From 489ea96a25147ee7520feeff427c34bc43507867 Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Fri, 23 Oct 2026 20:15:17 +0530 Subject: [PATCH 01/15] Add Python project ignore rules --- .gitignore | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..aaa2bdd1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Virtual environments +.venv/ +venv/ +env/ + +# Python bytecode +__pycache__/ +*.py[cod] + +# Packaging / build artifacts +build/ +dist/ +*.egg-info/ +.eggs/ + +# Test and tooling caches +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ +.coverage +htmlcov/ + +# Editor and OS files +.idea/ +.vscode/ +.DS_Store From 894f3b2d23def3c45145071384f9ed51fa19d054 Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 09:56:13 +0530 Subject: [PATCH 02/15] Fully migrate SDK to async on httpx2 --- README.md | 85 +- appwrite/client.py | 162 ++- appwrite/services/account.py | 252 ++--- appwrite/services/activities.py | 8 +- appwrite/services/advisor.py | 20 +- appwrite/services/apps.py | 88 +- appwrite/services/avatars.py | 44 +- appwrite/services/backups.py | 48 +- appwrite/services/databases.py | 288 +++--- appwrite/services/documents_db.py | 152 +-- appwrite/services/domains.py | 188 ++-- appwrite/services/embeddings.py | 4 +- appwrite/services/functions.py | 104 +- appwrite/services/graphql.py | 8 +- appwrite/services/locale.py | 32 +- appwrite/services/messaging.py | 192 ++-- appwrite/services/mongo.py | 128 +-- appwrite/services/mysql.py | 140 +-- appwrite/services/oauth2.py | 52 +- appwrite/services/organization.py | 92 +- appwrite/services/postgresql.py | 152 +-- appwrite/services/presences.py | 20 +- appwrite/services/project.py | 464 ++++----- appwrite/services/proxy.py | 40 +- appwrite/services/sites.py | 100 +- appwrite/services/storage.py | 52 +- appwrite/services/tables_db.py | 328 +++--- appwrite/services/teams.py | 72 +- appwrite/services/tokens.py | 20 +- appwrite/services/users.py | 188 ++-- appwrite/services/vectors_db.py | 144 +-- appwrite/services/waf.py | 52 +- appwrite/services/webhooks.py | 24 +- appwrite/utils/deprecated.py | 14 + pyproject.toml | 12 +- requirements.txt | 4 +- setup.py | 6 +- test/__init__.py | 4 + test/services/test_account.py | 946 +++++++---------- test/services/test_activities.py | 36 +- test/services/test_advisor.py | 75 +- test/services/test_apps.py | 296 +++--- test/services/test_avatars.py | 153 ++- test/services/test_backups.py | 166 ++- test/services/test_databases.py | 946 +++++++---------- test/services/test_documents_db.py | 504 ++++----- test/services/test_domains.py | 621 +++++------- test/services/test_embeddings.py | 23 +- test/services/test_functions.py | 348 +++---- test/services/test_graphql.py | 36 +- test/services/test_locale.py | 114 +-- test/services/test_messaging.py | 738 ++++++-------- test/services/test_mongo.py | 426 +++----- test/services/test_mysql.py | 465 ++++----- test/services/test_oauth2.py | 179 ++-- test/services/test_organization.py | 309 +++--- test/services/test_postgresql.py | 504 ++++----- test/services/test_presences.py | 75 +- test/services/test_project.py | 1518 +++++++++++----------------- test/services/test_proxy.py | 140 ++- test/services/test_sites.py | 335 +++--- test/services/test_storage.py | 179 ++-- test/services/test_tables_db.py | 1076 ++++++++------------ test/services/test_teams.py | 244 ++--- test/services/test_tokens.py | 75 +- test/services/test_users.py | 699 +++++-------- test/services/test_vectors_db.py | 478 ++++----- test/services/test_waf.py | 179 ++-- test/services/test_webhooks.py | 88 +- test/test_async_client.py | 114 +++ test/test_integration.py | 487 +++++++++ test/test_query.py | 64 +- 72 files changed, 7272 insertions(+), 9147 deletions(-) create mode 100644 test/test_async_client.py create mode 100644 test/test_integration.py diff --git a/README.md b/README.md index be1d4ed8..47cb3509 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Appwrite is an open-source backend as a service server that abstracts and simpli ## Installation -Requires Python 3.9 or later. Install the [`appwrite`](https://pypi.org/project/appwrite/) package from PyPI: +Requires Python 3.11 or later. Install the [`appwrite`](https://pypi.org/project/appwrite/) package from PyPI: ```bash pip install appwrite @@ -27,6 +27,8 @@ uv add appwrite ## Getting started +Every API call is asynchronous, so every service method returns a coroutine you `await`. + ### Initialize the client Create a client with your Appwrite endpoint, project ID and an [API key](https://appwrite.io/docs/partners/project/api-keys). Find the endpoint and project ID in your project's **Settings** page, and create an API key with only the scopes you need under **API keys** in the project sidebar. @@ -44,24 +46,31 @@ API keys grant server-level access to your project. Keep them out of client-side ### Make a request -Create a service object with the client and call any of its methods. Every method returns a typed Pydantic model, so response fields are available as attributes. +Create a service object with the client and await any of its methods. Every method returns a typed Pydantic model, so response fields are available as attributes. ```python +import asyncio + from appwrite.id import ID from appwrite.services.users import Users -users = Users(client) -user = users.create( - user_id=ID.unique(), - email='email@example.com', - password='password', - name="Walter O'Brien", -) +async def main(): + users = Users(client) + + user = await users.create( + user_id=ID.unique(), + email='email@example.com', + password='password', + name="Walter O'Brien", + ) + + print(user.id) + print(user.name) + print(user.to_dict()) -print(user.id) -print(user.name) -print(user.to_dict()) + +asyncio.run(main()) ``` See the [API reference](https://appwrite.io/docs/references/cloud/server-python/users) for every service and method. @@ -86,28 +95,29 @@ class Post(BaseModel): excerpt: Optional[str] = None -tables_db = TablesDB(client) +async def main(): + tables_db = TablesDB(client) -row = tables_db.create_row( - database_id='', - table_id='', - row_id=ID.unique(), - data={'title': 'Hello, world', 'published': True}, - model_type=Post, -) + row = await tables_db.create_row( + database_id='', + table_id='', + row_id=ID.unique(), + data={'title': 'Hello, world', 'published': True}, + model_type=Post, + ) -print(row.id) -print(row.data.title) + print(row.id) + print(row.data.title) -result = tables_db.list_rows( - database_id='', - table_id='', - queries=[Query.equal('published', True), Query.limit(25)], - model_type=Post, -) + result = await tables_db.list_rows( + database_id='', + table_id='', + queries=[Query.equal('published', True), Query.limit(25)], + model_type=Post, + ) -for row in result.rows: - print(row.data.title) + for row in result.rows: + print(row.data.title) ``` ### Handle errors @@ -118,11 +128,24 @@ Failed requests raise `AppwriteException`, which carries `message`, `code`, `typ from appwrite.exception import AppwriteException try: - user = users.get(user_id='') + user = await users.get(user_id='') except AppwriteException as error: print(error.code, error.type, error.message) ``` +### Close the client + +The client keeps a pooled HTTP connection open. Close it when you are done, or use it as an async context manager. + +```python +await client.aclose() +``` + +```python +async with Client() as client: + ... +``` + ### Self-hosted Appwrite Point the client at your own instance instead of Appwrite Cloud. Call `set_self_signed()` only in development, when the server uses a self-signed TLS certificate. diff --git a/appwrite/client.py b/appwrite/client.py index 4b4a5a0f..075a75aa 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -1,16 +1,25 @@ -import io +import asyncio +import inspect import json import os import platform import sys -import requests -from concurrent.futures import ThreadPoolExecutor, as_completed -from threading import Lock +import httpx2 from .input_file import InputFile from .exception import AppwriteException from .encoders.value_class_encoder import ValueClassEncoder from .query import Query +_ssl_context = None + + +def _default_ssl_context(): + """Build the TLS context once and reuse it across clients.""" + global _ssl_context + if _ssl_context is None: + _ssl_context = httpx2.create_ssl_context() + return _ssl_context + class Client: def __init__(self): @@ -27,11 +36,38 @@ def __init__(self): 'X-Appwrite-Response-Format': '2.5.0', } self._config = {} + self._http = self._new_http_client(verify=True) + + def _new_http_client(self, verify): + context = _default_ssl_context() if verify else False + return httpx2.AsyncClient(verify=context, timeout=None) + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + await self.aclose() + + async def aclose(self): + """Close the underlying HTTP connection pool.""" + await self._http.aclose() def set_self_signed(self, status=True): + """Accept self-signed TLS certificates.""" self._self_signed = status + previous = self._http + self._http = self._new_http_client(verify=not status) + self._dispose(previous) return self + @staticmethod + def _dispose(client): + try: + loop = asyncio.get_running_loop() + except RuntimeError: + return + loop.create_task(client.aclose()) + def set_endpoint(self, endpoint): if not endpoint.startswith('http://') and not endpoint.startswith('https://'): raise AppwriteException('Invalid endpoint URL: ' + endpoint) @@ -130,7 +166,8 @@ def set_impersonate_user_phone(self, value): self._config['impersonateuserphone'] = value return self - def call(self, method, path='', headers=None, params=None, response_type='json'): + async def call(self, method, path='', headers=None, params=None, response_type='json'): + """Perform a single API request.""" if headers is None: headers = {} @@ -141,6 +178,7 @@ def call(self, method, path='', headers=None, params=None, response_type='json') data = {} files = {} + content = None stringify = False headers = {**self._global_headers, **headers} @@ -150,37 +188,43 @@ def call(self, method, path='', headers=None, params=None, response_type='json') params = {} if headers['content-type'].startswith('application/json'): - data = json.dumps(data, cls=ValueClassEncoder) + content = json.dumps(data, cls=ValueClassEncoder) + data = {} if headers['content-type'].startswith('multipart/form-data'): del headers['content-type'] stringify = True for key in data.copy(): if isinstance(data[key], InputFile): - files[key] = (data[key].filename, data[key].data) + payload = data[key].data + if isinstance(payload, str): + payload = payload.encode('utf-8') + elif not isinstance(payload, bytes): + payload = bytes(payload) + files[key] = (data[key].filename, payload) del data[key] data = self.flatten(data, stringify=stringify) if not files and data: - # Without a file, requests would fall back to a URL-encoded body. + # Without a file, httpx2 would fall back to a URL-encoded body. files = {key: (None, value) for key, value in data.items()} data = {} elif not files: - # With no parts at all, requests would send a bare body, so close an empty multipart one. + # With no parts at all, httpx2 would send a bare body, so close an empty multipart one. boundary = os.urandom(16).hex() headers['content-type'] = f'multipart/form-data; boundary={boundary}' - data = f'--{boundary}--\r\n' + content = f'--{boundary}--\r\n' response = None try: - response = requests.request( # call method dynamically https://stackoverflow.com/a/4246075/2299554 + response = await self._http.request( # call method dynamically https://stackoverflow.com/a/4246075/2299554 method=method, url=self._endpoint + path, params=self.flatten(params, stringify=stringify), - data=data, - files=files, + data=data or None, + files=files or None, + content=content, headers=headers, - verify=(not self._self_signed), - allow_redirects=False if response_type == 'location' else True, + follow_redirects=False if response_type == 'location' else True, ) response.raise_for_status() @@ -190,7 +234,7 @@ def call(self, method, path='', headers=None, params=None, response_type='json') for warning in warnings.split(';'): print(f'Warning: {warning}', file=sys.stderr) - content_type = response.headers['Content-Type'] + content_type = response.headers.get('Content-Type', '') if response_type == 'location': return response.headers.get('Location') @@ -201,10 +245,10 @@ def call(self, method, path='', headers=None, params=None, response_type='json') if content_type.startswith('application/json'): return response.json() - return response._content + return response.content except Exception as e: if response != None: - content_type = response.headers['Content-Type'] + content_type = response.headers.get('Content-Type', '') if content_type.startswith('application/json'): raise AppwriteException( response.json()['message'], response.status_code, response.json().get('type'), response.text @@ -214,7 +258,7 @@ def call(self, method, path='', headers=None, params=None, response_type='json') else: raise AppwriteException(e) - def chunked_upload( + async def chunked_upload( self, path, headers=None, @@ -225,8 +269,9 @@ def chunked_upload( response_type='json', method='post', ): + """Upload a file in chunks, reporting progress as it goes.""" if params.get(param_name) is None: - return self.call(method, path, headers, params, response_type=response_type) + return await self.call(method, path, headers, params, response_type=response_type) input_file = params[param_name] @@ -243,14 +288,14 @@ def chunked_upload( input_file.data = input.read() params[param_name] = input_file - return self.call(method, path, headers, params, response_type=response_type) + return await self.call(method, path, headers, params, response_type=response_type) offset = 0 counter = 0 if upload_id: try: - result = self.call('get', path + '/' + upload_id, headers) + result = await self.call('get', path + '/' + upload_id, headers) counter = result['chunksUploaded'] except: pass @@ -285,7 +330,6 @@ def read_chunk(start, end): upload_id_header = upload_id completed_count = chunks[0]['index'] uploaded_size = chunks[0]['start'] - progress_lock = Lock() last_result = None final_result = None @@ -298,9 +342,9 @@ def is_upload_complete(chunk_result): chunks_total = chunk_result.get('chunksTotal', total_chunks) return int(chunks_uploaded) >= int(chunks_total) - def upload_chunk(chunk, current_upload_id): + async def upload_chunk(chunk, current_upload_id): chunk_input = InputFile.from_bytes( - read_chunk(chunk['start'], chunk['end']), + await asyncio.to_thread(read_chunk, chunk['start'], chunk['end']), input_file.filename, getattr(input_file, 'mime_type', None), ) @@ -310,7 +354,7 @@ def upload_chunk(chunk, current_upload_id): if current_upload_id: chunk_headers["x-appwrite-id"] = current_upload_id - return self.call( + return await self.call( method, path, chunk_headers, @@ -318,7 +362,7 @@ def upload_chunk(chunk, current_upload_id): response_type=response_type, ) - result = upload_chunk(chunks[0], upload_id_header) + result = await upload_chunk(chunks[0], upload_id_header) last_result = result if isinstance(result, dict) and "$id" in result: upload_id_header = result["$id"] @@ -326,44 +370,52 @@ def upload_chunk(chunk, current_upload_id): completed_count = chunks[0]['index'] + 1 uploaded_size = chunks[0]['end'] - if on_progress is not None: - on_progress( + await self._report_progress( + on_progress, + { + "$id": result.get("$id") if isinstance(result, dict) else None, + "progress": uploaded_size / size * 100, + "sizeUploaded": uploaded_size, + "chunksTotal": total_chunks, + "chunksUploaded": completed_count, + }, + ) + + semaphore = asyncio.Semaphore(8) + + async def upload_remaining_chunk(chunk): + nonlocal completed_count, uploaded_size, last_result, final_result + async with semaphore: + chunk_result = await upload_chunk(chunk, upload_id_header) + completed_count = completed_count + 1 + uploaded_size = uploaded_size + (chunk['end'] - chunk['start']) + last_result = chunk_result + if is_upload_complete(chunk_result): + final_result = chunk_result + await self._report_progress( + on_progress, { - "$id": result.get("$id") if isinstance(result, dict) else None, + "$id": upload_id_header, "progress": uploaded_size / size * 100, "sizeUploaded": uploaded_size, "chunksTotal": total_chunks, "chunksUploaded": completed_count, - } + }, ) - def upload_remaining_chunk(chunk): - nonlocal completed_count, uploaded_size, last_result, final_result - chunk_result = upload_chunk(chunk, upload_id_header) - with progress_lock: - completed_count = completed_count + 1 - uploaded_size = uploaded_size + (chunk['end'] - chunk['start']) - last_result = chunk_result - if is_upload_complete(chunk_result): - final_result = chunk_result - if on_progress is not None: - on_progress( - { - "$id": upload_id_header, - "progress": uploaded_size / size * 100, - "sizeUploaded": uploaded_size, - "chunksTotal": total_chunks, - "chunksUploaded": completed_count, - } - ) - - with ThreadPoolExecutor(max_workers=8) as executor: - futures = [executor.submit(upload_remaining_chunk, chunk) for chunk in chunks[1:]] - for future in as_completed(futures): - future.result() + await asyncio.gather(*(upload_remaining_chunk(chunk) for chunk in chunks[1:])) return final_result or last_result + @staticmethod + async def _report_progress(on_progress, payload): + """Invoke the progress callback, awaiting it when it is a coroutine.""" + if on_progress is None: + return + result = on_progress(payload) + if inspect.isawaitable(result): + await result + def flatten(self, data, prefix='', stringify=False): output = {} entries = data.items() if isinstance(data, dict) else enumerate(data) diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 9788e53c..f3cb5611 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -35,7 +35,7 @@ class Account(Service): def __init__(self, client) -> None: super(Account, self).__init__(client) - def get( + async def get( self, model_type: Type[T] = dict, ) -> User[T]: @@ -61,7 +61,7 @@ def get( api_path = '/account' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -73,7 +73,7 @@ def get( return User.with_data(response, model_type) - def create( + async def create( self, user_id: str, email: str, @@ -122,7 +122,7 @@ def create( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -135,7 +135,7 @@ def create( return User.with_data(response, model_type) - def list_consents( + async def list_consents( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -167,7 +167,7 @@ def list_consents( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -179,7 +179,7 @@ def list_consents( return self._parse_response(response, model=Oauth2ConsentList) - def get_consent( + async def get_consent( self, consent_id: str, ) -> Oauth2Consent: @@ -207,7 +207,7 @@ def get_consent( raise AppwriteException('Missing required parameter: "consent_id"') api_path = api_path.replace('{consentId}', str(self._normalize_value(consent_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -219,7 +219,7 @@ def get_consent( return self._parse_response(response, model=Oauth2Consent) - def delete_consent( + async def delete_consent( self, consent_id: str, ) -> Dict[str, Any]: @@ -247,7 +247,7 @@ def delete_consent( raise AppwriteException('Missing required parameter: "consent_id"') api_path = api_path.replace('{consentId}', str(self._normalize_value(consent_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -260,7 +260,7 @@ def delete_consent( return response - def list_consent_tokens( + async def list_consent_tokens( self, consent_id: str, queries: Optional[List[str]] = None, @@ -298,7 +298,7 @@ def list_consent_tokens( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -310,7 +310,7 @@ def list_consent_tokens( return self._parse_response(response, model=Oauth2ConsentTokenList) - def get_consent_token( + async def get_consent_token( self, consent_id: str, token_id: str, @@ -344,7 +344,7 @@ def get_consent_token( api_path = api_path.replace('{consentId}', str(self._normalize_value(consent_id))) api_path = api_path.replace('{tokenId}', str(self._normalize_value(token_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -356,7 +356,7 @@ def get_consent_token( return self._parse_response(response, model=Oauth2ConsentToken) - def delete_consent_token( + async def delete_consent_token( self, consent_id: str, token_id: str, @@ -390,7 +390,7 @@ def delete_consent_token( api_path = api_path.replace('{consentId}', str(self._normalize_value(consent_id))) api_path = api_path.replace('{tokenId}', str(self._normalize_value(token_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -403,7 +403,7 @@ def delete_consent_token( return response - def update_email( + async def update_email( self, email: str, password: str, @@ -442,7 +442,7 @@ def update_email( api_params['email'] = self._normalize_value(email) api_params['password'] = self._normalize_value(password) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -455,7 +455,7 @@ def update_email( return User.with_data(response, model_type) - def list_identities( + async def list_identities( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -487,7 +487,7 @@ def list_identities( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -499,7 +499,7 @@ def list_identities( return self._parse_response(response, model=IdentityList) - def delete_identity( + async def delete_identity( self, identity_id: str, ) -> Dict[str, Any]: @@ -527,7 +527,7 @@ def delete_identity( raise AppwriteException('Missing required parameter: "identity_id"') api_path = api_path.replace('{identityId}', str(self._normalize_value(identity_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -540,7 +540,7 @@ def delete_identity( return response - def list_memberships( + async def list_memberships( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -572,7 +572,7 @@ def list_memberships( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -584,7 +584,7 @@ def list_memberships( return self._parse_response(response, model=MembershipList) - def update_mfa( + async def update_mfa( self, mfa: bool, model_type: Type[T] = dict, @@ -616,7 +616,7 @@ def update_mfa( raise AppwriteException('Missing required parameter: "mfa"') api_params['mfa'] = self._normalize_value(mfa) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -629,7 +629,7 @@ def update_mfa( return User.with_data(response, model_type) - def create_mfa_authenticator( + async def create_mfa_authenticator( self, type: AuthenticatorType, ) -> MfaType: @@ -657,7 +657,7 @@ def create_mfa_authenticator( raise AppwriteException('Missing required parameter: "type"') api_path = api_path.replace('{type}', str(self._normalize_value(type))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -670,7 +670,7 @@ def create_mfa_authenticator( return self._parse_response(response, model=MfaType) - def update_mfa_authenticator( + async def update_mfa_authenticator( self, type: AuthenticatorType, otp: str, @@ -708,7 +708,7 @@ def update_mfa_authenticator( api_path = api_path.replace('{type}', str(self._normalize_value(type))) api_params['otp'] = self._normalize_value(otp) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -721,7 +721,7 @@ def update_mfa_authenticator( return User.with_data(response, model_type) - def delete_mfa_authenticator( + async def delete_mfa_authenticator( self, type: AuthenticatorType, ) -> Dict[str, Any]: @@ -749,7 +749,7 @@ def delete_mfa_authenticator( raise AppwriteException('Missing required parameter: "type"') api_path = api_path.replace('{type}', str(self._normalize_value(type))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -762,7 +762,7 @@ def delete_mfa_authenticator( return response - def create_mfa_challenge( + async def create_mfa_challenge( self, factor: AuthenticationFactor, ) -> MfaChallenge: @@ -790,7 +790,7 @@ def create_mfa_challenge( raise AppwriteException('Missing required parameter: "factor"') api_params['factor'] = self._normalize_value(factor) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -803,7 +803,7 @@ def create_mfa_challenge( return self._parse_response(response, model=MfaChallenge) - def update_mfa_challenge( + async def update_mfa_challenge( self, challenge_id: str, otp: str, @@ -837,7 +837,7 @@ def update_mfa_challenge( api_params['challengeId'] = self._normalize_value(challenge_id) api_params['otp'] = self._normalize_value(otp) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -850,7 +850,7 @@ def update_mfa_challenge( return self._parse_response(response, model=Session) - def list_mfa_factors( + async def list_mfa_factors( self, ) -> MfaFactors: """ @@ -869,7 +869,7 @@ def list_mfa_factors( api_path = '/account/mfa/factors' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -881,7 +881,7 @@ def list_mfa_factors( return self._parse_response(response, model=MfaFactors) - def get_mfa_recovery_codes( + async def get_mfa_recovery_codes( self, ) -> MfaRecoveryCodes: """ @@ -900,7 +900,7 @@ def get_mfa_recovery_codes( api_path = '/account/mfa/recovery-codes' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -912,7 +912,7 @@ def get_mfa_recovery_codes( return self._parse_response(response, model=MfaRecoveryCodes) - def create_mfa_recovery_codes( + async def create_mfa_recovery_codes( self, ) -> MfaRecoveryCodes: """ @@ -931,7 +931,7 @@ def create_mfa_recovery_codes( api_path = '/account/mfa/recovery-codes' api_params = {} - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -944,7 +944,7 @@ def create_mfa_recovery_codes( return self._parse_response(response, model=MfaRecoveryCodes) - def update_mfa_recovery_codes( + async def update_mfa_recovery_codes( self, ) -> MfaRecoveryCodes: """ @@ -963,7 +963,7 @@ def update_mfa_recovery_codes( api_path = '/account/mfa/recovery-codes' api_params = {} - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -976,7 +976,7 @@ def update_mfa_recovery_codes( return self._parse_response(response, model=MfaRecoveryCodes) - def update_name( + async def update_name( self, name: str, model_type: Type[T] = dict, @@ -1008,7 +1008,7 @@ def update_name( raise AppwriteException('Missing required parameter: "name"') api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1021,7 +1021,7 @@ def update_name( return User.with_data(response, model_type) - def list_passkeys( + async def list_passkeys( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -1053,7 +1053,7 @@ def list_passkeys( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1065,7 +1065,7 @@ def list_passkeys( return self._parse_response(response, model=PasskeyList) - def create_passkey( + async def create_passkey( self, passkey_id: Optional[str] = None, name: Optional[str] = None, @@ -1097,7 +1097,7 @@ def create_passkey( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1110,7 +1110,7 @@ def create_passkey( return self._parse_response(response, model=PasskeyChallenge) - def get_passkey( + async def get_passkey( self, passkey_id: str, ) -> Passkey: @@ -1138,7 +1138,7 @@ def get_passkey( raise AppwriteException('Missing required parameter: "passkey_id"') api_path = api_path.replace('{passkeyId}', str(self._normalize_value(passkey_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1150,7 +1150,7 @@ def get_passkey( return self._parse_response(response, model=Passkey) - def update_passkey( + async def update_passkey( self, passkey_id: str, name: str, @@ -1184,7 +1184,7 @@ def update_passkey( api_path = api_path.replace('{passkeyId}', str(self._normalize_value(passkey_id))) api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1197,7 +1197,7 @@ def update_passkey( return self._parse_response(response, model=Passkey) - def delete_passkey( + async def delete_passkey( self, passkey_id: str, ) -> Dict[str, Any]: @@ -1225,7 +1225,7 @@ def delete_passkey( raise AppwriteException('Missing required parameter: "passkey_id"') api_path = api_path.replace('{passkeyId}', str(self._normalize_value(passkey_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1238,7 +1238,7 @@ def delete_passkey( return response - def update_passkey_verification( + async def update_passkey_verification( self, passkey_id: str, credential: Dict[str, Any], @@ -1272,7 +1272,7 @@ def update_passkey_verification( api_path = api_path.replace('{passkeyId}', str(self._normalize_value(passkey_id))) api_params['credential'] = self._normalize_value(credential) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1285,7 +1285,7 @@ def update_passkey_verification( return self._parse_response(response, model=Passkey) - def update_password( + async def update_password( self, password: str, old_password: Optional[str] = None, @@ -1322,7 +1322,7 @@ def update_password( if old_password is not None: api_params['oldPassword'] = self._normalize_value(old_password) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1335,7 +1335,7 @@ def update_password( return User.with_data(response, model_type) - def update_phone( + async def update_phone( self, phone: str, password: str, @@ -1373,7 +1373,7 @@ def update_phone( api_params['phone'] = self._normalize_value(phone) api_params['password'] = self._normalize_value(password) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1386,7 +1386,7 @@ def update_phone( return User.with_data(response, model_type) - def get_prefs( + async def get_prefs( self, model_type: Type[T] = dict, ) -> Preferences[T]: @@ -1412,7 +1412,7 @@ def get_prefs( api_path = '/account/prefs' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1424,7 +1424,7 @@ def get_prefs( return Preferences.with_data(response, model_type) - def update_prefs( + async def update_prefs( self, prefs: Dict[str, Any], model_type: Type[T] = dict, @@ -1456,7 +1456,7 @@ def update_prefs( raise AppwriteException('Missing required parameter: "prefs"') api_params['prefs'] = self._normalize_value(prefs) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1469,7 +1469,7 @@ def update_prefs( return User.with_data(response, model_type) - def create_recovery( + async def create_recovery( self, email: str, url: str, @@ -1503,7 +1503,7 @@ def create_recovery( api_params['email'] = self._normalize_value(email) api_params['url'] = self._normalize_value(url) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1516,7 +1516,7 @@ def create_recovery( return self._parse_response(response, model=Token) - def update_recovery( + async def update_recovery( self, user_id: str, secret: str, @@ -1560,7 +1560,7 @@ def update_recovery( api_params['secret'] = self._normalize_value(secret) api_params['password'] = self._normalize_value(password) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1573,7 +1573,7 @@ def update_recovery( return self._parse_response(response, model=Token) - def create_recovery_otp( + async def create_recovery_otp( self, email: str, phrase: Optional[bool] = None, @@ -1608,7 +1608,7 @@ def create_recovery_otp( if phrase is not None: api_params['phrase'] = self._normalize_value(phrase) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1621,7 +1621,7 @@ def create_recovery_otp( return self._parse_response(response, model=Token) - def update_recovery_otp( + async def update_recovery_otp( self, user_id: str, secret: str, @@ -1663,7 +1663,7 @@ def update_recovery_otp( api_params['secret'] = self._normalize_value(secret) api_params['password'] = self._normalize_value(password) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1676,7 +1676,7 @@ def update_recovery_otp( return self._parse_response(response, model=Token) - def list_sessions( + async def list_sessions( self, total: Optional[bool] = None, ) -> SessionList: @@ -1703,7 +1703,7 @@ def list_sessions( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1715,7 +1715,7 @@ def list_sessions( return self._parse_response(response, model=SessionList) - def delete_sessions( + async def delete_sessions( self, current: Optional[bool] = None, ) -> Dict[str, Any]: @@ -1742,7 +1742,7 @@ def delete_sessions( if current is not None: api_params['current'] = self._normalize_value(current) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1755,7 +1755,7 @@ def delete_sessions( return response - def create_anonymous_session( + async def create_anonymous_session( self, ) -> Session: """ @@ -1774,7 +1774,7 @@ def create_anonymous_session( api_path = '/account/sessions/anonymous' api_params = {} - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1787,7 +1787,7 @@ def create_anonymous_session( return self._parse_response(response, model=Session) - def create_email_password_session( + async def create_email_password_session( self, email: str, password: str, @@ -1828,7 +1828,7 @@ def create_email_password_session( if duration is not None: api_params['duration'] = self._normalize_value(duration) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1841,7 +1841,7 @@ def create_email_password_session( return self._parse_response(response, model=Session) - def create_id_token_session( + async def create_id_token_session( self, provider: IdTokenProvider, id_token: str, @@ -1905,7 +1905,7 @@ def create_id_token_session( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1919,7 +1919,7 @@ def create_id_token_session( return self._parse_response(response, model=Session) @deprecated("This API has been deprecated since 1.6.0. Please use `account.create_session` instead.") - def update_magic_url_session( + async def update_magic_url_session( self, user_id: str, secret: str, @@ -1955,7 +1955,7 @@ def update_magic_url_session( api_params['userId'] = self._normalize_value(user_id) api_params['secret'] = self._normalize_value(secret) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1969,7 +1969,7 @@ def update_magic_url_session( return self._parse_response(response, model=Session) @deprecated("This API has been deprecated since 1.6.0. Please use `account.create_session` instead.") - def update_phone_session( + async def update_phone_session( self, user_id: str, secret: str, @@ -2005,7 +2005,7 @@ def update_phone_session( api_params['userId'] = self._normalize_value(user_id) api_params['secret'] = self._normalize_value(secret) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -2018,7 +2018,7 @@ def update_phone_session( return self._parse_response(response, model=Session) - def create_session( + async def create_session( self, user_id: str, secret: str, @@ -2052,7 +2052,7 @@ def create_session( api_params['userId'] = self._normalize_value(user_id) api_params['secret'] = self._normalize_value(secret) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2065,7 +2065,7 @@ def create_session( return self._parse_response(response, model=Session) - def get_session( + async def get_session( self, session_id: str, ) -> Session: @@ -2093,7 +2093,7 @@ def get_session( raise AppwriteException('Missing required parameter: "session_id"') api_path = api_path.replace('{sessionId}', str(self._normalize_value(session_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2105,7 +2105,7 @@ def get_session( return self._parse_response(response, model=Session) - def update_session( + async def update_session( self, session_id: str, ) -> Session: @@ -2133,7 +2133,7 @@ def update_session( raise AppwriteException('Missing required parameter: "session_id"') api_path = api_path.replace('{sessionId}', str(self._normalize_value(session_id))) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2146,7 +2146,7 @@ def update_session( return self._parse_response(response, model=Session) - def delete_session( + async def delete_session( self, session_id: str, ) -> Dict[str, Any]: @@ -2174,7 +2174,7 @@ def delete_session( raise AppwriteException('Missing required parameter: "session_id"') api_path = api_path.replace('{sessionId}', str(self._normalize_value(session_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -2187,7 +2187,7 @@ def delete_session( return response - def update_status( + async def update_status( self, model_type: Type[T] = dict, ) -> User[T]: @@ -2213,7 +2213,7 @@ def update_status( api_path = '/account/status' api_params = {} - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2226,7 +2226,7 @@ def update_status( return User.with_data(response, model_type) - def create_email_token( + async def create_email_token( self, user_id: str, email: str, @@ -2267,7 +2267,7 @@ def create_email_token( if phrase is not None: api_params['phrase'] = self._normalize_value(phrase) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2280,7 +2280,7 @@ def create_email_token( return self._parse_response(response, model=Token) - def create_magic_url_token( + async def create_magic_url_token( self, user_id: str, email: str, @@ -2326,7 +2326,7 @@ def create_magic_url_token( if phrase is not None: api_params['phrase'] = self._normalize_value(phrase) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2339,7 +2339,7 @@ def create_magic_url_token( return self._parse_response(response, model=Token) - def create_o_auth2_token( + async def create_o_auth2_token( self, provider: OAuthProvider, success: Optional[str] = None, @@ -2393,7 +2393,7 @@ def create_o_auth2_token( if state is not None: api_params['state'] = self._normalize_value(state) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2406,7 +2406,7 @@ def create_o_auth2_token( return response - def create_passkey_token( + async def create_passkey_token( self, ) -> PasskeyChallenge: """ @@ -2425,7 +2425,7 @@ def create_passkey_token( api_path = '/account/tokens/passkey' api_params = {} - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2438,7 +2438,7 @@ def create_passkey_token( return self._parse_response(response, model=PasskeyChallenge) - def update_passkey_token( + async def update_passkey_token( self, challenge_id: str, credential: Dict[str, Any], @@ -2472,7 +2472,7 @@ def update_passkey_token( api_params['challengeId'] = self._normalize_value(challenge_id) api_params['credential'] = self._normalize_value(credential) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -2485,7 +2485,7 @@ def update_passkey_token( return self._parse_response(response, model=TokenSecret) - def create_phone_token( + async def create_phone_token( self, user_id: str, phone: str, @@ -2521,7 +2521,7 @@ def create_phone_token( api_params['userId'] = self._normalize_value(user_id) api_params['phone'] = self._normalize_value(phone) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2534,7 +2534,7 @@ def create_phone_token( return self._parse_response(response, model=Token) - def create_email_verification( + async def create_email_verification( self, url: str, ) -> Token: @@ -2564,7 +2564,7 @@ def create_email_verification( raise AppwriteException('Missing required parameter: "url"') api_params['url'] = self._normalize_value(url) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2578,7 +2578,7 @@ def create_email_verification( return self._parse_response(response, model=Token) @deprecated("This API has been deprecated since 1.8.0. Please use `account.create_email_verification` instead.") - def create_verification( + async def create_verification( self, url: str, ) -> Token: @@ -2610,7 +2610,7 @@ def create_verification( raise AppwriteException('Missing required parameter: "url"') api_params['url'] = self._normalize_value(url) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2623,7 +2623,7 @@ def create_verification( return self._parse_response(response, model=Token) - def update_email_verification( + async def update_email_verification( self, user_id: str, secret: str, @@ -2657,7 +2657,7 @@ def update_email_verification( api_params['userId'] = self._normalize_value(user_id) api_params['secret'] = self._normalize_value(secret) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -2671,7 +2671,7 @@ def update_email_verification( return self._parse_response(response, model=Token) @deprecated("This API has been deprecated since 1.8.0. Please use `account.update_email_verification` instead.") - def update_verification( + async def update_verification( self, user_id: str, secret: str, @@ -2707,7 +2707,7 @@ def update_verification( api_params['userId'] = self._normalize_value(user_id) api_params['secret'] = self._normalize_value(secret) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -2720,7 +2720,7 @@ def update_verification( return self._parse_response(response, model=Token) - def create_email_verification_otp( + async def create_email_verification_otp( self, phrase: Optional[bool] = None, ) -> Token: @@ -2749,7 +2749,7 @@ def create_email_verification_otp( if phrase is not None: api_params['phrase'] = self._normalize_value(phrase) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2762,7 +2762,7 @@ def create_email_verification_otp( return self._parse_response(response, model=Token) - def update_email_verification_otp( + async def update_email_verification_otp( self, user_id: str, secret: str, @@ -2796,7 +2796,7 @@ def update_email_verification_otp( api_params['userId'] = self._normalize_value(user_id) api_params['secret'] = self._normalize_value(secret) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -2809,7 +2809,7 @@ def update_email_verification_otp( return self._parse_response(response, model=Token) - def create_phone_verification( + async def create_phone_verification( self, ) -> Token: """ @@ -2828,7 +2828,7 @@ def create_phone_verification( api_path = '/account/verifications/phone' api_params = {} - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2841,7 +2841,7 @@ def create_phone_verification( return self._parse_response(response, model=Token) - def update_phone_verification( + async def update_phone_verification( self, user_id: str, secret: str, @@ -2875,7 +2875,7 @@ def update_phone_verification( api_params['userId'] = self._normalize_value(user_id) api_params['secret'] = self._normalize_value(secret) - response = self.client.call( + response = await self.client.call( 'put', api_path, { diff --git a/appwrite/services/activities.py b/appwrite/services/activities.py index 8556609f..2325aec4 100644 --- a/appwrite/services/activities.py +++ b/appwrite/services/activities.py @@ -12,7 +12,7 @@ class Activities(Service): def __init__(self, client) -> None: super(Activities, self).__init__(client) - def list_events( + async def list_events( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -44,7 +44,7 @@ def list_events( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -56,7 +56,7 @@ def list_events( return self._parse_response(response, model=ActivityEventList) - def get_event( + async def get_event( self, event_id: str, ) -> ActivityEvent: @@ -84,7 +84,7 @@ def get_event( raise AppwriteException('Missing required parameter: "event_id"') api_path = api_path.replace('{eventId}', str(self._normalize_value(event_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { diff --git a/appwrite/services/advisor.py b/appwrite/services/advisor.py index 194d0b7a..4660bb4e 100644 --- a/appwrite/services/advisor.py +++ b/appwrite/services/advisor.py @@ -14,7 +14,7 @@ class Advisor(Service): def __init__(self, client) -> None: super(Advisor, self).__init__(client) - def list_reports( + async def list_reports( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -46,7 +46,7 @@ def list_reports( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -58,7 +58,7 @@ def list_reports( return self._parse_response(response, model=ReportList) - def get_report( + async def get_report( self, report_id: str, ) -> Report: @@ -86,7 +86,7 @@ def get_report( raise AppwriteException('Missing required parameter: "report_id"') api_path = api_path.replace('{reportId}', str(self._normalize_value(report_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -98,7 +98,7 @@ def get_report( return self._parse_response(response, model=Report) - def delete_report( + async def delete_report( self, report_id: str, ) -> Dict[str, Any]: @@ -126,7 +126,7 @@ def delete_report( raise AppwriteException('Missing required parameter: "report_id"') api_path = api_path.replace('{reportId}', str(self._normalize_value(report_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -139,7 +139,7 @@ def delete_report( return response - def list_insights( + async def list_insights( self, report_id: str, queries: Optional[List[str]] = None, @@ -177,7 +177,7 @@ def list_insights( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -189,7 +189,7 @@ def list_insights( return self._parse_response(response, model=InsightList) - def get_insight( + async def get_insight( self, report_id: str, insight_id: str, @@ -223,7 +223,7 @@ def get_insight( api_path = api_path.replace('{reportId}', str(self._normalize_value(report_id))) api_path = api_path.replace('{insightId}', str(self._normalize_value(insight_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { diff --git a/appwrite/services/apps.py b/appwrite/services/apps.py index 6a3439a6..e6940ea9 100644 --- a/appwrite/services/apps.py +++ b/appwrite/services/apps.py @@ -21,7 +21,7 @@ class Apps(Service): def __init__(self, client) -> None: super(Apps, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -53,7 +53,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -65,7 +65,7 @@ def list( return self._parse_response(response, model=AppsList) - def create( + async def create( self, app_id: str, name: str, @@ -185,7 +185,7 @@ def create( if team_id is not None: api_params['teamId'] = self._normalize_value(team_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -198,7 +198,7 @@ def create( return self._parse_response(response, model=App) - def list_installation_scopes( + async def list_installation_scopes( self, ) -> AppScopeList: """ @@ -217,7 +217,7 @@ def list_installation_scopes( api_path = '/apps/scopes/installations' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -229,7 +229,7 @@ def list_installation_scopes( return self._parse_response(response, model=AppScopeList) - def list_o_auth2_scopes( + async def list_o_auth2_scopes( self, ) -> AppScopeList: """ @@ -248,7 +248,7 @@ def list_o_auth2_scopes( api_path = '/apps/scopes/oauth2' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -260,7 +260,7 @@ def list_o_auth2_scopes( return self._parse_response(response, model=AppScopeList) - def get( + async def get( self, app_id: str, ) -> App: @@ -288,7 +288,7 @@ def get( raise AppwriteException('Missing required parameter: "app_id"') api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -300,7 +300,7 @@ def get( return self._parse_response(response, model=App) - def update( + async def update( self, app_id: str, name: str, @@ -424,7 +424,7 @@ def update( if installation_redirect_url is not None: api_params['installationRedirectUrl'] = self._normalize_value(installation_redirect_url) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -437,7 +437,7 @@ def update( return self._parse_response(response, model=App) - def delete( + async def delete( self, app_id: str, ) -> Dict[str, Any]: @@ -465,7 +465,7 @@ def delete( raise AppwriteException('Missing required parameter: "app_id"') api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -478,7 +478,7 @@ def delete( return response - def list_installations( + async def list_installations( self, app_id: str, queries: Optional[List[str]] = None, @@ -516,7 +516,7 @@ def list_installations( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -528,7 +528,7 @@ def list_installations( return self._parse_response(response, model=AppInstallationList) - def get_installation( + async def get_installation( self, app_id: str, installation_id: str, @@ -562,7 +562,7 @@ def get_installation( api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) api_path = api_path.replace('{installationId}', str(self._normalize_value(installation_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -574,7 +574,7 @@ def get_installation( return self._parse_response(response, model=AppInstallation) - def delete_installation( + async def delete_installation( self, app_id: str, installation_id: str, @@ -608,7 +608,7 @@ def delete_installation( api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) api_path = api_path.replace('{installationId}', str(self._normalize_value(installation_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -621,7 +621,7 @@ def delete_installation( return response - def create_installation_token( + async def create_installation_token( self, app_id: str, installation_id: str, @@ -655,7 +655,7 @@ def create_installation_token( api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) api_path = api_path.replace('{installationId}', str(self._normalize_value(installation_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -668,7 +668,7 @@ def create_installation_token( return self._parse_response(response, model=Oauth2Token) - def list_keys( + async def list_keys( self, app_id: str, queries: Optional[List[str]] = None, @@ -706,7 +706,7 @@ def list_keys( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -718,7 +718,7 @@ def list_keys( return self._parse_response(response, model=AppKeyList) - def create_key( + async def create_key( self, app_id: str, ) -> AppKey: @@ -746,7 +746,7 @@ def create_key( raise AppwriteException('Missing required parameter: "app_id"') api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -759,7 +759,7 @@ def create_key( return self._parse_response(response, model=AppKey) - def get_key( + async def get_key( self, app_id: str, key_id: str, @@ -793,7 +793,7 @@ def get_key( api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -805,7 +805,7 @@ def get_key( return self._parse_response(response, model=AppKey) - def delete_key( + async def delete_key( self, app_id: str, key_id: str, @@ -839,7 +839,7 @@ def delete_key( api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -852,7 +852,7 @@ def delete_key( return response - def update_labels( + async def update_labels( self, app_id: str, labels: List[str], @@ -886,7 +886,7 @@ def update_labels( api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) api_params['labels'] = self._normalize_value(labels) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -899,7 +899,7 @@ def update_labels( return self._parse_response(response, model=App) - def list_secrets( + async def list_secrets( self, app_id: str, queries: Optional[List[str]] = None, @@ -937,7 +937,7 @@ def list_secrets( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -949,7 +949,7 @@ def list_secrets( return self._parse_response(response, model=AppSecretList) - def create_secret( + async def create_secret( self, app_id: str, ) -> AppSecretPlaintext: @@ -977,7 +977,7 @@ def create_secret( raise AppwriteException('Missing required parameter: "app_id"') api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -990,7 +990,7 @@ def create_secret( return self._parse_response(response, model=AppSecretPlaintext) - def get_secret( + async def get_secret( self, app_id: str, secret_id: str, @@ -1024,7 +1024,7 @@ def get_secret( api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) api_path = api_path.replace('{secretId}', str(self._normalize_value(secret_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1036,7 +1036,7 @@ def get_secret( return self._parse_response(response, model=AppSecret) - def delete_secret( + async def delete_secret( self, app_id: str, secret_id: str, @@ -1070,7 +1070,7 @@ def delete_secret( api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) api_path = api_path.replace('{secretId}', str(self._normalize_value(secret_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1083,7 +1083,7 @@ def delete_secret( return response - def update_team( + async def update_team( self, app_id: str, team_id: str, @@ -1117,7 +1117,7 @@ def update_team( api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) api_params['teamId'] = self._normalize_value(team_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1130,7 +1130,7 @@ def update_team( return self._parse_response(response, model=App) - def delete_tokens( + async def delete_tokens( self, app_id: str, ) -> Dict[str, Any]: @@ -1158,7 +1158,7 @@ def delete_tokens( raise AppwriteException('Missing required parameter: "app_id"') api_path = api_path.replace('{appId}', str(self._normalize_value(app_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index a01b4baf..f71666ea 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -21,7 +21,7 @@ class Avatars(Service): def __init__(self, client) -> None: super(Avatars, self).__init__(client) - def get_browser( + async def get_browser( self, code: Browser, width: Optional[float] = None, @@ -66,7 +66,7 @@ def get_browser( if quality is not None: api_params['quality'] = self._normalize_value(quality) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -78,7 +78,7 @@ def get_browser( return response - def get_credit_card( + async def get_credit_card( self, code: CreditCard, width: Optional[float] = None, @@ -123,7 +123,7 @@ def get_credit_card( if quality is not None: api_params['quality'] = self._normalize_value(quality) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -135,7 +135,7 @@ def get_credit_card( return response - def get_favicon( + async def get_favicon( self, url: str, ) -> bytes: @@ -165,7 +165,7 @@ def get_favicon( raise AppwriteException('Missing required parameter: "url"') api_params['url'] = self._normalize_value(url) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -177,7 +177,7 @@ def get_favicon( return response - def get_flag( + async def get_flag( self, code: Flag, width: Optional[float] = None, @@ -222,7 +222,7 @@ def get_flag( if quality is not None: api_params['quality'] = self._normalize_value(quality) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -234,7 +234,7 @@ def get_flag( return response - def get_image( + async def get_image( self, url: str, width: Optional[float] = None, @@ -276,7 +276,7 @@ def get_image( if height is not None: api_params['height'] = self._normalize_value(height) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -288,7 +288,7 @@ def get_image( return response - def get_initials( + async def get_initials( self, name: Optional[str] = None, width: Optional[float] = None, @@ -334,7 +334,7 @@ def get_initials( if background is not None: api_params['background'] = self._normalize_value(background) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -346,7 +346,7 @@ def get_initials( return response - def get_photo( + async def get_photo( self, width: Optional[float] = None, height: Optional[float] = None, @@ -410,7 +410,7 @@ def get_photo( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -422,7 +422,7 @@ def get_photo( return response - def update_photo( + async def update_photo( self, file: InputFile, on_progress=None, @@ -462,7 +462,7 @@ def update_photo( upload_id = '' - response = self.client.chunked_upload( + response = await self.client.chunked_upload( api_path, { 'X-Appwrite-Project': self.client.get_config('project'), @@ -478,7 +478,7 @@ def update_photo( return Account.with_data(response, model_type) - def delete_photo( + async def delete_photo( self, ) -> Dict[str, Any]: """ @@ -497,7 +497,7 @@ def delete_photo( api_path = '/avatars/photo' api_params = {} - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -510,7 +510,7 @@ def delete_photo( return response - def get_qr( + async def get_qr( self, text: str, size: Optional[float] = None, @@ -553,7 +553,7 @@ def get_qr( if download is not None: api_params['download'] = self._normalize_value(download) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -565,7 +565,7 @@ def get_qr( return response - def get_screenshot( + async def get_screenshot( self, url: str, headers: Optional[Dict[str, Any]] = None, @@ -692,7 +692,7 @@ def get_screenshot( if output is not None: api_params['output'] = self._normalize_value(output) - response = self.client.call( + response = await self.client.call( 'get', api_path, { diff --git a/appwrite/services/backups.py b/appwrite/services/backups.py index b33b009c..19933aea 100644 --- a/appwrite/services/backups.py +++ b/appwrite/services/backups.py @@ -17,7 +17,7 @@ class Backups(Service): def __init__(self, client) -> None: super(Backups, self).__init__(client) - def list_archives( + async def list_archives( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -49,7 +49,7 @@ def list_archives( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -61,7 +61,7 @@ def list_archives( return self._parse_response(response, model=BackupArchiveList) - def create_archive( + async def create_archive( self, services: List[BackupServices], resource_id: Optional[str] = None, @@ -94,7 +94,7 @@ def create_archive( if resource_id is not None: api_params['resourceId'] = self._normalize_value(resource_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -107,7 +107,7 @@ def create_archive( return self._parse_response(response, model=BackupArchive) - def get_archive( + async def get_archive( self, archive_id: str, ) -> BackupArchive: @@ -135,7 +135,7 @@ def get_archive( raise AppwriteException('Missing required parameter: "archive_id"') api_path = api_path.replace('{archiveId}', str(self._normalize_value(archive_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -147,7 +147,7 @@ def get_archive( return self._parse_response(response, model=BackupArchive) - def delete_archive( + async def delete_archive( self, archive_id: str, ) -> Dict[str, Any]: @@ -175,7 +175,7 @@ def delete_archive( raise AppwriteException('Missing required parameter: "archive_id"') api_path = api_path.replace('{archiveId}', str(self._normalize_value(archive_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -188,7 +188,7 @@ def delete_archive( return response - def list_policies( + async def list_policies( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -220,7 +220,7 @@ def list_policies( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -232,7 +232,7 @@ def list_policies( return self._parse_response(response, model=BackupPolicyList) - def create_policy( + async def create_policy( self, policy_id: str, services: List[BackupServices], @@ -293,7 +293,7 @@ def create_policy( api_params['retention'] = self._normalize_value(retention) api_params['schedule'] = self._normalize_value(schedule) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -306,7 +306,7 @@ def create_policy( return self._parse_response(response, model=BackupPolicy) - def get_policy( + async def get_policy( self, policy_id: str, ) -> BackupPolicy: @@ -334,7 +334,7 @@ def get_policy( raise AppwriteException('Missing required parameter: "policy_id"') api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -346,7 +346,7 @@ def get_policy( return self._parse_response(response, model=BackupPolicy) - def update_policy( + async def update_policy( self, policy_id: str, name: Optional[str] = None, @@ -394,7 +394,7 @@ def update_policy( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -407,7 +407,7 @@ def update_policy( return self._parse_response(response, model=BackupPolicy) - def delete_policy( + async def delete_policy( self, policy_id: str, ) -> Dict[str, Any]: @@ -435,7 +435,7 @@ def delete_policy( raise AppwriteException('Missing required parameter: "policy_id"') api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -448,7 +448,7 @@ def delete_policy( return response - def create_restoration( + async def create_restoration( self, archive_id: str, services: List[BackupServices], @@ -500,7 +500,7 @@ def create_restoration( if new_resource_name is not None: api_params['newResourceName'] = self._normalize_value(new_resource_name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -513,7 +513,7 @@ def create_restoration( return self._parse_response(response, model=BackupRestoration) - def list_restorations( + async def list_restorations( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -545,7 +545,7 @@ def list_restorations( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -557,7 +557,7 @@ def list_restorations( return self._parse_response(response, model=BackupRestorationList) - def get_restoration( + async def get_restoration( self, restoration_id: str, ) -> BackupRestoration: @@ -585,7 +585,7 @@ def get_restoration( raise AppwriteException('Missing required parameter: "restoration_id"') api_path = api_path.replace('{restorationId}', str(self._normalize_value(restoration_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 179b6b20..9f8637ae 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -46,7 +46,7 @@ def __init__(self, client) -> None: super(Databases, self).__init__(client) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list` instead.") - def list( + async def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -85,7 +85,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -98,7 +98,7 @@ def list( return self._parse_response(response, model=DatabaseList) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create` instead.") - def create( + async def create( self, database_id: str, name: str, @@ -144,7 +144,7 @@ def create( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -158,7 +158,7 @@ def create( return self._parse_response(response, model=Database) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_transactions` instead.") - def list_transactions( + async def list_transactions( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -192,7 +192,7 @@ def list_transactions( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -205,7 +205,7 @@ def list_transactions( return self._parse_response(response, model=TransactionList) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_transaction` instead.") - def create_transaction( + async def create_transaction( self, ttl: Optional[float] = None, ) -> Transaction: @@ -234,7 +234,7 @@ def create_transaction( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -248,7 +248,7 @@ def create_transaction( return self._parse_response(response, model=Transaction) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_transaction` instead.") - def get_transaction( + async def get_transaction( self, transaction_id: str, ) -> Transaction: @@ -278,7 +278,7 @@ def get_transaction( raise AppwriteException('Missing required parameter: "transaction_id"') api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -291,7 +291,7 @@ def get_transaction( return self._parse_response(response, model=Transaction) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_transaction` instead.") - def update_transaction( + async def update_transaction( self, transaction_id: str, commit: Optional[bool] = None, @@ -331,7 +331,7 @@ def update_transaction( if rollback is not None: api_params['rollback'] = self._normalize_value(rollback) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -345,7 +345,7 @@ def update_transaction( return self._parse_response(response, model=Transaction) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_transaction` instead.") - def delete_transaction( + async def delete_transaction( self, transaction_id: str, ) -> Dict[str, Any]: @@ -375,7 +375,7 @@ def delete_transaction( raise AppwriteException('Missing required parameter: "transaction_id"') api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -389,7 +389,7 @@ def delete_transaction( return response @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_operations` instead.") - def create_operations( + async def create_operations( self, transaction_id: str, operations: Optional[List[Dict[str, Any]]] = None, @@ -424,7 +424,7 @@ def create_operations( if operations is not None: api_params['operations'] = self._normalize_value(operations) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -438,7 +438,7 @@ def create_operations( return self._parse_response(response, model=Transaction) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get` instead.") - def get( + async def get( self, database_id: str, ) -> Database: @@ -468,7 +468,7 @@ def get( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -481,7 +481,7 @@ def get( return self._parse_response(response, model=Database) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update` instead.") - def update( + async def update( self, database_id: str, name: Optional[str] = None, @@ -526,7 +526,7 @@ def update( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -540,7 +540,7 @@ def update( return self._parse_response(response, model=Database) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete` instead.") - def delete( + async def delete( self, database_id: str, ) -> Dict[str, Any]: @@ -570,7 +570,7 @@ def delete( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -584,7 +584,7 @@ def delete( return response @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_tables` instead.") - def list_collections( + async def list_collections( self, database_id: str, queries: Optional[List[str]] = None, @@ -629,7 +629,7 @@ def list_collections( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -642,7 +642,7 @@ def list_collections( return self._parse_response(response, model=CollectionList) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_table` instead.") - def create_collection( + async def create_collection( self, database_id: str, collection_id: str, @@ -714,7 +714,7 @@ def create_collection( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -728,7 +728,7 @@ def create_collection( return self._parse_response(response, model=Collection) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_table` instead.") - def get_collection( + async def get_collection( self, database_id: str, collection_id: str, @@ -764,7 +764,7 @@ def get_collection( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -777,7 +777,7 @@ def get_collection( return self._parse_response(response, model=Collection) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_table` instead.") - def update_collection( + async def update_collection( self, database_id: str, collection_id: str, @@ -843,7 +843,7 @@ def update_collection( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -857,7 +857,7 @@ def update_collection( return self._parse_response(response, model=Collection) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_table` instead.") - def delete_collection( + async def delete_collection( self, database_id: str, collection_id: str, @@ -893,7 +893,7 @@ def delete_collection( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -907,7 +907,7 @@ def delete_collection( return response @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_columns` instead.") - def list_attributes( + async def list_attributes( self, database_id: str, collection_id: str, @@ -953,7 +953,7 @@ def list_attributes( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -966,7 +966,7 @@ def list_attributes( return self._parse_response(response, model=AttributeList) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_big_int_column` instead.") - def create_big_int_attribute( + async def create_big_int_attribute( self, database_id: str, collection_id: str, @@ -1039,7 +1039,7 @@ def create_big_int_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1053,7 +1053,7 @@ def create_big_int_attribute( return self._parse_response(response, model=AttributeBigint) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_big_int_column` instead.") - def update_big_int_attribute( + async def update_big_int_attribute( self, database_id: str, collection_id: str, @@ -1125,7 +1125,7 @@ def update_big_int_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1139,7 +1139,7 @@ def update_big_int_attribute( return self._parse_response(response, model=AttributeBigint) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_boolean_column` instead.") - def create_boolean_attribute( + async def create_boolean_attribute( self, database_id: str, collection_id: str, @@ -1202,7 +1202,7 @@ def create_boolean_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1216,7 +1216,7 @@ def create_boolean_attribute( return self._parse_response(response, model=AttributeBoolean) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_boolean_column` instead.") - def update_boolean_attribute( + async def update_boolean_attribute( self, database_id: str, collection_id: str, @@ -1278,7 +1278,7 @@ def update_boolean_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1292,7 +1292,7 @@ def update_boolean_attribute( return self._parse_response(response, model=AttributeBoolean) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_datetime_column` instead.") - def create_datetime_attribute( + async def create_datetime_attribute( self, database_id: str, collection_id: str, @@ -1355,7 +1355,7 @@ def create_datetime_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1369,7 +1369,7 @@ def create_datetime_attribute( return self._parse_response(response, model=AttributeDatetime) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_datetime_column` instead.") - def update_datetime_attribute( + async def update_datetime_attribute( self, database_id: str, collection_id: str, @@ -1431,7 +1431,7 @@ def update_datetime_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1445,7 +1445,7 @@ def update_datetime_attribute( return self._parse_response(response, model=AttributeDatetime) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_email_column` instead.") - def create_email_attribute( + async def create_email_attribute( self, database_id: str, collection_id: str, @@ -1508,7 +1508,7 @@ def create_email_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1522,7 +1522,7 @@ def create_email_attribute( return self._parse_response(response, model=AttributeEmail) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_email_column` instead.") - def update_email_attribute( + async def update_email_attribute( self, database_id: str, collection_id: str, @@ -1584,7 +1584,7 @@ def update_email_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1598,7 +1598,7 @@ def update_email_attribute( return self._parse_response(response, model=AttributeEmail) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_enum_column` instead.") - def create_enum_attribute( + async def create_enum_attribute( self, database_id: str, collection_id: str, @@ -1667,7 +1667,7 @@ def create_enum_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1681,7 +1681,7 @@ def create_enum_attribute( return self._parse_response(response, model=AttributeEnum) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_enum_column` instead.") - def update_enum_attribute( + async def update_enum_attribute( self, database_id: str, collection_id: str, @@ -1749,7 +1749,7 @@ def update_enum_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1763,7 +1763,7 @@ def update_enum_attribute( return self._parse_response(response, model=AttributeEnum) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_float_column` instead.") - def create_float_attribute( + async def create_float_attribute( self, database_id: str, collection_id: str, @@ -1836,7 +1836,7 @@ def create_float_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1850,7 +1850,7 @@ def create_float_attribute( return self._parse_response(response, model=AttributeFloat) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_float_column` instead.") - def update_float_attribute( + async def update_float_attribute( self, database_id: str, collection_id: str, @@ -1922,7 +1922,7 @@ def update_float_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1936,7 +1936,7 @@ def update_float_attribute( return self._parse_response(response, model=AttributeFloat) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_integer_column` instead.") - def create_integer_attribute( + async def create_integer_attribute( self, database_id: str, collection_id: str, @@ -2009,7 +2009,7 @@ def create_integer_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2023,7 +2023,7 @@ def create_integer_attribute( return self._parse_response(response, model=AttributeInteger) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_integer_column` instead.") - def update_integer_attribute( + async def update_integer_attribute( self, database_id: str, collection_id: str, @@ -2095,7 +2095,7 @@ def update_integer_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2109,7 +2109,7 @@ def update_integer_attribute( return self._parse_response(response, model=AttributeInteger) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_ip_column` instead.") - def create_ip_attribute( + async def create_ip_attribute( self, database_id: str, collection_id: str, @@ -2172,7 +2172,7 @@ def create_ip_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2186,7 +2186,7 @@ def create_ip_attribute( return self._parse_response(response, model=AttributeIp) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_ip_column` instead.") - def update_ip_attribute( + async def update_ip_attribute( self, database_id: str, collection_id: str, @@ -2248,7 +2248,7 @@ def update_ip_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2262,7 +2262,7 @@ def update_ip_attribute( return self._parse_response(response, model=AttributeIp) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_line_column` instead.") - def create_line_attribute( + async def create_line_attribute( self, database_id: str, collection_id: str, @@ -2320,7 +2320,7 @@ def create_line_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2334,7 +2334,7 @@ def create_line_attribute( return self._parse_response(response, model=AttributeLine) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_line_column` instead.") - def update_line_attribute( + async def update_line_attribute( self, database_id: str, collection_id: str, @@ -2397,7 +2397,7 @@ def update_line_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2411,7 +2411,7 @@ def update_line_attribute( return self._parse_response(response, model=AttributeLine) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_longtext_column` instead.") - def create_longtext_attribute( + async def create_longtext_attribute( self, database_id: str, collection_id: str, @@ -2479,7 +2479,7 @@ def create_longtext_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2493,7 +2493,7 @@ def create_longtext_attribute( return self._parse_response(response, model=AttributeLongtext) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_longtext_column` instead.") - def update_longtext_attribute( + async def update_longtext_attribute( self, database_id: str, collection_id: str, @@ -2555,7 +2555,7 @@ def update_longtext_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2569,7 +2569,7 @@ def update_longtext_attribute( return self._parse_response(response, model=AttributeLongtext) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_mediumtext_column` instead.") - def create_mediumtext_attribute( + async def create_mediumtext_attribute( self, database_id: str, collection_id: str, @@ -2637,7 +2637,7 @@ def create_mediumtext_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2651,7 +2651,7 @@ def create_mediumtext_attribute( return self._parse_response(response, model=AttributeMediumtext) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_mediumtext_column` instead.") - def update_mediumtext_attribute( + async def update_mediumtext_attribute( self, database_id: str, collection_id: str, @@ -2713,7 +2713,7 @@ def update_mediumtext_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2727,7 +2727,7 @@ def update_mediumtext_attribute( return self._parse_response(response, model=AttributeMediumtext) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_point_column` instead.") - def create_point_attribute( + async def create_point_attribute( self, database_id: str, collection_id: str, @@ -2785,7 +2785,7 @@ def create_point_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2799,7 +2799,7 @@ def create_point_attribute( return self._parse_response(response, model=AttributePoint) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_point_column` instead.") - def update_point_attribute( + async def update_point_attribute( self, database_id: str, collection_id: str, @@ -2862,7 +2862,7 @@ def update_point_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2876,7 +2876,7 @@ def update_point_attribute( return self._parse_response(response, model=AttributePoint) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_polygon_column` instead.") - def create_polygon_attribute( + async def create_polygon_attribute( self, database_id: str, collection_id: str, @@ -2934,7 +2934,7 @@ def create_polygon_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2948,7 +2948,7 @@ def create_polygon_attribute( return self._parse_response(response, model=AttributePolygon) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_polygon_column` instead.") - def update_polygon_attribute( + async def update_polygon_attribute( self, database_id: str, collection_id: str, @@ -3011,7 +3011,7 @@ def update_polygon_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3025,7 +3025,7 @@ def update_polygon_attribute( return self._parse_response(response, model=AttributePolygon) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_relationship_column` instead.") - def create_relationship_attribute( + async def create_relationship_attribute( self, database_id: str, collection_id: str, @@ -3098,7 +3098,7 @@ def create_relationship_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3112,7 +3112,7 @@ def create_relationship_attribute( return self._parse_response(response, model=AttributeRelationship) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead.") - def update_relationship_attribute( + async def update_relationship_attribute( self, database_id: str, collection_id: str, @@ -3169,7 +3169,7 @@ def update_relationship_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3183,7 +3183,7 @@ def update_relationship_attribute( return self._parse_response(response, model=AttributeRelationship) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_string_column` instead.") - def create_string_attribute( + async def create_string_attribute( self, database_id: str, collection_id: str, @@ -3257,7 +3257,7 @@ def create_string_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3271,7 +3271,7 @@ def create_string_attribute( return self._parse_response(response, model=AttributeString) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_string_column` instead.") - def update_string_attribute( + async def update_string_attribute( self, database_id: str, collection_id: str, @@ -3338,7 +3338,7 @@ def update_string_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3352,7 +3352,7 @@ def update_string_attribute( return self._parse_response(response, model=AttributeString) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_text_column` instead.") - def create_text_attribute( + async def create_text_attribute( self, database_id: str, collection_id: str, @@ -3420,7 +3420,7 @@ def create_text_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3434,7 +3434,7 @@ def create_text_attribute( return self._parse_response(response, model=AttributeText) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_text_column` instead.") - def update_text_attribute( + async def update_text_attribute( self, database_id: str, collection_id: str, @@ -3496,7 +3496,7 @@ def update_text_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3510,7 +3510,7 @@ def update_text_attribute( return self._parse_response(response, model=AttributeText) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_url_column` instead.") - def create_url_attribute( + async def create_url_attribute( self, database_id: str, collection_id: str, @@ -3573,7 +3573,7 @@ def create_url_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3587,7 +3587,7 @@ def create_url_attribute( return self._parse_response(response, model=AttributeUrl) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_url_column` instead.") - def update_url_attribute( + async def update_url_attribute( self, database_id: str, collection_id: str, @@ -3649,7 +3649,7 @@ def update_url_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3663,7 +3663,7 @@ def update_url_attribute( return self._parse_response(response, model=AttributeUrl) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_varchar_column` instead.") - def create_varchar_attribute( + async def create_varchar_attribute( self, database_id: str, collection_id: str, @@ -3737,7 +3737,7 @@ def create_varchar_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3751,7 +3751,7 @@ def create_varchar_attribute( return self._parse_response(response, model=AttributeVarchar) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_varchar_column` instead.") - def update_varchar_attribute( + async def update_varchar_attribute( self, database_id: str, collection_id: str, @@ -3818,7 +3818,7 @@ def update_varchar_attribute( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3832,7 +3832,7 @@ def update_varchar_attribute( return self._parse_response(response, model=AttributeVarchar) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_column` instead.") - def get_attribute( + async def get_attribute( self, database_id: str, collection_id: str, @@ -3893,7 +3893,7 @@ def get_attribute( api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -3962,7 +3962,7 @@ def get_attribute( raise AppwriteException('Unable to match response to any known model') @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_column` instead.") - def delete_attribute( + async def delete_attribute( self, database_id: str, collection_id: str, @@ -4004,7 +4004,7 @@ def delete_attribute( api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -4018,7 +4018,7 @@ def delete_attribute( return response @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_rows` instead.") - def list_documents( + async def list_documents( self, database_id: str, collection_id: str, @@ -4080,7 +4080,7 @@ def list_documents( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -4093,7 +4093,7 @@ def list_documents( return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_row` instead.") - def create_document( + async def create_document( self, database_id: str, collection_id: str, @@ -4155,7 +4155,7 @@ def create_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4169,7 +4169,7 @@ def create_document( return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_rows` instead.") - def create_documents( + async def create_documents( self, database_id: str, collection_id: str, @@ -4220,7 +4220,7 @@ def create_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4234,7 +4234,7 @@ def create_documents( return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.upsert_rows` instead.") - def upsert_documents( + async def upsert_documents( self, database_id: str, collection_id: str, @@ -4285,7 +4285,7 @@ def upsert_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -4299,7 +4299,7 @@ def upsert_documents( return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_rows` instead.") - def update_documents( + async def update_documents( self, database_id: str, collection_id: str, @@ -4354,7 +4354,7 @@ def update_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4368,7 +4368,7 @@ def update_documents( return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_rows` instead.") - def delete_documents( + async def delete_documents( self, database_id: str, collection_id: str, @@ -4418,7 +4418,7 @@ def delete_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -4432,7 +4432,7 @@ def delete_documents( return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_query` instead.") - def create_query( + async def create_query( self, database_id: str, collection_id: str, @@ -4492,7 +4492,7 @@ def create_query( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4506,7 +4506,7 @@ def create_query( return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_row` instead.") - def get_document( + async def get_document( self, database_id: str, collection_id: str, @@ -4562,7 +4562,7 @@ def get_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -4575,7 +4575,7 @@ def get_document( return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.upsert_row` instead.") - def upsert_document( + async def upsert_document( self, database_id: str, collection_id: str, @@ -4636,7 +4636,7 @@ def upsert_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -4650,7 +4650,7 @@ def upsert_document( return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_row` instead.") - def update_document( + async def update_document( self, database_id: str, collection_id: str, @@ -4711,7 +4711,7 @@ def update_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4725,7 +4725,7 @@ def update_document( return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_row` instead.") - def delete_document( + async def delete_document( self, database_id: str, collection_id: str, @@ -4772,7 +4772,7 @@ def delete_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -4786,7 +4786,7 @@ def delete_document( return response @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.decrement_row_column` instead.") - def decrement_document_attribute( + async def decrement_document_attribute( self, database_id: str, collection_id: str, @@ -4853,7 +4853,7 @@ def decrement_document_attribute( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4867,7 +4867,7 @@ def decrement_document_attribute( return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.increment_row_column` instead.") - def increment_document_attribute( + async def increment_document_attribute( self, database_id: str, collection_id: str, @@ -4934,7 +4934,7 @@ def increment_document_attribute( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4948,7 +4948,7 @@ def increment_document_attribute( return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_indexes` instead.") - def list_indexes( + async def list_indexes( self, database_id: str, collection_id: str, @@ -4994,7 +4994,7 @@ def list_indexes( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -5007,7 +5007,7 @@ def list_indexes( return self._parse_response(response, model=IndexList) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_index` instead.") - def create_index( + async def create_index( self, database_id: str, collection_id: str, @@ -5077,7 +5077,7 @@ def create_index( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -5091,7 +5091,7 @@ def create_index( return self._parse_response(response, model=Index) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_index` instead.") - def get_index( + async def get_index( self, database_id: str, collection_id: str, @@ -5133,7 +5133,7 @@ def get_index( api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -5146,7 +5146,7 @@ def get_index( return self._parse_response(response, model=Index) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_index` instead.") - def delete_index( + async def delete_index( self, database_id: str, collection_id: str, @@ -5188,7 +5188,7 @@ def delete_index( api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/documents_db.py b/appwrite/services/documents_db.py index 234f2b66..282628f2 100644 --- a/appwrite/services/documents_db.py +++ b/appwrite/services/documents_db.py @@ -29,7 +29,7 @@ class DocumentsDB(Service): def __init__(self, client) -> None: super(DocumentsDB, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -61,7 +61,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -73,7 +73,7 @@ def list( return self._parse_response(response, model=DatabaseList) - def create( + async def create( self, database_id: str, name: str, @@ -132,7 +132,7 @@ def create( if sync_mode is not None: api_params['syncMode'] = self._normalize_value(sync_mode) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -145,7 +145,7 @@ def create( return self._parse_response(response, model=Database) - def list_specifications( + async def list_specifications( self, ) -> DedicatedDatabaseSpecificationList: """ @@ -164,7 +164,7 @@ def list_specifications( api_path = '/documentsdb/specifications' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -176,7 +176,7 @@ def list_specifications( return self._parse_response(response, model=DedicatedDatabaseSpecificationList) - def list_transactions( + async def list_transactions( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -208,7 +208,7 @@ def list_transactions( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -220,7 +220,7 @@ def list_transactions( return self._parse_response(response, model=TransactionList) - def create_transaction( + async def create_transaction( self, ttl: Optional[float] = None, ) -> Transaction: @@ -247,7 +247,7 @@ def create_transaction( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -260,7 +260,7 @@ def create_transaction( return self._parse_response(response, model=Transaction) - def get_transaction( + async def get_transaction( self, transaction_id: str, ) -> Transaction: @@ -288,7 +288,7 @@ def get_transaction( raise AppwriteException('Missing required parameter: "transaction_id"') api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -300,7 +300,7 @@ def get_transaction( return self._parse_response(response, model=Transaction) - def update_transaction( + async def update_transaction( self, transaction_id: str, commit: Optional[bool] = None, @@ -338,7 +338,7 @@ def update_transaction( if rollback is not None: api_params['rollback'] = self._normalize_value(rollback) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -351,7 +351,7 @@ def update_transaction( return self._parse_response(response, model=Transaction) - def delete_transaction( + async def delete_transaction( self, transaction_id: str, ) -> Dict[str, Any]: @@ -379,7 +379,7 @@ def delete_transaction( raise AppwriteException('Missing required parameter: "transaction_id"') api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -392,7 +392,7 @@ def delete_transaction( return response - def create_operations( + async def create_operations( self, transaction_id: str, operations: Optional[List[Dict[str, Any]]] = None, @@ -425,7 +425,7 @@ def create_operations( if operations is not None: api_params['operations'] = self._normalize_value(operations) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -438,7 +438,7 @@ def create_operations( return self._parse_response(response, model=Transaction) - def get( + async def get( self, database_id: str, ) -> Database: @@ -466,7 +466,7 @@ def get( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -478,7 +478,7 @@ def get( return self._parse_response(response, model=Database) - def update( + async def update( self, database_id: str, name: str, @@ -537,7 +537,7 @@ def update( if sync_mode is not None: api_params['syncMode'] = self._normalize_value(sync_mode) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -550,7 +550,7 @@ def update( return self._parse_response(response, model=Database) - def delete( + async def delete( self, database_id: str, ) -> Dict[str, Any]: @@ -578,7 +578,7 @@ def delete( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -591,7 +591,7 @@ def delete( return response - def list_collections( + async def list_collections( self, database_id: str, queries: Optional[List[str]] = None, @@ -634,7 +634,7 @@ def list_collections( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -646,7 +646,7 @@ def list_collections( return self._parse_response(response, model=CollectionList) - def create_collection( + async def create_collection( self, database_id: str, collection_id: str, @@ -716,7 +716,7 @@ def create_collection( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -729,7 +729,7 @@ def create_collection( return self._parse_response(response, model=Collection) - def get_collection( + async def get_collection( self, database_id: str, collection_id: str, @@ -763,7 +763,7 @@ def get_collection( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -775,7 +775,7 @@ def get_collection( return self._parse_response(response, model=Collection) - def update_collection( + async def update_collection( self, database_id: str, collection_id: str, @@ -840,7 +840,7 @@ def update_collection( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -853,7 +853,7 @@ def update_collection( return self._parse_response(response, model=Collection) - def delete_collection( + async def delete_collection( self, database_id: str, collection_id: str, @@ -887,7 +887,7 @@ def delete_collection( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -900,7 +900,7 @@ def delete_collection( return response - def list_documents( + async def list_documents( self, database_id: str, collection_id: str, @@ -958,7 +958,7 @@ def list_documents( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -970,7 +970,7 @@ def list_documents( return DocumentList.with_data(response, model_type) - def create_document( + async def create_document( self, database_id: str, collection_id: str, @@ -1030,7 +1030,7 @@ def create_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1043,7 +1043,7 @@ def create_document( return Document.with_data(response, model_type) - def create_documents( + async def create_documents( self, database_id: str, collection_id: str, @@ -1092,7 +1092,7 @@ def create_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1105,7 +1105,7 @@ def create_documents( return DocumentList.with_data(response, model_type) - def upsert_documents( + async def upsert_documents( self, database_id: str, collection_id: str, @@ -1154,7 +1154,7 @@ def upsert_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1167,7 +1167,7 @@ def upsert_documents( return DocumentList.with_data(response, model_type) - def update_documents( + async def update_documents( self, database_id: str, collection_id: str, @@ -1220,7 +1220,7 @@ def update_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1233,7 +1233,7 @@ def update_documents( return DocumentList.with_data(response, model_type) - def delete_documents( + async def delete_documents( self, database_id: str, collection_id: str, @@ -1281,7 +1281,7 @@ def delete_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1294,7 +1294,7 @@ def delete_documents( return DocumentList.with_data(response, model_type) - def create_query( + async def create_query( self, database_id: str, collection_id: str, @@ -1352,7 +1352,7 @@ def create_query( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1365,7 +1365,7 @@ def create_query( return DocumentList.with_data(response, model_type) - def get_document( + async def get_document( self, database_id: str, collection_id: str, @@ -1419,7 +1419,7 @@ def get_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1431,7 +1431,7 @@ def get_document( return Document.with_data(response, model_type) - def upsert_document( + async def upsert_document( self, database_id: str, collection_id: str, @@ -1490,7 +1490,7 @@ def upsert_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1503,7 +1503,7 @@ def upsert_document( return Document.with_data(response, model_type) - def update_document( + async def update_document( self, database_id: str, collection_id: str, @@ -1562,7 +1562,7 @@ def update_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1575,7 +1575,7 @@ def update_document( return Document.with_data(response, model_type) - def delete_document( + async def delete_document( self, database_id: str, collection_id: str, @@ -1620,7 +1620,7 @@ def delete_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1633,7 +1633,7 @@ def delete_document( return response - def decrement_document_attribute( + async def decrement_document_attribute( self, database_id: str, collection_id: str, @@ -1698,7 +1698,7 @@ def decrement_document_attribute( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1711,7 +1711,7 @@ def decrement_document_attribute( return Document.with_data(response, model_type) - def increment_document_attribute( + async def increment_document_attribute( self, database_id: str, collection_id: str, @@ -1776,7 +1776,7 @@ def increment_document_attribute( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1789,7 +1789,7 @@ def increment_document_attribute( return Document.with_data(response, model_type) - def list_indexes( + async def list_indexes( self, database_id: str, collection_id: str, @@ -1833,7 +1833,7 @@ def list_indexes( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1845,7 +1845,7 @@ def list_indexes( return self._parse_response(response, model=IndexList) - def create_index( + async def create_index( self, database_id: str, collection_id: str, @@ -1913,7 +1913,7 @@ def create_index( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1926,7 +1926,7 @@ def create_index( return self._parse_response(response, model=Index) - def get_index( + async def get_index( self, database_id: str, collection_id: str, @@ -1966,7 +1966,7 @@ def get_index( api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1978,7 +1978,7 @@ def get_index( return self._parse_response(response, model=Index) - def delete_index( + async def delete_index( self, database_id: str, collection_id: str, @@ -2018,7 +2018,7 @@ def delete_index( api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -2031,7 +2031,7 @@ def delete_index( return response - def create_failover( + async def create_failover( self, database_id: str, target_replica_id: Optional[str] = None, @@ -2064,7 +2064,7 @@ def create_failover( if target_replica_id is not None: api_params['targetReplicaId'] = self._normalize_value(target_replica_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2077,7 +2077,7 @@ def create_failover( return self._parse_response(response, model=DedicatedDatabase) - def list_operations( + async def list_operations( self, database_id: str, status: Optional[str] = None, @@ -2120,7 +2120,7 @@ def list_operations( if offset is not None: api_params['offset'] = self._normalize_value(offset) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2132,7 +2132,7 @@ def list_operations( return self._parse_response(response, model=DedicatedDatabaseOperationList) - def get_replicas( + async def get_replicas( self, database_id: str, ) -> DedicatedDatabaseReplicas: @@ -2160,7 +2160,7 @@ def get_replicas( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2172,7 +2172,7 @@ def get_replicas( return self._parse_response(response, model=DedicatedDatabaseReplicas) - def get_status( + async def get_status( self, database_id: str, ) -> DatabaseStatus: @@ -2200,7 +2200,7 @@ def get_status( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { diff --git a/appwrite/services/domains.py b/appwrite/services/domains.py index bce1dc23..6973c912 100644 --- a/appwrite/services/domains.py +++ b/appwrite/services/domains.py @@ -18,7 +18,7 @@ class Domains(Service): def __init__(self, client) -> None: super(Domains, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -55,7 +55,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -67,7 +67,7 @@ def list( return self._parse_response(response, model=DomainsList) - def create( + async def create( self, team_id: str, domain: str, @@ -101,7 +101,7 @@ def create( api_params['teamId'] = self._normalize_value(team_id) api_params['domain'] = self._normalize_value(domain) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -115,7 +115,7 @@ def create( return self._parse_response(response, model=Domain) @deprecated("This API has been deprecated since 2.0.0. Please use `domains.list_prices` instead.") - def get_price( + async def get_price( self, domain: str, period_years: Optional[float] = None, @@ -155,7 +155,7 @@ def get_price( if registration_type is not None: api_params['registrationType'] = self._normalize_value(registration_type) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -167,7 +167,7 @@ def get_price( return self._parse_response(response, model=DomainPrice) - def list_prices( + async def list_prices( self, domains: List[str], period_years: Optional[float] = None, @@ -205,7 +205,7 @@ def list_prices( if registration_type is not None: api_params['registrationType'] = self._normalize_value(registration_type) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -217,7 +217,7 @@ def list_prices( return self._parse_response(response, model=DomainPricesList) - def get( + async def get( self, domain_id: str, ) -> Domain: @@ -245,7 +245,7 @@ def get( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -257,7 +257,7 @@ def get( return self._parse_response(response, model=Domain) - def delete( + async def delete( self, domain_id: str, ) -> Dict[str, Any]: @@ -286,7 +286,7 @@ def delete( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -299,7 +299,7 @@ def delete( return response - def update_nameservers( + async def update_nameservers( self, domain_id: str, nameservers: Optional[List[str]] = None, @@ -333,7 +333,7 @@ def update_nameservers( if nameservers is not None: api_params['nameservers'] = self._normalize_value(nameservers) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -346,7 +346,7 @@ def update_nameservers( return self._parse_response(response, model=Domain) - def verify_nameservers( + async def verify_nameservers( self, domain_id: str, ) -> Domain: @@ -376,7 +376,7 @@ def verify_nameservers( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -389,7 +389,7 @@ def verify_nameservers( return self._parse_response(response, model=Domain) - def get_preset_google_workspace( + async def get_preset_google_workspace( self, domain_id: str, ) -> DnsRecordsList: @@ -417,7 +417,7 @@ def get_preset_google_workspace( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -429,7 +429,7 @@ def get_preset_google_workspace( return self._parse_response(response, model=DnsRecordsList) - def create_preset_google_workspace( + async def create_preset_google_workspace( self, domain_id: str, ) -> DnsRecordsList: @@ -458,7 +458,7 @@ def create_preset_google_workspace( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -471,7 +471,7 @@ def create_preset_google_workspace( return self._parse_response(response, model=DnsRecordsList) - def get_preset_i_cloud( + async def get_preset_i_cloud( self, domain_id: str, ) -> DnsRecordsList: @@ -499,7 +499,7 @@ def get_preset_i_cloud( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -511,7 +511,7 @@ def get_preset_i_cloud( return self._parse_response(response, model=DnsRecordsList) - def create_preset_i_cloud( + async def create_preset_i_cloud( self, domain_id: str, ) -> DnsRecordsList: @@ -540,7 +540,7 @@ def create_preset_i_cloud( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -553,7 +553,7 @@ def create_preset_i_cloud( return self._parse_response(response, model=DnsRecordsList) - def get_preset_mailgun( + async def get_preset_mailgun( self, domain_id: str, ) -> DnsRecordsList: @@ -581,7 +581,7 @@ def get_preset_mailgun( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -593,7 +593,7 @@ def get_preset_mailgun( return self._parse_response(response, model=DnsRecordsList) - def create_preset_mailgun( + async def create_preset_mailgun( self, domain_id: str, ) -> DnsRecordsList: @@ -622,7 +622,7 @@ def create_preset_mailgun( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -635,7 +635,7 @@ def create_preset_mailgun( return self._parse_response(response, model=DnsRecordsList) - def get_preset_outlook( + async def get_preset_outlook( self, domain_id: str, ) -> DnsRecordsList: @@ -663,7 +663,7 @@ def get_preset_outlook( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -675,7 +675,7 @@ def get_preset_outlook( return self._parse_response(response, model=DnsRecordsList) - def create_preset_outlook( + async def create_preset_outlook( self, domain_id: str, ) -> DnsRecordsList: @@ -704,7 +704,7 @@ def create_preset_outlook( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -717,7 +717,7 @@ def create_preset_outlook( return self._parse_response(response, model=DnsRecordsList) - def get_preset_proton_mail( + async def get_preset_proton_mail( self, domain_id: str, ) -> DnsRecordsList: @@ -745,7 +745,7 @@ def get_preset_proton_mail( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -757,7 +757,7 @@ def get_preset_proton_mail( return self._parse_response(response, model=DnsRecordsList) - def create_preset_proton_mail( + async def create_preset_proton_mail( self, domain_id: str, ) -> DnsRecordsList: @@ -786,7 +786,7 @@ def create_preset_proton_mail( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -799,7 +799,7 @@ def create_preset_proton_mail( return self._parse_response(response, model=DnsRecordsList) - def get_preset_zoho( + async def get_preset_zoho( self, domain_id: str, ) -> DnsRecordsList: @@ -827,7 +827,7 @@ def get_preset_zoho( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -839,7 +839,7 @@ def get_preset_zoho( return self._parse_response(response, model=DnsRecordsList) - def create_preset_zoho( + async def create_preset_zoho( self, domain_id: str, ) -> DnsRecordsList: @@ -868,7 +868,7 @@ def create_preset_zoho( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -881,7 +881,7 @@ def create_preset_zoho( return self._parse_response(response, model=DnsRecordsList) - def list_records( + async def list_records( self, domain_id: str, queries: Optional[List[str]] = None, @@ -920,7 +920,7 @@ def list_records( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -932,7 +932,7 @@ def list_records( return self._parse_response(response, model=DnsRecordsList) - def create_record_a( + async def create_record_a( self, domain_id: str, name: str, @@ -984,7 +984,7 @@ def create_record_a( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -997,7 +997,7 @@ def create_record_a( return self._parse_response(response, model=DnsRecord) - def update_record_a( + async def update_record_a( self, domain_id: str, record_id: str, @@ -1056,7 +1056,7 @@ def update_record_a( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1069,7 +1069,7 @@ def update_record_a( return self._parse_response(response, model=DnsRecord) - def create_record_aaaa( + async def create_record_aaaa( self, domain_id: str, name: str, @@ -1121,7 +1121,7 @@ def create_record_aaaa( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1134,7 +1134,7 @@ def create_record_aaaa( return self._parse_response(response, model=DnsRecord) - def update_record_aaaa( + async def update_record_aaaa( self, domain_id: str, record_id: str, @@ -1193,7 +1193,7 @@ def update_record_aaaa( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1206,7 +1206,7 @@ def update_record_aaaa( return self._parse_response(response, model=DnsRecord) - def create_record_alias( + async def create_record_alias( self, domain_id: str, name: str, @@ -1259,7 +1259,7 @@ def create_record_alias( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1272,7 +1272,7 @@ def create_record_alias( return self._parse_response(response, model=DnsRecord) - def update_record_alias( + async def update_record_alias( self, domain_id: str, record_id: str, @@ -1333,7 +1333,7 @@ def update_record_alias( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1346,7 +1346,7 @@ def update_record_alias( return self._parse_response(response, model=DnsRecord) - def create_record_caa( + async def create_record_caa( self, domain_id: str, name: str, @@ -1398,7 +1398,7 @@ def create_record_caa( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1411,7 +1411,7 @@ def create_record_caa( return self._parse_response(response, model=DnsRecord) - def update_record_caa( + async def update_record_caa( self, domain_id: str, record_id: str, @@ -1470,7 +1470,7 @@ def update_record_caa( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1483,7 +1483,7 @@ def update_record_caa( return self._parse_response(response, model=DnsRecord) - def create_record_cname( + async def create_record_cname( self, domain_id: str, name: str, @@ -1538,7 +1538,7 @@ def create_record_cname( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1551,7 +1551,7 @@ def create_record_cname( return self._parse_response(response, model=DnsRecord) - def update_record_cname( + async def update_record_cname( self, domain_id: str, record_id: str, @@ -1608,7 +1608,7 @@ def update_record_cname( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1621,7 +1621,7 @@ def update_record_cname( return self._parse_response(response, model=DnsRecord) - def create_record_https( + async def create_record_https( self, domain_id: str, name: str, @@ -1673,7 +1673,7 @@ def create_record_https( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1686,7 +1686,7 @@ def create_record_https( return self._parse_response(response, model=DnsRecord) - def update_record_https( + async def update_record_https( self, domain_id: str, record_id: str, @@ -1745,7 +1745,7 @@ def update_record_https( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1758,7 +1758,7 @@ def update_record_https( return self._parse_response(response, model=DnsRecord) - def create_record_mx( + async def create_record_mx( self, domain_id: str, name: str, @@ -1818,7 +1818,7 @@ def create_record_mx( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1831,7 +1831,7 @@ def create_record_mx( return self._parse_response(response, model=DnsRecord) - def update_record_mx( + async def update_record_mx( self, domain_id: str, record_id: str, @@ -1894,7 +1894,7 @@ def update_record_mx( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1907,7 +1907,7 @@ def update_record_mx( return self._parse_response(response, model=DnsRecord) - def create_record_ns( + async def create_record_ns( self, domain_id: str, name: str, @@ -1959,7 +1959,7 @@ def create_record_ns( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1972,7 +1972,7 @@ def create_record_ns( return self._parse_response(response, model=DnsRecord) - def update_record_ns( + async def update_record_ns( self, domain_id: str, record_id: str, @@ -2032,7 +2032,7 @@ def update_record_ns( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -2045,7 +2045,7 @@ def update_record_ns( return self._parse_response(response, model=DnsRecord) - def create_record_srv( + async def create_record_srv( self, domain_id: str, name: str, @@ -2116,7 +2116,7 @@ def create_record_srv( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2129,7 +2129,7 @@ def create_record_srv( return self._parse_response(response, model=DnsRecord) - def update_record_srv( + async def update_record_srv( self, domain_id: str, record_id: str, @@ -2217,7 +2217,7 @@ def update_record_srv( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -2230,7 +2230,7 @@ def update_record_srv( return self._parse_response(response, model=DnsRecord) - def create_record_txt( + async def create_record_txt( self, domain_id: str, name: str, @@ -2282,7 +2282,7 @@ def create_record_txt( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2295,7 +2295,7 @@ def create_record_txt( return self._parse_response(response, model=DnsRecord) - def update_record_txt( + async def update_record_txt( self, domain_id: str, record_id: str, @@ -2355,7 +2355,7 @@ def update_record_txt( if comment is not None: api_params['comment'] = self._normalize_value(comment) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -2368,7 +2368,7 @@ def update_record_txt( return self._parse_response(response, model=DnsRecord) - def get_record( + async def get_record( self, domain_id: str, record_id: str, @@ -2406,7 +2406,7 @@ def get_record( api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) api_path = api_path.replace('{recordId}', str(self._normalize_value(record_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2418,7 +2418,7 @@ def get_record( return self._parse_response(response, model=DnsRecord) - def delete_record( + async def delete_record( self, domain_id: str, record_id: str, @@ -2453,7 +2453,7 @@ def delete_record( api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) api_path = api_path.replace('{recordId}', str(self._normalize_value(record_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -2466,7 +2466,7 @@ def delete_record( return response - def update_team( + async def update_team( self, domain_id: str, team_id: str, @@ -2504,7 +2504,7 @@ def update_team( api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) api_params['teamId'] = self._normalize_value(team_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2517,7 +2517,7 @@ def update_team( return self._parse_response(response, model=Domain) - def get_transfer_status( + async def get_transfer_status( self, domain_id: str, ) -> DomainTransferStatus: @@ -2545,7 +2545,7 @@ def get_transfer_status( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2557,7 +2557,7 @@ def get_transfer_status( return self._parse_response(response, model=DomainTransferStatus) - def get_zone( + async def get_zone( self, domain_id: str, ) -> str: @@ -2586,7 +2586,7 @@ def get_zone( raise AppwriteException('Missing required parameter: "domain_id"') api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2599,7 +2599,7 @@ def get_zone( return response - def update_zone( + async def update_zone( self, domain_id: str, content: str, @@ -2634,7 +2634,7 @@ def update_zone( api_path = api_path.replace('{domainId}', str(self._normalize_value(domain_id))) api_params['content'] = self._normalize_value(content) - response = self.client.call( + response = await self.client.call( 'put', api_path, { diff --git a/appwrite/services/embeddings.py b/appwrite/services/embeddings.py index 4068b552..0bd09328 100644 --- a/appwrite/services/embeddings.py +++ b/appwrite/services/embeddings.py @@ -12,7 +12,7 @@ class Embeddings(Service): def __init__(self, client) -> None: super(Embeddings, self).__init__(client) - def create_text_embeddings( + async def create_text_embeddings( self, texts: List[str], model: Optional[EmbeddingModel] = None, @@ -45,7 +45,7 @@ def create_text_embeddings( if model is not None: api_params['model'] = self._normalize_value(model) - response = self.client.call( + response = await self.client.call( 'post', api_path, { diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index fa109998..43e6f35d 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -27,7 +27,7 @@ class Functions(Service): def __init__(self, client) -> None: super(Functions, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -64,7 +64,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -76,7 +76,7 @@ def list( return self._parse_response(response, model=FunctionList) - def create( + async def create( self, function_id: str, name: str, @@ -221,7 +221,7 @@ def create( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -234,7 +234,7 @@ def create( return self._parse_response(response, model=Function) - def list_runtimes( + async def list_runtimes( self, total: Optional[bool] = None, ) -> RuntimeList: @@ -261,7 +261,7 @@ def list_runtimes( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -273,7 +273,7 @@ def list_runtimes( return self._parse_response(response, model=RuntimeList) - def list_specifications( + async def list_specifications( self, type: Optional[str] = None, total: Optional[bool] = None, @@ -305,7 +305,7 @@ def list_specifications( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -317,7 +317,7 @@ def list_specifications( return self._parse_response(response, model=SpecificationList) - def get( + async def get( self, function_id: str, ) -> Function: @@ -345,7 +345,7 @@ def get( raise AppwriteException('Missing required parameter: "function_id"') api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -357,7 +357,7 @@ def get( return self._parse_response(response, model=Function) - def update( + async def update( self, function_id: str, name: str, @@ -506,7 +506,7 @@ def update( if email_enabled is not None: api_params['emailEnabled'] = self._normalize_value(email_enabled) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -519,7 +519,7 @@ def update( return self._parse_response(response, model=Function) - def delete( + async def delete( self, function_id: str, ) -> Dict[str, Any]: @@ -547,7 +547,7 @@ def delete( raise AppwriteException('Missing required parameter: "function_id"') api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -560,7 +560,7 @@ def delete( return response - def update_function_deployment( + async def update_function_deployment( self, function_id: str, deployment_id: str, @@ -594,7 +594,7 @@ def update_function_deployment( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) api_params['deploymentId'] = self._normalize_value(deployment_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -607,7 +607,7 @@ def update_function_deployment( return self._parse_response(response, model=Function) - def list_deployments( + async def list_deployments( self, function_id: str, queries: Optional[List[str]] = None, @@ -650,7 +650,7 @@ def list_deployments( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -662,7 +662,7 @@ def list_deployments( return self._parse_response(response, model=DeploymentList) - def create_deployment( + async def create_deployment( self, function_id: str, code: InputFile, @@ -724,7 +724,7 @@ def create_deployment( upload_id = '' - response = self.client.chunked_upload( + response = await self.client.chunked_upload( api_path, { 'X-Appwrite-Project': self.client.get_config('project'), @@ -740,7 +740,7 @@ def create_deployment( return self._parse_response(response, model=Deployment) - def create_duplicate_deployment( + async def create_duplicate_deployment( self, function_id: str, deployment_id: str, @@ -779,7 +779,7 @@ def create_duplicate_deployment( if build_id is not None: api_params['buildId'] = self._normalize_value(build_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -792,7 +792,7 @@ def create_duplicate_deployment( return self._parse_response(response, model=Deployment) - def create_template_deployment( + async def create_template_deployment( self, function_id: str, repository: str, @@ -857,7 +857,7 @@ def create_template_deployment( if activate is not None: api_params['activate'] = self._normalize_value(activate) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -870,7 +870,7 @@ def create_template_deployment( return self._parse_response(response, model=Deployment) - def create_vcs_deployment( + async def create_vcs_deployment( self, function_id: str, type: VCSReferenceType, @@ -917,7 +917,7 @@ def create_vcs_deployment( if activate is not None: api_params['activate'] = self._normalize_value(activate) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -930,7 +930,7 @@ def create_vcs_deployment( return self._parse_response(response, model=Deployment) - def get_deployment( + async def get_deployment( self, function_id: str, deployment_id: str, @@ -964,7 +964,7 @@ def get_deployment( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -976,7 +976,7 @@ def get_deployment( return self._parse_response(response, model=Deployment) - def delete_deployment( + async def delete_deployment( self, function_id: str, deployment_id: str, @@ -1010,7 +1010,7 @@ def delete_deployment( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1023,7 +1023,7 @@ def delete_deployment( return response - def get_deployment_download( + async def get_deployment_download( self, function_id: str, deployment_id: str, @@ -1067,7 +1067,7 @@ def get_deployment_download( if token is not None: api_params['token'] = self._normalize_value(token) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1079,7 +1079,7 @@ def get_deployment_download( return response - def update_deployment_status( + async def update_deployment_status( self, function_id: str, deployment_id: str, @@ -1113,7 +1113,7 @@ def update_deployment_status( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1126,7 +1126,7 @@ def update_deployment_status( return self._parse_response(response, model=Deployment) - def list_executions( + async def list_executions( self, function_id: str, queries: Optional[List[str]] = None, @@ -1164,7 +1164,7 @@ def list_executions( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1176,7 +1176,7 @@ def list_executions( return self._parse_response(response, model=ExecutionList) - def create_execution( + async def create_execution( self, function_id: str, body: Optional[str] = None, @@ -1234,7 +1234,7 @@ def create_execution( if scheduled_at is not None: api_params['scheduledAt'] = self._normalize_value(scheduled_at) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1247,7 +1247,7 @@ def create_execution( return self._parse_response(response, model=Execution) - def get_execution( + async def get_execution( self, function_id: str, execution_id: str, @@ -1281,7 +1281,7 @@ def get_execution( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) api_path = api_path.replace('{executionId}', str(self._normalize_value(execution_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1293,7 +1293,7 @@ def get_execution( return self._parse_response(response, model=Execution) - def delete_execution( + async def delete_execution( self, function_id: str, execution_id: str, @@ -1327,7 +1327,7 @@ def delete_execution( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) api_path = api_path.replace('{executionId}', str(self._normalize_value(execution_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1340,7 +1340,7 @@ def delete_execution( return response - def list_variables( + async def list_variables( self, function_id: str, queries: Optional[List[str]] = None, @@ -1378,7 +1378,7 @@ def list_variables( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1390,7 +1390,7 @@ def list_variables( return self._parse_response(response, model=VariableList) - def create_variable( + async def create_variable( self, function_id: str, variable_id: str, @@ -1446,7 +1446,7 @@ def create_variable( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1459,7 +1459,7 @@ def create_variable( return self._parse_response(response, model=Variable) - def get_variable( + async def get_variable( self, function_id: str, variable_id: str, @@ -1493,7 +1493,7 @@ def get_variable( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1505,7 +1505,7 @@ def get_variable( return self._parse_response(response, model=Variable) - def update_variable( + async def update_variable( self, function_id: str, variable_id: str, @@ -1559,7 +1559,7 @@ def update_variable( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1572,7 +1572,7 @@ def update_variable( return self._parse_response(response, model=Variable) - def delete_variable( + async def delete_variable( self, function_id: str, variable_id: str, @@ -1606,7 +1606,7 @@ def delete_variable( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/graphql.py b/appwrite/services/graphql.py index ed8661b2..f1919774 100644 --- a/appwrite/services/graphql.py +++ b/appwrite/services/graphql.py @@ -10,7 +10,7 @@ class Graphql(Service): def __init__(self, client) -> None: super(Graphql, self).__init__(client) - def query( + async def query( self, query: Dict[str, Any], ) -> Dict[str, Any]: @@ -38,7 +38,7 @@ def query( raise AppwriteException('Missing required parameter: "query"') api_params['query'] = self._normalize_value(query) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -52,7 +52,7 @@ def query( return response - def mutation( + async def mutation( self, query: Dict[str, Any], ) -> Dict[str, Any]: @@ -80,7 +80,7 @@ def mutation( raise AppwriteException('Missing required parameter: "query"') api_params['query'] = self._normalize_value(query) - response = self.client.call( + response = await self.client.call( 'post', api_path, { diff --git a/appwrite/services/locale.py b/appwrite/services/locale.py index e0e69e70..3a242350 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -17,7 +17,7 @@ class Locale(Service): def __init__(self, client) -> None: super(Locale, self).__init__(client) - def get( + async def get( self, ) -> LocaleModel: """ @@ -38,7 +38,7 @@ def get( api_path = '/locale' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -50,7 +50,7 @@ def get( return self._parse_response(response, model=LocaleModel) - def list_codes( + async def list_codes( self, total: Optional[bool] = None, ) -> LocaleCodeList: @@ -77,7 +77,7 @@ def list_codes( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -89,7 +89,7 @@ def list_codes( return self._parse_response(response, model=LocaleCodeList) - def list_continents( + async def list_continents( self, total: Optional[bool] = None, ) -> ContinentList: @@ -116,7 +116,7 @@ def list_continents( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -128,7 +128,7 @@ def list_continents( return self._parse_response(response, model=ContinentList) - def list_countries( + async def list_countries( self, total: Optional[bool] = None, ) -> CountryList: @@ -155,7 +155,7 @@ def list_countries( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -167,7 +167,7 @@ def list_countries( return self._parse_response(response, model=CountryList) - def list_countries_eu( + async def list_countries_eu( self, total: Optional[bool] = None, ) -> CountryList: @@ -194,7 +194,7 @@ def list_countries_eu( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -206,7 +206,7 @@ def list_countries_eu( return self._parse_response(response, model=CountryList) - def list_countries_phones( + async def list_countries_phones( self, total: Optional[bool] = None, ) -> PhoneList: @@ -233,7 +233,7 @@ def list_countries_phones( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -245,7 +245,7 @@ def list_countries_phones( return self._parse_response(response, model=PhoneList) - def list_currencies( + async def list_currencies( self, total: Optional[bool] = None, ) -> CurrencyList: @@ -272,7 +272,7 @@ def list_currencies( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -284,7 +284,7 @@ def list_currencies( return self._parse_response(response, model=CurrencyList) - def list_languages( + async def list_languages( self, total: Optional[bool] = None, ) -> LanguageList: @@ -311,7 +311,7 @@ def list_languages( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { diff --git a/appwrite/services/messaging.py b/appwrite/services/messaging.py index df5083f7..1845351e 100644 --- a/appwrite/services/messaging.py +++ b/appwrite/services/messaging.py @@ -21,7 +21,7 @@ class Messaging(Service): def __init__(self, client) -> None: super(Messaging, self).__init__(client) - def list_messages( + async def list_messages( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -58,7 +58,7 @@ def list_messages( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -70,7 +70,7 @@ def list_messages( return self._parse_response(response, model=MessageList) - def create_email( + async def create_email( self, message_id: str, subject: str, @@ -170,7 +170,7 @@ def create_email( if emails is not None: api_params['emails'] = self._normalize_value(emails) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -183,7 +183,7 @@ def create_email( return self._parse_response(response, model=Message) - def update_email( + async def update_email( self, message_id: str, topics: Optional[List[str]] = None, @@ -281,7 +281,7 @@ def update_email( if emails is not None: api_params['emails'] = self._normalize_value(emails) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -294,7 +294,7 @@ def update_email( return self._parse_response(response, model=Message) - def create_push( + async def create_push( self, message_id: str, title: Optional[str] = None, @@ -417,7 +417,7 @@ def create_push( if channel_id is not None: api_params['channelId'] = self._normalize_value(channel_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -430,7 +430,7 @@ def create_push( return self._parse_response(response, model=Message) - def update_push( + async def update_push( self, message_id: str, topics: Optional[List[str]] = None, @@ -553,7 +553,7 @@ def update_push( if channel_id is not None: api_params['channelId'] = self._normalize_value(channel_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -566,7 +566,7 @@ def update_push( return self._parse_response(response, model=Message) - def create_sms( + async def create_sms( self, message_id: str, content: str, @@ -625,7 +625,7 @@ def create_sms( if scheduled_at is not None: api_params['scheduledAt'] = self._normalize_value(scheduled_at) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -638,7 +638,7 @@ def create_sms( return self._parse_response(response, model=Message) - def update_sms( + async def update_sms( self, message_id: str, topics: Optional[List[str]] = None, @@ -696,7 +696,7 @@ def update_sms( if scheduled_at is not None: api_params['scheduledAt'] = self._normalize_value(scheduled_at) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -709,7 +709,7 @@ def update_sms( return self._parse_response(response, model=Message) - def get_message( + async def get_message( self, message_id: str, ) -> Message: @@ -737,7 +737,7 @@ def get_message( raise AppwriteException('Missing required parameter: "message_id"') api_path = api_path.replace('{messageId}', str(self._normalize_value(message_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -749,7 +749,7 @@ def get_message( return self._parse_response(response, model=Message) - def delete( + async def delete( self, message_id: str, ) -> Dict[str, Any]: @@ -777,7 +777,7 @@ def delete( raise AppwriteException('Missing required parameter: "message_id"') api_path = api_path.replace('{messageId}', str(self._normalize_value(message_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -790,7 +790,7 @@ def delete( return response - def list_targets( + async def list_targets( self, message_id: str, queries: Optional[List[str]] = None, @@ -828,7 +828,7 @@ def list_targets( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -840,7 +840,7 @@ def list_targets( return self._parse_response(response, model=TargetList) - def list_providers( + async def list_providers( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -877,7 +877,7 @@ def list_providers( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -889,7 +889,7 @@ def list_providers( return self._parse_response(response, model=ProviderList) - def create_apns_provider( + async def create_apns_provider( self, provider_id: str, name: str, @@ -953,7 +953,7 @@ def create_apns_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -966,7 +966,7 @@ def create_apns_provider( return self._parse_response(response, model=Provider) - def update_apns_provider( + async def update_apns_provider( self, provider_id: str, name: Optional[str] = None, @@ -1029,7 +1029,7 @@ def update_apns_provider( if sandbox is not None: api_params['sandbox'] = self._normalize_value(sandbox) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1042,7 +1042,7 @@ def update_apns_provider( return self._parse_response(response, model=Provider) - def create_appwrite_provider( + async def create_appwrite_provider( self, provider_id: str, name: str, @@ -1091,7 +1091,7 @@ def create_appwrite_provider( if expiry is not None: api_params['expiry'] = self._normalize_value(expiry) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1104,7 +1104,7 @@ def create_appwrite_provider( return self._parse_response(response, model=Provider) - def update_appwrite_provider( + async def update_appwrite_provider( self, provider_id: str, name: Optional[str] = None, @@ -1152,7 +1152,7 @@ def update_appwrite_provider( if expiry is not None: api_params['expiry'] = self._normalize_value(expiry) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1165,7 +1165,7 @@ def update_appwrite_provider( return self._parse_response(response, model=Provider) - def create_fcm_provider( + async def create_fcm_provider( self, provider_id: str, name: str, @@ -1209,7 +1209,7 @@ def create_fcm_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1222,7 +1222,7 @@ def create_fcm_provider( return self._parse_response(response, model=Provider) - def update_fcm_provider( + async def update_fcm_provider( self, provider_id: str, name: Optional[str] = None, @@ -1265,7 +1265,7 @@ def update_fcm_provider( if service_account_json is not None: api_params['serviceAccountJSON'] = self._normalize_value(service_account_json) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1278,7 +1278,7 @@ def update_fcm_provider( return self._parse_response(response, model=Provider) - def create_mailgun_provider( + async def create_mailgun_provider( self, provider_id: str, name: str, @@ -1352,7 +1352,7 @@ def create_mailgun_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1365,7 +1365,7 @@ def create_mailgun_provider( return self._parse_response(response, model=Provider) - def update_mailgun_provider( + async def update_mailgun_provider( self, provider_id: str, name: Optional[str] = None, @@ -1438,7 +1438,7 @@ def update_mailgun_provider( if reply_to_email is not None: api_params['replyToEmail'] = self._normalize_value(reply_to_email) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1451,7 +1451,7 @@ def update_mailgun_provider( return self._parse_response(response, model=Provider) - def create_msg91_provider( + async def create_msg91_provider( self, provider_id: str, name: str, @@ -1505,7 +1505,7 @@ def create_msg91_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1518,7 +1518,7 @@ def create_msg91_provider( return self._parse_response(response, model=Provider) - def update_msg91_provider( + async def update_msg91_provider( self, provider_id: str, name: Optional[str] = None, @@ -1571,7 +1571,7 @@ def update_msg91_provider( if auth_key is not None: api_params['authKey'] = self._normalize_value(auth_key) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1584,7 +1584,7 @@ def update_msg91_provider( return self._parse_response(response, model=Provider) - def create_resend_provider( + async def create_resend_provider( self, provider_id: str, name: str, @@ -1648,7 +1648,7 @@ def create_resend_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1661,7 +1661,7 @@ def create_resend_provider( return self._parse_response(response, model=Provider) - def update_resend_provider( + async def update_resend_provider( self, provider_id: str, name: Optional[str] = None, @@ -1724,7 +1724,7 @@ def update_resend_provider( if reply_to_email is not None: api_params['replyToEmail'] = self._normalize_value(reply_to_email) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1737,7 +1737,7 @@ def update_resend_provider( return self._parse_response(response, model=Provider) - def create_sendgrid_provider( + async def create_sendgrid_provider( self, provider_id: str, name: str, @@ -1801,7 +1801,7 @@ def create_sendgrid_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1814,7 +1814,7 @@ def create_sendgrid_provider( return self._parse_response(response, model=Provider) - def update_sendgrid_provider( + async def update_sendgrid_provider( self, provider_id: str, name: Optional[str] = None, @@ -1877,7 +1877,7 @@ def update_sendgrid_provider( if reply_to_email is not None: api_params['replyToEmail'] = self._normalize_value(reply_to_email) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1890,7 +1890,7 @@ def update_sendgrid_provider( return self._parse_response(response, model=Provider) - def create_ses_provider( + async def create_ses_provider( self, provider_id: str, name: str, @@ -1964,7 +1964,7 @@ def create_ses_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1977,7 +1977,7 @@ def create_ses_provider( return self._parse_response(response, model=Provider) - def update_ses_provider( + async def update_ses_provider( self, provider_id: str, name: Optional[str] = None, @@ -2050,7 +2050,7 @@ def update_ses_provider( if reply_to_email is not None: api_params['replyToEmail'] = self._normalize_value(reply_to_email) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2063,7 +2063,7 @@ def update_ses_provider( return self._parse_response(response, model=Provider) - def create_smtp_provider( + async def create_smtp_provider( self, provider_id: str, name: str, @@ -2158,7 +2158,7 @@ def create_smtp_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2171,7 +2171,7 @@ def create_smtp_provider( return self._parse_response(response, model=Provider) - def update_smtp_provider( + async def update_smtp_provider( self, provider_id: str, name: Optional[str] = None, @@ -2264,7 +2264,7 @@ def update_smtp_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2277,7 +2277,7 @@ def update_smtp_provider( return self._parse_response(response, model=Provider) - def create_telesign_provider( + async def create_telesign_provider( self, provider_id: str, name: str, @@ -2331,7 +2331,7 @@ def create_telesign_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2344,7 +2344,7 @@ def create_telesign_provider( return self._parse_response(response, model=Provider) - def update_telesign_provider( + async def update_telesign_provider( self, provider_id: str, name: Optional[str] = None, @@ -2397,7 +2397,7 @@ def update_telesign_provider( if xfrom is not None: api_params['from'] = self._normalize_value(xfrom) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2410,7 +2410,7 @@ def update_telesign_provider( return self._parse_response(response, model=Provider) - def create_textmagic_provider( + async def create_textmagic_provider( self, provider_id: str, name: str, @@ -2464,7 +2464,7 @@ def create_textmagic_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2477,7 +2477,7 @@ def create_textmagic_provider( return self._parse_response(response, model=Provider) - def update_textmagic_provider( + async def update_textmagic_provider( self, provider_id: str, name: Optional[str] = None, @@ -2530,7 +2530,7 @@ def update_textmagic_provider( if xfrom is not None: api_params['from'] = self._normalize_value(xfrom) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2543,7 +2543,7 @@ def update_textmagic_provider( return self._parse_response(response, model=Provider) - def create_twilio_provider( + async def create_twilio_provider( self, provider_id: str, name: str, @@ -2597,7 +2597,7 @@ def create_twilio_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2610,7 +2610,7 @@ def create_twilio_provider( return self._parse_response(response, model=Provider) - def update_twilio_provider( + async def update_twilio_provider( self, provider_id: str, name: Optional[str] = None, @@ -2663,7 +2663,7 @@ def update_twilio_provider( if xfrom is not None: api_params['from'] = self._normalize_value(xfrom) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2676,7 +2676,7 @@ def update_twilio_provider( return self._parse_response(response, model=Provider) - def create_vonage_provider( + async def create_vonage_provider( self, provider_id: str, name: str, @@ -2730,7 +2730,7 @@ def create_vonage_provider( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2743,7 +2743,7 @@ def create_vonage_provider( return self._parse_response(response, model=Provider) - def update_vonage_provider( + async def update_vonage_provider( self, provider_id: str, name: Optional[str] = None, @@ -2796,7 +2796,7 @@ def update_vonage_provider( if xfrom is not None: api_params['from'] = self._normalize_value(xfrom) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2809,7 +2809,7 @@ def update_vonage_provider( return self._parse_response(response, model=Provider) - def get_provider( + async def get_provider( self, provider_id: str, ) -> Provider: @@ -2837,7 +2837,7 @@ def get_provider( raise AppwriteException('Missing required parameter: "provider_id"') api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2849,7 +2849,7 @@ def get_provider( return self._parse_response(response, model=Provider) - def delete_provider( + async def delete_provider( self, provider_id: str, ) -> Dict[str, Any]: @@ -2877,7 +2877,7 @@ def delete_provider( raise AppwriteException('Missing required parameter: "provider_id"') api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -2890,7 +2890,7 @@ def delete_provider( return response - def list_topics( + async def list_topics( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -2927,7 +2927,7 @@ def list_topics( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2939,7 +2939,7 @@ def list_topics( return self._parse_response(response, model=TopicList) - def create_topic( + async def create_topic( self, topic_id: str, name: str, @@ -2993,7 +2993,7 @@ def create_topic( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3006,7 +3006,7 @@ def create_topic( return self._parse_response(response, model=Topic) - def get_topic( + async def get_topic( self, topic_id: str, ) -> Topic: @@ -3034,7 +3034,7 @@ def get_topic( raise AppwriteException('Missing required parameter: "topic_id"') api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -3046,7 +3046,7 @@ def get_topic( return self._parse_response(response, model=Topic) - def update_topic( + async def update_topic( self, topic_id: str, name: Optional[str] = None, @@ -3099,7 +3099,7 @@ def update_topic( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3112,7 +3112,7 @@ def update_topic( return self._parse_response(response, model=Topic) - def delete_topic( + async def delete_topic( self, topic_id: str, ) -> Dict[str, Any]: @@ -3140,7 +3140,7 @@ def delete_topic( raise AppwriteException('Missing required parameter: "topic_id"') api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -3153,7 +3153,7 @@ def delete_topic( return response - def list_subscribers( + async def list_subscribers( self, topic_id: str, queries: Optional[List[str]] = None, @@ -3196,7 +3196,7 @@ def list_subscribers( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -3208,7 +3208,7 @@ def list_subscribers( return self._parse_response(response, model=SubscriberList) - def create_subscriber( + async def create_subscriber( self, topic_id: str, subscriber_id: str, @@ -3248,7 +3248,7 @@ def create_subscriber( api_params['subscriberId'] = self._normalize_value(subscriber_id) api_params['targetId'] = self._normalize_value(target_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3261,7 +3261,7 @@ def create_subscriber( return self._parse_response(response, model=Subscriber) - def get_subscriber( + async def get_subscriber( self, topic_id: str, subscriber_id: str, @@ -3295,7 +3295,7 @@ def get_subscriber( api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) api_path = api_path.replace('{subscriberId}', str(self._normalize_value(subscriber_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -3307,7 +3307,7 @@ def get_subscriber( return self._parse_response(response, model=Subscriber) - def delete_subscriber( + async def delete_subscriber( self, topic_id: str, subscriber_id: str, @@ -3341,7 +3341,7 @@ def delete_subscriber( api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) api_path = api_path.replace('{subscriberId}', str(self._normalize_value(subscriber_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/mongo.py b/appwrite/services/mongo.py index f377fe6c..462011f2 100644 --- a/appwrite/services/mongo.py +++ b/appwrite/services/mongo.py @@ -26,7 +26,7 @@ class Mongo(Service): def __init__(self, client) -> None: super(Mongo, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -58,7 +58,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -70,7 +70,7 @@ def list( return self._parse_response(response, model=DedicatedDatabaseList) - def create( + async def create( self, database_id: str, name: str, @@ -166,7 +166,7 @@ def create( if storage_autoscaling_max_gb is not None: api_params['storageAutoscalingMaxGb'] = self._normalize_value(storage_autoscaling_max_gb) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -179,7 +179,7 @@ def create( return self._parse_response(response, model=DedicatedDatabase) - def list_specifications( + async def list_specifications( self, ) -> DedicatedDatabaseSpecificationList: """ @@ -198,7 +198,7 @@ def list_specifications( api_path = '/mongo/specifications' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -210,7 +210,7 @@ def list_specifications( return self._parse_response(response, model=DedicatedDatabaseSpecificationList) - def get( + async def get( self, database_id: str, ) -> DedicatedDatabase: @@ -238,7 +238,7 @@ def get( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -250,7 +250,7 @@ def get( return self._parse_response(response, model=DedicatedDatabase) - def update( + async def update( self, database_id: str, name: Optional[str] = None, @@ -380,7 +380,7 @@ def update( if sql_api_timeout_seconds is not None: api_params['sqlApiTimeoutSeconds'] = self._normalize_value(sql_api_timeout_seconds) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -393,7 +393,7 @@ def update( return self._parse_response(response, model=DedicatedDatabase) - def delete( + async def delete( self, database_id: str, ) -> Dict[str, Any]: @@ -421,7 +421,7 @@ def delete( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -434,7 +434,7 @@ def delete( return response - def list_backups( + async def list_backups( self, database_id: str, queries: Optional[List[str]] = None, @@ -472,7 +472,7 @@ def list_backups( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -484,7 +484,7 @@ def list_backups( return self._parse_response(response, model=DedicatedDatabaseBackupList) - def create_backup( + async def create_backup( self, database_id: str, type: Optional[str] = None, @@ -517,7 +517,7 @@ def create_backup( if type is not None: api_params['type'] = self._normalize_value(type) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -530,7 +530,7 @@ def create_backup( return self._parse_response(response, model=DedicatedDatabaseBackup) - def list_backup_policies( + async def list_backup_policies( self, database_id: str, queries: Optional[List[str]] = None, @@ -568,7 +568,7 @@ def list_backup_policies( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -580,7 +580,7 @@ def list_backup_policies( return self._parse_response(response, model=BackupPolicyList) - def create_backup_policy( + async def create_backup_policy( self, database_id: str, policy_id: str, @@ -642,7 +642,7 @@ def create_backup_policy( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -655,7 +655,7 @@ def create_backup_policy( return self._parse_response(response, model=BackupPolicy) - def get_backup_policy( + async def get_backup_policy( self, database_id: str, policy_id: str, @@ -689,7 +689,7 @@ def get_backup_policy( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -701,7 +701,7 @@ def get_backup_policy( return self._parse_response(response, model=BackupPolicy) - def update_backup_policy( + async def update_backup_policy( self, database_id: str, policy_id: str, @@ -755,7 +755,7 @@ def update_backup_policy( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -768,7 +768,7 @@ def update_backup_policy( return self._parse_response(response, model=BackupPolicy) - def delete_backup_policy( + async def delete_backup_policy( self, database_id: str, policy_id: str, @@ -802,7 +802,7 @@ def delete_backup_policy( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -815,7 +815,7 @@ def delete_backup_policy( return response - def update_backup_storage( + async def update_backup_storage( self, database_id: str, provider: str, @@ -882,7 +882,7 @@ def update_backup_storage( api_params['accessKey'] = self._normalize_value(access_key) api_params['secretKey'] = self._normalize_value(secret_key) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -895,7 +895,7 @@ def update_backup_storage( return self._parse_response(response, model=DedicatedDatabaseBackupStorage) - def get_backup( + async def get_backup( self, database_id: str, backup_id: str, @@ -929,7 +929,7 @@ def get_backup( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{backupId}', str(self._normalize_value(backup_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -941,7 +941,7 @@ def get_backup( return self._parse_response(response, model=DedicatedDatabaseBackup) - def delete_backup( + async def delete_backup( self, database_id: str, backup_id: str, @@ -975,7 +975,7 @@ def delete_backup( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{backupId}', str(self._normalize_value(backup_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -988,7 +988,7 @@ def delete_backup( return response - def list_branches( + async def list_branches( self, database_id: str, ) -> DedicatedDatabaseBranchList: @@ -1016,7 +1016,7 @@ def list_branches( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1028,7 +1028,7 @@ def list_branches( return self._parse_response(response, model=DedicatedDatabaseBranchList) - def create_branch( + async def create_branch( self, database_id: str, branch_id: Optional[str] = None, @@ -1066,7 +1066,7 @@ def create_branch( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1079,7 +1079,7 @@ def create_branch( return self._parse_response(response, model=DedicatedDatabase) - def delete_branch( + async def delete_branch( self, database_id: str, branch_id: str, @@ -1113,7 +1113,7 @@ def delete_branch( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{branchId}', str(self._normalize_value(branch_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1126,7 +1126,7 @@ def delete_branch( return self._parse_response(response, model=DedicatedDatabase) - def update_credentials( + async def update_credentials( self, database_id: str, ) -> DedicatedDatabaseOperation: @@ -1154,7 +1154,7 @@ def update_credentials( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1167,7 +1167,7 @@ def update_credentials( return self._parse_response(response, model=DedicatedDatabaseOperation) - def create_failover( + async def create_failover( self, database_id: str, target_replica_id: Optional[str] = None, @@ -1200,7 +1200,7 @@ def create_failover( if target_replica_id is not None: api_params['targetReplicaId'] = self._normalize_value(target_replica_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1213,7 +1213,7 @@ def create_failover( return self._parse_response(response, model=DedicatedDatabase) - def update_maintenance( + async def update_maintenance( self, database_id: str, day: str, @@ -1253,7 +1253,7 @@ def update_maintenance( api_params['day'] = self._normalize_value(day) api_params['hourUtc'] = self._normalize_value(hour_utc) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1266,7 +1266,7 @@ def update_maintenance( return self._parse_response(response, model=DedicatedDatabase) - def create_migration( + async def create_migration( self, database_id: str, target_type: str, @@ -1305,7 +1305,7 @@ def create_migration( if specification is not None: api_params['specification'] = self._normalize_value(specification) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1318,7 +1318,7 @@ def create_migration( return self._parse_response(response, model=DedicatedDatabase) - def list_operations( + async def list_operations( self, database_id: str, status: Optional[str] = None, @@ -1361,7 +1361,7 @@ def list_operations( if offset is not None: api_params['offset'] = self._normalize_value(offset) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1373,7 +1373,7 @@ def list_operations( return self._parse_response(response, model=DedicatedDatabaseOperationList) - def get_pitr( + async def get_pitr( self, database_id: str, ) -> DedicatedDatabasePITRWindows: @@ -1401,7 +1401,7 @@ def get_pitr( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1413,7 +1413,7 @@ def get_pitr( return self._parse_response(response, model=DedicatedDatabasePITRWindows) - def get_replicas( + async def get_replicas( self, database_id: str, ) -> DedicatedDatabaseReplicas: @@ -1441,7 +1441,7 @@ def get_replicas( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1453,7 +1453,7 @@ def get_replicas( return self._parse_response(response, model=DedicatedDatabaseReplicas) - def list_restorations( + async def list_restorations( self, database_id: str, status: Optional[str] = None, @@ -1501,7 +1501,7 @@ def list_restorations( if offset is not None: api_params['offset'] = self._normalize_value(offset) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1513,7 +1513,7 @@ def list_restorations( return self._parse_response(response, model=DedicatedDatabaseRestorationList) - def create_restoration( + async def create_restoration( self, database_id: str, type: Optional[str] = None, @@ -1578,7 +1578,7 @@ def create_restoration( if auto_promote is not None: api_params['autoPromote'] = self._normalize_value(auto_promote) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1591,7 +1591,7 @@ def create_restoration( return self._parse_response(response, model=DedicatedDatabaseRestoration) - def get_restoration( + async def get_restoration( self, database_id: str, restoration_id: str, @@ -1625,7 +1625,7 @@ def get_restoration( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{restorationId}', str(self._normalize_value(restoration_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1637,7 +1637,7 @@ def get_restoration( return self._parse_response(response, model=DedicatedDatabaseRestoration) - def promote_restoration( + async def promote_restoration( self, database_id: str, restoration_id: str, @@ -1674,7 +1674,7 @@ def promote_restoration( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{restorationId}', str(self._normalize_value(restoration_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1687,7 +1687,7 @@ def promote_restoration( return self._parse_response(response, model=DedicatedDatabaseRestoration) - def get_status( + async def get_status( self, database_id: str, ) -> DatabaseStatus: @@ -1715,7 +1715,7 @@ def get_status( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1727,7 +1727,7 @@ def get_status( return self._parse_response(response, model=DatabaseStatus) - def create_upgrade( + async def create_upgrade( self, database_id: str, target_version: str, @@ -1761,7 +1761,7 @@ def create_upgrade( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_params['targetVersion'] = self._normalize_value(target_version) - response = self.client.call( + response = await self.client.call( 'post', api_path, { diff --git a/appwrite/services/mysql.py b/appwrite/services/mysql.py index 0e402fe2..dd967189 100644 --- a/appwrite/services/mysql.py +++ b/appwrite/services/mysql.py @@ -28,7 +28,7 @@ class Mysql(Service): def __init__(self, client) -> None: super(Mysql, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -60,7 +60,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -72,7 +72,7 @@ def list( return self._parse_response(response, model=DedicatedDatabaseList) - def create( + async def create( self, database_id: str, name: str, @@ -168,7 +168,7 @@ def create( if storage_autoscaling_max_gb is not None: api_params['storageAutoscalingMaxGb'] = self._normalize_value(storage_autoscaling_max_gb) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -181,7 +181,7 @@ def create( return self._parse_response(response, model=DedicatedDatabase) - def list_specifications( + async def list_specifications( self, ) -> DedicatedDatabaseSpecificationList: """ @@ -200,7 +200,7 @@ def list_specifications( api_path = '/mysql/specifications' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -212,7 +212,7 @@ def list_specifications( return self._parse_response(response, model=DedicatedDatabaseSpecificationList) - def get( + async def get( self, database_id: str, ) -> DedicatedDatabase: @@ -240,7 +240,7 @@ def get( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -252,7 +252,7 @@ def get( return self._parse_response(response, model=DedicatedDatabase) - def update( + async def update( self, database_id: str, name: Optional[str] = None, @@ -382,7 +382,7 @@ def update( if sql_api_timeout_seconds is not None: api_params['sqlApiTimeoutSeconds'] = self._normalize_value(sql_api_timeout_seconds) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -395,7 +395,7 @@ def update( return self._parse_response(response, model=DedicatedDatabase) - def delete( + async def delete( self, database_id: str, ) -> Dict[str, Any]: @@ -423,7 +423,7 @@ def delete( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -436,7 +436,7 @@ def delete( return response - def list_backups( + async def list_backups( self, database_id: str, queries: Optional[List[str]] = None, @@ -474,7 +474,7 @@ def list_backups( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -486,7 +486,7 @@ def list_backups( return self._parse_response(response, model=DedicatedDatabaseBackupList) - def create_backup( + async def create_backup( self, database_id: str, type: Optional[str] = None, @@ -519,7 +519,7 @@ def create_backup( if type is not None: api_params['type'] = self._normalize_value(type) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -532,7 +532,7 @@ def create_backup( return self._parse_response(response, model=DedicatedDatabaseBackup) - def list_backup_policies( + async def list_backup_policies( self, database_id: str, queries: Optional[List[str]] = None, @@ -570,7 +570,7 @@ def list_backup_policies( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -582,7 +582,7 @@ def list_backup_policies( return self._parse_response(response, model=BackupPolicyList) - def create_backup_policy( + async def create_backup_policy( self, database_id: str, policy_id: str, @@ -644,7 +644,7 @@ def create_backup_policy( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -657,7 +657,7 @@ def create_backup_policy( return self._parse_response(response, model=BackupPolicy) - def get_backup_policy( + async def get_backup_policy( self, database_id: str, policy_id: str, @@ -691,7 +691,7 @@ def get_backup_policy( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -703,7 +703,7 @@ def get_backup_policy( return self._parse_response(response, model=BackupPolicy) - def update_backup_policy( + async def update_backup_policy( self, database_id: str, policy_id: str, @@ -757,7 +757,7 @@ def update_backup_policy( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -770,7 +770,7 @@ def update_backup_policy( return self._parse_response(response, model=BackupPolicy) - def delete_backup_policy( + async def delete_backup_policy( self, database_id: str, policy_id: str, @@ -804,7 +804,7 @@ def delete_backup_policy( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -817,7 +817,7 @@ def delete_backup_policy( return response - def update_backup_storage( + async def update_backup_storage( self, database_id: str, provider: str, @@ -884,7 +884,7 @@ def update_backup_storage( api_params['accessKey'] = self._normalize_value(access_key) api_params['secretKey'] = self._normalize_value(secret_key) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -897,7 +897,7 @@ def update_backup_storage( return self._parse_response(response, model=DedicatedDatabaseBackupStorage) - def get_backup( + async def get_backup( self, database_id: str, backup_id: str, @@ -931,7 +931,7 @@ def get_backup( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{backupId}', str(self._normalize_value(backup_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -943,7 +943,7 @@ def get_backup( return self._parse_response(response, model=DedicatedDatabaseBackup) - def delete_backup( + async def delete_backup( self, database_id: str, backup_id: str, @@ -977,7 +977,7 @@ def delete_backup( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{backupId}', str(self._normalize_value(backup_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -990,7 +990,7 @@ def delete_backup( return response - def list_branches( + async def list_branches( self, database_id: str, ) -> DedicatedDatabaseBranchList: @@ -1018,7 +1018,7 @@ def list_branches( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1030,7 +1030,7 @@ def list_branches( return self._parse_response(response, model=DedicatedDatabaseBranchList) - def create_branch( + async def create_branch( self, database_id: str, branch_id: Optional[str] = None, @@ -1068,7 +1068,7 @@ def create_branch( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1081,7 +1081,7 @@ def create_branch( return self._parse_response(response, model=DedicatedDatabase) - def delete_branch( + async def delete_branch( self, database_id: str, branch_id: str, @@ -1115,7 +1115,7 @@ def delete_branch( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{branchId}', str(self._normalize_value(branch_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1128,7 +1128,7 @@ def delete_branch( return self._parse_response(response, model=DedicatedDatabase) - def update_credentials( + async def update_credentials( self, database_id: str, ) -> DedicatedDatabaseOperation: @@ -1156,7 +1156,7 @@ def update_credentials( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1169,7 +1169,7 @@ def update_credentials( return self._parse_response(response, model=DedicatedDatabaseOperation) - def create_execution( + async def create_execution( self, database_id: str, sql: str, @@ -1213,7 +1213,7 @@ def create_execution( if timeout_seconds is not None: api_params['timeoutSeconds'] = self._normalize_value(timeout_seconds) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1226,7 +1226,7 @@ def create_execution( return self._parse_response(response, model=DedicatedDatabaseExecution) - def create_failover( + async def create_failover( self, database_id: str, target_replica_id: Optional[str] = None, @@ -1259,7 +1259,7 @@ def create_failover( if target_replica_id is not None: api_params['targetReplicaId'] = self._normalize_value(target_replica_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1272,7 +1272,7 @@ def create_failover( return self._parse_response(response, model=DedicatedDatabase) - def update_maintenance( + async def update_maintenance( self, database_id: str, day: str, @@ -1312,7 +1312,7 @@ def update_maintenance( api_params['day'] = self._normalize_value(day) api_params['hourUtc'] = self._normalize_value(hour_utc) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1325,7 +1325,7 @@ def update_maintenance( return self._parse_response(response, model=DedicatedDatabase) - def create_migration( + async def create_migration( self, database_id: str, target_type: str, @@ -1364,7 +1364,7 @@ def create_migration( if specification is not None: api_params['specification'] = self._normalize_value(specification) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1377,7 +1377,7 @@ def create_migration( return self._parse_response(response, model=DedicatedDatabase) - def list_operations( + async def list_operations( self, database_id: str, status: Optional[str] = None, @@ -1420,7 +1420,7 @@ def list_operations( if offset is not None: api_params['offset'] = self._normalize_value(offset) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1432,7 +1432,7 @@ def list_operations( return self._parse_response(response, model=DedicatedDatabaseOperationList) - def get_pitr( + async def get_pitr( self, database_id: str, ) -> DedicatedDatabasePITRWindows: @@ -1460,7 +1460,7 @@ def get_pitr( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1472,7 +1472,7 @@ def get_pitr( return self._parse_response(response, model=DedicatedDatabasePITRWindows) - def get_pooler( + async def get_pooler( self, database_id: str, ) -> DedicatedDatabasePooler: @@ -1500,7 +1500,7 @@ def get_pooler( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1512,7 +1512,7 @@ def get_pooler( return self._parse_response(response, model=DedicatedDatabasePooler) - def update_pooler( + async def update_pooler( self, database_id: str, mode: Optional[str] = None, @@ -1580,7 +1580,7 @@ def update_pooler( if pooler_memory_limit is not None: api_params['poolerMemoryLimit'] = self._normalize_value(pooler_memory_limit) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1593,7 +1593,7 @@ def update_pooler( return self._parse_response(response, model=DedicatedDatabasePooler) - def get_replicas( + async def get_replicas( self, database_id: str, ) -> DedicatedDatabaseReplicas: @@ -1621,7 +1621,7 @@ def get_replicas( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1633,7 +1633,7 @@ def get_replicas( return self._parse_response(response, model=DedicatedDatabaseReplicas) - def list_restorations( + async def list_restorations( self, database_id: str, status: Optional[str] = None, @@ -1681,7 +1681,7 @@ def list_restorations( if offset is not None: api_params['offset'] = self._normalize_value(offset) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1693,7 +1693,7 @@ def list_restorations( return self._parse_response(response, model=DedicatedDatabaseRestorationList) - def create_restoration( + async def create_restoration( self, database_id: str, type: Optional[str] = None, @@ -1758,7 +1758,7 @@ def create_restoration( if auto_promote is not None: api_params['autoPromote'] = self._normalize_value(auto_promote) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1771,7 +1771,7 @@ def create_restoration( return self._parse_response(response, model=DedicatedDatabaseRestoration) - def get_restoration( + async def get_restoration( self, database_id: str, restoration_id: str, @@ -1805,7 +1805,7 @@ def get_restoration( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{restorationId}', str(self._normalize_value(restoration_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1817,7 +1817,7 @@ def get_restoration( return self._parse_response(response, model=DedicatedDatabaseRestoration) - def promote_restoration( + async def promote_restoration( self, database_id: str, restoration_id: str, @@ -1854,7 +1854,7 @@ def promote_restoration( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{restorationId}', str(self._normalize_value(restoration_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1867,7 +1867,7 @@ def promote_restoration( return self._parse_response(response, model=DedicatedDatabaseRestoration) - def get_status( + async def get_status( self, database_id: str, ) -> DatabaseStatus: @@ -1895,7 +1895,7 @@ def get_status( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1907,7 +1907,7 @@ def get_status( return self._parse_response(response, model=DatabaseStatus) - def create_upgrade( + async def create_upgrade( self, database_id: str, target_version: str, @@ -1941,7 +1941,7 @@ def create_upgrade( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_params['targetVersion'] = self._normalize_value(target_version) - response = self.client.call( + response = await self.client.call( 'post', api_path, { diff --git a/appwrite/services/oauth2.py b/appwrite/services/oauth2.py index 774dcf2c..cc887f35 100644 --- a/appwrite/services/oauth2.py +++ b/appwrite/services/oauth2.py @@ -20,7 +20,7 @@ class Oauth2(Service): def __init__(self, client) -> None: super(Oauth2, self).__init__(client) - def approve( + async def approve( self, grant_id: str, authorization_details: Optional[str] = None, @@ -59,7 +59,7 @@ def approve( if scope is not None: api_params['scope'] = self._normalize_value(scope) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -71,7 +71,7 @@ def approve( return self._parse_response(response, model=Oauth2Approve) - def authorize( + async def authorize( self, client_id: Optional[str] = None, redirect_uri: Optional[str] = None, @@ -164,7 +164,7 @@ def authorize( if request_uri is not None: api_params['request_uri'] = self._normalize_value(request_uri) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -175,7 +175,7 @@ def authorize( return self._parse_response(response, model=Oauth2Authorize) - def authorize_post( + async def authorize_post( self, client_id: Optional[str] = None, redirect_uri: Optional[str] = None, @@ -268,7 +268,7 @@ def authorize_post( if request_uri is not None: api_params['request_uri'] = self._normalize_value(request_uri) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -280,7 +280,7 @@ def authorize_post( return self._parse_response(response, model=Oauth2Authorize) - def create_device_authorization( + async def create_device_authorization( self, client_id: Optional[str] = None, scope: Optional[str] = None, @@ -328,7 +328,7 @@ def create_device_authorization( if audience is not None: api_params['audience'] = self._normalize_value(audience) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -340,7 +340,7 @@ def create_device_authorization( return self._parse_response(response, model=Oauth2DeviceAuthorization) - def create_grant( + async def create_grant( self, user_code: str, ) -> Oauth2Grant: @@ -369,7 +369,7 @@ def create_grant( api_path = api_path.replace('{project_id}', str(self._normalize_value(self.client.get_config('project')))) api_params['user_code'] = self._normalize_value(user_code) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -381,7 +381,7 @@ def create_grant( return self._parse_response(response, model=Oauth2Grant) - def get_grant( + async def get_grant( self, grant_id: str, ) -> Oauth2Grant: @@ -410,7 +410,7 @@ def get_grant( api_path = api_path.replace('{project_id}', str(self._normalize_value(self.client.get_config('project')))) api_path = api_path.replace('{grant_id}', str(self._normalize_value(grant_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -421,7 +421,7 @@ def get_grant( return self._parse_response(response, model=Oauth2Grant) - def introspect( + async def introspect( self, token: str, token_type_hint: Optional[str] = None, @@ -465,7 +465,7 @@ def introspect( if client_secret is not None: api_params['client_secret'] = self._normalize_value(client_secret) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -477,7 +477,7 @@ def introspect( return self._parse_response(response, model=Oauth2Introspection) - def list_organizations( + async def list_organizations( self, limit: Optional[float] = None, offset: Optional[float] = None, @@ -515,7 +515,7 @@ def list_organizations( if search is not None: api_params['search'] = self._normalize_value(search) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -526,7 +526,7 @@ def list_organizations( return self._parse_response(response, model=Oauth2OrganizationList) - def create_par( + async def create_par( self, client_id: str, redirect_uri: str, @@ -617,7 +617,7 @@ def create_par( if audience is not None: api_params['audience'] = self._normalize_value(audience) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -629,7 +629,7 @@ def create_par( return self._parse_response(response, model=Oauth2PAR) - def list_projects( + async def list_projects( self, limit: Optional[float] = None, offset: Optional[float] = None, @@ -667,7 +667,7 @@ def list_projects( if search is not None: api_params['search'] = self._normalize_value(search) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -678,7 +678,7 @@ def list_projects( return self._parse_response(response, model=Oauth2ProjectList) - def reject( + async def reject( self, grant_id: str, ) -> Oauth2Reject: @@ -707,7 +707,7 @@ def reject( api_path = api_path.replace('{project_id}', str(self._normalize_value(self.client.get_config('project')))) api_params['grant_id'] = self._normalize_value(grant_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -719,7 +719,7 @@ def reject( return self._parse_response(response, model=Oauth2Reject) - def revoke( + async def revoke( self, token: str, token_type_hint: Optional[str] = None, @@ -763,7 +763,7 @@ def revoke( if client_secret is not None: api_params['client_secret'] = self._normalize_value(client_secret) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -775,7 +775,7 @@ def revoke( return response - def create_token( + async def create_token( self, grant_type: str, code: Optional[str] = None, @@ -849,7 +849,7 @@ def create_token( if audience is not None: api_params['audience'] = self._normalize_value(audience) - response = self.client.call( + response = await self.client.call( 'post', api_path, { diff --git a/appwrite/services/organization.py b/appwrite/services/organization.py index ecb7efdb..44c67397 100644 --- a/appwrite/services/organization.py +++ b/appwrite/services/organization.py @@ -24,7 +24,7 @@ class Organization(Service): def __init__(self, client) -> None: super(Organization, self).__init__(client) - def get( + async def get( self, model_type: Type[T] = dict, ) -> OrganizationModel[T]: @@ -50,7 +50,7 @@ def get( api_path = '/organization' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -62,7 +62,7 @@ def get( return OrganizationModel.with_data(response, model_type) - def update( + async def update( self, name: str, model_type: Type[T] = dict, @@ -94,7 +94,7 @@ def update( raise AppwriteException('Missing required parameter: "name"') api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -107,7 +107,7 @@ def update( return OrganizationModel.with_data(response, model_type) - def delete( + async def delete( self, ) -> Dict[str, Any]: """ @@ -126,7 +126,7 @@ def delete( api_path = '/organization' api_params = {} - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -139,7 +139,7 @@ def delete( return response - def list_installations( + async def list_installations( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -171,7 +171,7 @@ def list_installations( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -183,7 +183,7 @@ def list_installations( return self._parse_response(response, model=AppInstallationList) - def create_installation( + async def create_installation( self, app_id: str, authorization_details: Optional[str] = None, @@ -216,7 +216,7 @@ def create_installation( if authorization_details is not None: api_params['authorizationDetails'] = self._normalize_value(authorization_details) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -229,7 +229,7 @@ def create_installation( return self._parse_response(response, model=AppInstallation) - def get_installation( + async def get_installation( self, installation_id: str, ) -> AppInstallation: @@ -257,7 +257,7 @@ def get_installation( raise AppwriteException('Missing required parameter: "installation_id"') api_path = api_path.replace('{installationId}', str(self._normalize_value(installation_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -269,7 +269,7 @@ def get_installation( return self._parse_response(response, model=AppInstallation) - def update_installation( + async def update_installation( self, installation_id: str, authorization_details: Optional[str] = None, @@ -302,7 +302,7 @@ def update_installation( if authorization_details is not None: api_params['authorizationDetails'] = self._normalize_value(authorization_details) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -315,7 +315,7 @@ def update_installation( return self._parse_response(response, model=AppInstallation) - def delete_installation( + async def delete_installation( self, installation_id: str, ) -> Dict[str, Any]: @@ -343,7 +343,7 @@ def delete_installation( raise AppwriteException('Missing required parameter: "installation_id"') api_path = api_path.replace('{installationId}', str(self._normalize_value(installation_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -356,7 +356,7 @@ def delete_installation( return response - def list_memberships( + async def list_memberships( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -393,7 +393,7 @@ def list_memberships( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -405,7 +405,7 @@ def list_memberships( return self._parse_response(response, model=MembershipList) - def create_membership( + async def create_membership( self, roles: List[str], email: Optional[str] = None, @@ -458,7 +458,7 @@ def create_membership( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -471,7 +471,7 @@ def create_membership( return self._parse_response(response, model=Membership) - def get_membership( + async def get_membership( self, membership_id: str, ) -> Membership: @@ -499,7 +499,7 @@ def get_membership( raise AppwriteException('Missing required parameter: "membership_id"') api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -511,7 +511,7 @@ def get_membership( return self._parse_response(response, model=Membership) - def update_membership( + async def update_membership( self, membership_id: str, roles: List[str], @@ -545,7 +545,7 @@ def update_membership( api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) api_params['roles'] = self._normalize_value(roles) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -558,7 +558,7 @@ def update_membership( return self._parse_response(response, model=Membership) - def delete_membership( + async def delete_membership( self, membership_id: str, ) -> Dict[str, Any]: @@ -586,7 +586,7 @@ def delete_membership( raise AppwriteException('Missing required parameter: "membership_id"') api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -599,7 +599,7 @@ def delete_membership( return response - def list_projects( + async def list_projects( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -636,7 +636,7 @@ def list_projects( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -648,7 +648,7 @@ def list_projects( return self._parse_response(response, model=ProjectList) - def create_project( + async def create_project( self, project_id: str, name: str, @@ -687,7 +687,7 @@ def create_project( if region is not None: api_params['region'] = self._normalize_value(region) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -700,7 +700,7 @@ def create_project( return self._parse_response(response, model=Project) - def get_project( + async def get_project( self, project_id: str, ) -> Project: @@ -728,7 +728,7 @@ def get_project( raise AppwriteException('Missing required parameter: "project_id"') api_path = api_path.replace('{projectId}', str(self._normalize_value(project_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -740,7 +740,7 @@ def get_project( return self._parse_response(response, model=Project) - def update_project( + async def update_project( self, project_id: str, name: str, @@ -774,7 +774,7 @@ def update_project( api_path = api_path.replace('{projectId}', str(self._normalize_value(project_id))) api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -787,7 +787,7 @@ def update_project( return self._parse_response(response, model=Project) - def delete_project( + async def delete_project( self, project_id: str, ) -> Dict[str, Any]: @@ -815,7 +815,7 @@ def delete_project( raise AppwriteException('Missing required parameter: "project_id"') api_path = api_path.replace('{projectId}', str(self._normalize_value(project_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -828,7 +828,7 @@ def delete_project( return response - def list_project_keys( + async def list_project_keys( self, project_id: str, queries: Optional[List[str]] = None, @@ -866,7 +866,7 @@ def list_project_keys( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -878,7 +878,7 @@ def list_project_keys( return self._parse_response(response, model=KeyList) - def create_ephemeral_project_key( + async def create_ephemeral_project_key( self, project_id: str, scopes: List[ProjectKeyScopes], @@ -920,7 +920,7 @@ def create_ephemeral_project_key( api_params['scopes'] = self._normalize_value(scopes) api_params['duration'] = self._normalize_value(duration) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -933,7 +933,7 @@ def create_ephemeral_project_key( return self._parse_response(response, model=EphemeralKey) - def get_project_key( + async def get_project_key( self, project_id: str, key_id: str, @@ -967,7 +967,7 @@ def get_project_key( api_path = api_path.replace('{projectId}', str(self._normalize_value(project_id))) api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -979,7 +979,7 @@ def get_project_key( return self._parse_response(response, model=Key) - def update_project_key( + async def update_project_key( self, project_id: str, key_id: str, @@ -1035,7 +1035,7 @@ def update_project_key( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1048,7 +1048,7 @@ def update_project_key( return self._parse_response(response, model=Key) - def delete_project_key( + async def delete_project_key( self, project_id: str, key_id: str, @@ -1082,7 +1082,7 @@ def delete_project_key( api_path = api_path.replace('{projectId}', str(self._normalize_value(project_id))) api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/postgresql.py b/appwrite/services/postgresql.py index a5692e05..bcd1e500 100644 --- a/appwrite/services/postgresql.py +++ b/appwrite/services/postgresql.py @@ -29,7 +29,7 @@ class Postgresql(Service): def __init__(self, client) -> None: super(Postgresql, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -61,7 +61,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -73,7 +73,7 @@ def list( return self._parse_response(response, model=DedicatedDatabaseList) - def create( + async def create( self, database_id: str, name: str, @@ -169,7 +169,7 @@ def create( if storage_autoscaling_max_gb is not None: api_params['storageAutoscalingMaxGb'] = self._normalize_value(storage_autoscaling_max_gb) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -182,7 +182,7 @@ def create( return self._parse_response(response, model=DedicatedDatabase) - def list_specifications( + async def list_specifications( self, ) -> DedicatedDatabaseSpecificationList: """ @@ -201,7 +201,7 @@ def list_specifications( api_path = '/postgresql/specifications' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -213,7 +213,7 @@ def list_specifications( return self._parse_response(response, model=DedicatedDatabaseSpecificationList) - def get( + async def get( self, database_id: str, ) -> DedicatedDatabase: @@ -241,7 +241,7 @@ def get( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -253,7 +253,7 @@ def get( return self._parse_response(response, model=DedicatedDatabase) - def update( + async def update( self, database_id: str, name: Optional[str] = None, @@ -383,7 +383,7 @@ def update( if sql_api_timeout_seconds is not None: api_params['sqlApiTimeoutSeconds'] = self._normalize_value(sql_api_timeout_seconds) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -396,7 +396,7 @@ def update( return self._parse_response(response, model=DedicatedDatabase) - def delete( + async def delete( self, database_id: str, ) -> Dict[str, Any]: @@ -424,7 +424,7 @@ def delete( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -437,7 +437,7 @@ def delete( return response - def list_backups( + async def list_backups( self, database_id: str, queries: Optional[List[str]] = None, @@ -475,7 +475,7 @@ def list_backups( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -487,7 +487,7 @@ def list_backups( return self._parse_response(response, model=DedicatedDatabaseBackupList) - def create_backup( + async def create_backup( self, database_id: str, type: Optional[str] = None, @@ -520,7 +520,7 @@ def create_backup( if type is not None: api_params['type'] = self._normalize_value(type) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -533,7 +533,7 @@ def create_backup( return self._parse_response(response, model=DedicatedDatabaseBackup) - def list_backup_policies( + async def list_backup_policies( self, database_id: str, queries: Optional[List[str]] = None, @@ -571,7 +571,7 @@ def list_backup_policies( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -583,7 +583,7 @@ def list_backup_policies( return self._parse_response(response, model=BackupPolicyList) - def create_backup_policy( + async def create_backup_policy( self, database_id: str, policy_id: str, @@ -645,7 +645,7 @@ def create_backup_policy( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -658,7 +658,7 @@ def create_backup_policy( return self._parse_response(response, model=BackupPolicy) - def get_backup_policy( + async def get_backup_policy( self, database_id: str, policy_id: str, @@ -692,7 +692,7 @@ def get_backup_policy( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -704,7 +704,7 @@ def get_backup_policy( return self._parse_response(response, model=BackupPolicy) - def update_backup_policy( + async def update_backup_policy( self, database_id: str, policy_id: str, @@ -758,7 +758,7 @@ def update_backup_policy( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -771,7 +771,7 @@ def update_backup_policy( return self._parse_response(response, model=BackupPolicy) - def delete_backup_policy( + async def delete_backup_policy( self, database_id: str, policy_id: str, @@ -805,7 +805,7 @@ def delete_backup_policy( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -818,7 +818,7 @@ def delete_backup_policy( return response - def update_backup_storage( + async def update_backup_storage( self, database_id: str, provider: str, @@ -885,7 +885,7 @@ def update_backup_storage( api_params['accessKey'] = self._normalize_value(access_key) api_params['secretKey'] = self._normalize_value(secret_key) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -898,7 +898,7 @@ def update_backup_storage( return self._parse_response(response, model=DedicatedDatabaseBackupStorage) - def get_backup( + async def get_backup( self, database_id: str, backup_id: str, @@ -932,7 +932,7 @@ def get_backup( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{backupId}', str(self._normalize_value(backup_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -944,7 +944,7 @@ def get_backup( return self._parse_response(response, model=DedicatedDatabaseBackup) - def delete_backup( + async def delete_backup( self, database_id: str, backup_id: str, @@ -978,7 +978,7 @@ def delete_backup( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{backupId}', str(self._normalize_value(backup_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -991,7 +991,7 @@ def delete_backup( return response - def list_branches( + async def list_branches( self, database_id: str, ) -> DedicatedDatabaseBranchList: @@ -1019,7 +1019,7 @@ def list_branches( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1031,7 +1031,7 @@ def list_branches( return self._parse_response(response, model=DedicatedDatabaseBranchList) - def create_branch( + async def create_branch( self, database_id: str, branch_id: Optional[str] = None, @@ -1069,7 +1069,7 @@ def create_branch( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1082,7 +1082,7 @@ def create_branch( return self._parse_response(response, model=DedicatedDatabase) - def delete_branch( + async def delete_branch( self, database_id: str, branch_id: str, @@ -1116,7 +1116,7 @@ def delete_branch( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{branchId}', str(self._normalize_value(branch_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1129,7 +1129,7 @@ def delete_branch( return self._parse_response(response, model=DedicatedDatabase) - def update_credentials( + async def update_credentials( self, database_id: str, ) -> DedicatedDatabaseOperation: @@ -1157,7 +1157,7 @@ def update_credentials( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1170,7 +1170,7 @@ def update_credentials( return self._parse_response(response, model=DedicatedDatabaseOperation) - def create_execution( + async def create_execution( self, database_id: str, sql: str, @@ -1214,7 +1214,7 @@ def create_execution( if timeout_seconds is not None: api_params['timeoutSeconds'] = self._normalize_value(timeout_seconds) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1227,7 +1227,7 @@ def create_execution( return self._parse_response(response, model=DedicatedDatabaseExecution) - def list_extensions( + async def list_extensions( self, database_id: str, ) -> DedicatedDatabaseExtensions: @@ -1255,7 +1255,7 @@ def list_extensions( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1267,7 +1267,7 @@ def list_extensions( return self._parse_response(response, model=DedicatedDatabaseExtensions) - def create_extension( + async def create_extension( self, database_id: str, name: str, @@ -1301,7 +1301,7 @@ def create_extension( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1314,7 +1314,7 @@ def create_extension( return self._parse_response(response, model=DedicatedDatabase) - def delete_extension( + async def delete_extension( self, database_id: str, extension_name: str, @@ -1348,7 +1348,7 @@ def delete_extension( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{extensionName}', str(self._normalize_value(extension_name))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1361,7 +1361,7 @@ def delete_extension( return self._parse_response(response, model=DedicatedDatabase) - def create_failover( + async def create_failover( self, database_id: str, target_replica_id: Optional[str] = None, @@ -1394,7 +1394,7 @@ def create_failover( if target_replica_id is not None: api_params['targetReplicaId'] = self._normalize_value(target_replica_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1407,7 +1407,7 @@ def create_failover( return self._parse_response(response, model=DedicatedDatabase) - def update_maintenance( + async def update_maintenance( self, database_id: str, day: str, @@ -1447,7 +1447,7 @@ def update_maintenance( api_params['day'] = self._normalize_value(day) api_params['hourUtc'] = self._normalize_value(hour_utc) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1460,7 +1460,7 @@ def update_maintenance( return self._parse_response(response, model=DedicatedDatabase) - def create_migration( + async def create_migration( self, database_id: str, target_type: str, @@ -1499,7 +1499,7 @@ def create_migration( if specification is not None: api_params['specification'] = self._normalize_value(specification) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1512,7 +1512,7 @@ def create_migration( return self._parse_response(response, model=DedicatedDatabase) - def list_operations( + async def list_operations( self, database_id: str, status: Optional[str] = None, @@ -1555,7 +1555,7 @@ def list_operations( if offset is not None: api_params['offset'] = self._normalize_value(offset) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1567,7 +1567,7 @@ def list_operations( return self._parse_response(response, model=DedicatedDatabaseOperationList) - def get_pitr( + async def get_pitr( self, database_id: str, ) -> DedicatedDatabasePITRWindows: @@ -1595,7 +1595,7 @@ def get_pitr( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1607,7 +1607,7 @@ def get_pitr( return self._parse_response(response, model=DedicatedDatabasePITRWindows) - def get_pooler( + async def get_pooler( self, database_id: str, ) -> DedicatedDatabasePooler: @@ -1635,7 +1635,7 @@ def get_pooler( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1647,7 +1647,7 @@ def get_pooler( return self._parse_response(response, model=DedicatedDatabasePooler) - def update_pooler( + async def update_pooler( self, database_id: str, mode: Optional[str] = None, @@ -1715,7 +1715,7 @@ def update_pooler( if pooler_memory_limit is not None: api_params['poolerMemoryLimit'] = self._normalize_value(pooler_memory_limit) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1728,7 +1728,7 @@ def update_pooler( return self._parse_response(response, model=DedicatedDatabasePooler) - def get_replicas( + async def get_replicas( self, database_id: str, ) -> DedicatedDatabaseReplicas: @@ -1756,7 +1756,7 @@ def get_replicas( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1768,7 +1768,7 @@ def get_replicas( return self._parse_response(response, model=DedicatedDatabaseReplicas) - def list_restorations( + async def list_restorations( self, database_id: str, status: Optional[str] = None, @@ -1816,7 +1816,7 @@ def list_restorations( if offset is not None: api_params['offset'] = self._normalize_value(offset) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1828,7 +1828,7 @@ def list_restorations( return self._parse_response(response, model=DedicatedDatabaseRestorationList) - def create_restoration( + async def create_restoration( self, database_id: str, type: Optional[str] = None, @@ -1893,7 +1893,7 @@ def create_restoration( if auto_promote is not None: api_params['autoPromote'] = self._normalize_value(auto_promote) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1906,7 +1906,7 @@ def create_restoration( return self._parse_response(response, model=DedicatedDatabaseRestoration) - def get_restoration( + async def get_restoration( self, database_id: str, restoration_id: str, @@ -1940,7 +1940,7 @@ def get_restoration( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{restorationId}', str(self._normalize_value(restoration_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1952,7 +1952,7 @@ def get_restoration( return self._parse_response(response, model=DedicatedDatabaseRestoration) - def promote_restoration( + async def promote_restoration( self, database_id: str, restoration_id: str, @@ -1989,7 +1989,7 @@ def promote_restoration( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{restorationId}', str(self._normalize_value(restoration_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2002,7 +2002,7 @@ def promote_restoration( return self._parse_response(response, model=DedicatedDatabaseRestoration) - def get_status( + async def get_status( self, database_id: str, ) -> DatabaseStatus: @@ -2030,7 +2030,7 @@ def get_status( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2042,7 +2042,7 @@ def get_status( return self._parse_response(response, model=DatabaseStatus) - def create_upgrade( + async def create_upgrade( self, database_id: str, target_version: str, @@ -2076,7 +2076,7 @@ def create_upgrade( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_params['targetVersion'] = self._normalize_value(target_version) - response = self.client.call( + response = await self.client.call( 'post', api_path, { diff --git a/appwrite/services/presences.py b/appwrite/services/presences.py index 7066914a..5f93c23e 100644 --- a/appwrite/services/presences.py +++ b/appwrite/services/presences.py @@ -12,7 +12,7 @@ class Presences(Service): def __init__(self, client) -> None: super(Presences, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -49,7 +49,7 @@ def list( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -61,7 +61,7 @@ def list( return self._parse_response(response, model=PresenceList) - def get( + async def get( self, presence_id: str, ) -> Presence: @@ -89,7 +89,7 @@ def get( raise AppwriteException('Missing required parameter: "presence_id"') api_path = api_path.replace('{presenceId}', str(self._normalize_value(presence_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -101,7 +101,7 @@ def get( return self._parse_response(response, model=Presence) - def upsert( + async def upsert( self, presence_id: str, user_id: str, @@ -156,7 +156,7 @@ def upsert( if metadata is not None: api_params['metadata'] = self._normalize_value(metadata) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -169,7 +169,7 @@ def upsert( return self._parse_response(response, model=Presence) - def update( + async def update( self, presence_id: str, user_id: str, @@ -228,7 +228,7 @@ def update( if purge is not None: api_params['purge'] = self._normalize_value(purge) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -241,7 +241,7 @@ def update( return self._parse_response(response, model=Presence) - def delete( + async def delete( self, presence_id: str, ) -> Dict[str, Any]: @@ -269,7 +269,7 @@ def delete( raise AppwriteException('Missing required parameter: "presence_id"') api_path = api_path.replace('{presenceId}', str(self._normalize_value(presence_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/project.py b/appwrite/services/project.py index d1d6da2d..39f054c3 100644 --- a/appwrite/services/project.py +++ b/appwrite/services/project.py @@ -113,7 +113,7 @@ class Project(Service): def __init__(self, client) -> None: super(Project, self).__init__(client) - def get( + async def get( self, ) -> ProjectModel: """ @@ -132,7 +132,7 @@ def get( api_path = '/project' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -144,7 +144,7 @@ def get( return self._parse_response(response, model=ProjectModel) - def delete( + async def delete( self, ) -> Dict[str, Any]: """ @@ -163,7 +163,7 @@ def delete( api_path = '/project' api_params = {} - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -176,7 +176,7 @@ def delete( return response - def update_auth_method( + async def update_auth_method( self, method_id: ProjectAuthMethodId, enabled: bool, @@ -210,7 +210,7 @@ def update_auth_method( api_path = api_path.replace('{methodId}', str(self._normalize_value(method_id))) api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -223,7 +223,7 @@ def update_auth_method( return self._parse_response(response, model=ProjectModel) - def list_environments( + async def list_environments( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -255,7 +255,7 @@ def list_environments( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -267,7 +267,7 @@ def list_environments( return self._parse_response(response, model=ProjectList) - def create_environment( + async def create_environment( self, environment_id: str, name: str, @@ -301,7 +301,7 @@ def create_environment( api_params['environmentId'] = self._normalize_value(environment_id) api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -314,7 +314,7 @@ def create_environment( return self._parse_response(response, model=ProjectModel) - def get_environment( + async def get_environment( self, environment_id: str, ) -> ProjectModel: @@ -342,7 +342,7 @@ def get_environment( raise AppwriteException('Missing required parameter: "environment_id"') api_path = api_path.replace('{environmentId}', str(self._normalize_value(environment_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -354,7 +354,7 @@ def get_environment( return self._parse_response(response, model=ProjectModel) - def update_environment( + async def update_environment( self, environment_id: str, name: str, @@ -388,7 +388,7 @@ def update_environment( api_path = api_path.replace('{environmentId}', str(self._normalize_value(environment_id))) api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -401,7 +401,7 @@ def update_environment( return self._parse_response(response, model=ProjectModel) - def delete_environment( + async def delete_environment( self, environment_id: str, ) -> Dict[str, Any]: @@ -429,7 +429,7 @@ def delete_environment( raise AppwriteException('Missing required parameter: "environment_id"') api_path = api_path.replace('{environmentId}', str(self._normalize_value(environment_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -442,7 +442,7 @@ def delete_environment( return response - def list_keys( + async def list_keys( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -474,7 +474,7 @@ def list_keys( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -486,7 +486,7 @@ def list_keys( return self._parse_response(response, model=KeyList) - def create_ephemeral_key( + async def create_ephemeral_key( self, scopes: List[ProjectKeyScopes], duration: float, @@ -522,7 +522,7 @@ def create_ephemeral_key( api_params['scopes'] = self._normalize_value(scopes) api_params['duration'] = self._normalize_value(duration) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -535,7 +535,7 @@ def create_ephemeral_key( return self._parse_response(response, model=EphemeralKey) - def get_key( + async def get_key( self, key_id: str, ) -> Key: @@ -563,7 +563,7 @@ def get_key( raise AppwriteException('Missing required parameter: "key_id"') api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -575,7 +575,7 @@ def get_key( return self._parse_response(response, model=Key) - def update_key( + async def update_key( self, key_id: str, name: str, @@ -625,7 +625,7 @@ def update_key( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -638,7 +638,7 @@ def update_key( return self._parse_response(response, model=Key) - def delete_key( + async def delete_key( self, key_id: str, ) -> Dict[str, Any]: @@ -666,7 +666,7 @@ def delete_key( raise AppwriteException('Missing required parameter: "key_id"') api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -679,7 +679,7 @@ def delete_key( return response - def update_labels( + async def update_labels( self, labels: List[str], ) -> ProjectModel: @@ -707,7 +707,7 @@ def update_labels( raise AppwriteException('Missing required parameter: "labels"') api_params['labels'] = self._normalize_value(labels) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -720,7 +720,7 @@ def update_labels( return self._parse_response(response, model=ProjectModel) - def list_mock_phones( + async def list_mock_phones( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -752,7 +752,7 @@ def list_mock_phones( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -764,7 +764,7 @@ def list_mock_phones( return self._parse_response(response, model=MockNumberList) - def create_mock_phone( + async def create_mock_phone( self, number: str, otp: str, @@ -798,7 +798,7 @@ def create_mock_phone( api_params['number'] = self._normalize_value(number) api_params['otp'] = self._normalize_value(otp) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -811,7 +811,7 @@ def create_mock_phone( return self._parse_response(response, model=MockNumber) - def get_mock_phone( + async def get_mock_phone( self, number: str, ) -> MockNumber: @@ -839,7 +839,7 @@ def get_mock_phone( raise AppwriteException('Missing required parameter: "number"') api_path = api_path.replace('{number}', str(self._normalize_value(number))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -851,7 +851,7 @@ def get_mock_phone( return self._parse_response(response, model=MockNumber) - def update_mock_phone( + async def update_mock_phone( self, number: str, otp: str, @@ -885,7 +885,7 @@ def update_mock_phone( api_path = api_path.replace('{number}', str(self._normalize_value(number))) api_params['otp'] = self._normalize_value(otp) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -898,7 +898,7 @@ def update_mock_phone( return self._parse_response(response, model=MockNumber) - def delete_mock_phone( + async def delete_mock_phone( self, number: str, ) -> Dict[str, Any]: @@ -926,7 +926,7 @@ def delete_mock_phone( raise AppwriteException('Missing required parameter: "number"') api_path = api_path.replace('{number}', str(self._normalize_value(number))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -939,7 +939,7 @@ def delete_mock_phone( return response - def list_o_auth2_providers( + async def list_o_auth2_providers( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -971,7 +971,7 @@ def list_o_auth2_providers( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -983,7 +983,7 @@ def list_o_auth2_providers( return self._parse_response(response, model=OAuth2ProviderList) - def update_o_auth2_server( + async def update_o_auth2_server( self, enabled: bool, authorization_url: str, @@ -1087,7 +1087,7 @@ def update_o_auth2_server( if installation_scopes is not None: api_params['installationScopes'] = self._normalize_value(installation_scopes) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1100,7 +1100,7 @@ def update_o_auth2_server( return self._parse_response(response, model=ProjectModel) - def update_o_auth2_amazon( + async def update_o_auth2_amazon( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1137,7 +1137,7 @@ def update_o_auth2_amazon( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1150,7 +1150,7 @@ def update_o_auth2_amazon( return self._parse_response(response, model=OAuth2Amazon) - def update_o_auth2_apple( + async def update_o_auth2_apple( self, service_id: Optional[str] = None, key_id: Optional[str] = None, @@ -1207,7 +1207,7 @@ def update_o_auth2_apple( if native_enabled is not None: api_params['nativeEnabled'] = self._normalize_value(native_enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1220,7 +1220,7 @@ def update_o_auth2_apple( return self._parse_response(response, model=OAuth2Apple) - def update_o_auth2_appwrite( + async def update_o_auth2_appwrite( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1257,7 +1257,7 @@ def update_o_auth2_appwrite( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1270,7 +1270,7 @@ def update_o_auth2_appwrite( return self._parse_response(response, model=OAuth2Appwrite) - def update_o_auth2_auth0( + async def update_o_auth2_auth0( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1317,7 +1317,7 @@ def update_o_auth2_auth0( if prompt is not None: api_params['prompt'] = self._normalize_value(prompt) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1330,7 +1330,7 @@ def update_o_auth2_auth0( return self._parse_response(response, model=OAuth2Auth0) - def update_o_auth2_authentik( + async def update_o_auth2_authentik( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1372,7 +1372,7 @@ def update_o_auth2_authentik( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1385,7 +1385,7 @@ def update_o_auth2_authentik( return self._parse_response(response, model=OAuth2Authentik) - def update_o_auth2_autodesk( + async def update_o_auth2_autodesk( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1422,7 +1422,7 @@ def update_o_auth2_autodesk( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1435,7 +1435,7 @@ def update_o_auth2_autodesk( return self._parse_response(response, model=OAuth2Autodesk) - def update_o_auth2_bitbucket( + async def update_o_auth2_bitbucket( self, key: Optional[str] = None, secret: Optional[str] = None, @@ -1472,7 +1472,7 @@ def update_o_auth2_bitbucket( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1485,7 +1485,7 @@ def update_o_auth2_bitbucket( return self._parse_response(response, model=OAuth2Bitbucket) - def update_o_auth2_bitly( + async def update_o_auth2_bitly( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1522,7 +1522,7 @@ def update_o_auth2_bitly( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1535,7 +1535,7 @@ def update_o_auth2_bitly( return self._parse_response(response, model=OAuth2Bitly) - def update_o_auth2_box( + async def update_o_auth2_box( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1572,7 +1572,7 @@ def update_o_auth2_box( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1585,7 +1585,7 @@ def update_o_auth2_box( return self._parse_response(response, model=OAuth2Box) - def update_o_auth2_cloudflare( + async def update_o_auth2_cloudflare( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1622,7 +1622,7 @@ def update_o_auth2_cloudflare( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1635,7 +1635,7 @@ def update_o_auth2_cloudflare( return self._parse_response(response, model=OAuth2Cloudflare) - def update_o_auth2_dailymotion( + async def update_o_auth2_dailymotion( self, api_key: Optional[str] = None, api_secret: Optional[str] = None, @@ -1672,7 +1672,7 @@ def update_o_auth2_dailymotion( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1685,7 +1685,7 @@ def update_o_auth2_dailymotion( return self._parse_response(response, model=OAuth2Dailymotion) - def update_o_auth2_discord( + async def update_o_auth2_discord( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1727,7 +1727,7 @@ def update_o_auth2_discord( if prompt is not None: api_params['prompt'] = self._normalize_value(prompt) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1740,7 +1740,7 @@ def update_o_auth2_discord( return self._parse_response(response, model=OAuth2Discord) - def update_o_auth2_disqus( + async def update_o_auth2_disqus( self, public_key: Optional[str] = None, secret_key: Optional[str] = None, @@ -1777,7 +1777,7 @@ def update_o_auth2_disqus( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1790,7 +1790,7 @@ def update_o_auth2_disqus( return self._parse_response(response, model=OAuth2Disqus) - def update_o_auth2_dropbox( + async def update_o_auth2_dropbox( self, app_key: Optional[str] = None, app_secret: Optional[str] = None, @@ -1827,7 +1827,7 @@ def update_o_auth2_dropbox( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1840,7 +1840,7 @@ def update_o_auth2_dropbox( return self._parse_response(response, model=OAuth2Dropbox) - def update_o_auth2_etsy( + async def update_o_auth2_etsy( self, key_string: Optional[str] = None, shared_secret: Optional[str] = None, @@ -1877,7 +1877,7 @@ def update_o_auth2_etsy( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1890,7 +1890,7 @@ def update_o_auth2_etsy( return self._parse_response(response, model=OAuth2Etsy) - def update_o_auth2_facebook( + async def update_o_auth2_facebook( self, app_id: Optional[str] = None, app_secret: Optional[str] = None, @@ -1927,7 +1927,7 @@ def update_o_auth2_facebook( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1940,7 +1940,7 @@ def update_o_auth2_facebook( return self._parse_response(response, model=OAuth2Facebook) - def update_o_auth2_figma( + async def update_o_auth2_figma( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -1977,7 +1977,7 @@ def update_o_auth2_figma( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1990,7 +1990,7 @@ def update_o_auth2_figma( return self._parse_response(response, model=OAuth2Figma) - def update_o_auth2_fusion_auth( + async def update_o_auth2_fusion_auth( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2032,7 +2032,7 @@ def update_o_auth2_fusion_auth( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2045,7 +2045,7 @@ def update_o_auth2_fusion_auth( return self._parse_response(response, model=OAuth2FusionAuth) - def update_o_auth2_git_hub( + async def update_o_auth2_git_hub( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2087,7 +2087,7 @@ def update_o_auth2_git_hub( if prompt is not None: api_params['prompt'] = self._normalize_value(prompt) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2100,7 +2100,7 @@ def update_o_auth2_git_hub( return self._parse_response(response, model=OAuth2Github) - def update_o_auth2_gitlab( + async def update_o_auth2_gitlab( self, application_id: Optional[str] = None, secret: Optional[str] = None, @@ -2142,7 +2142,7 @@ def update_o_auth2_gitlab( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2155,7 +2155,7 @@ def update_o_auth2_gitlab( return self._parse_response(response, model=OAuth2Gitlab) - def update_o_auth2_google( + async def update_o_auth2_google( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2207,7 +2207,7 @@ def update_o_auth2_google( if native_enabled is not None: api_params['nativeEnabled'] = self._normalize_value(native_enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2220,7 +2220,7 @@ def update_o_auth2_google( return self._parse_response(response, model=OAuth2Google) - def update_o_auth2_hugging_face( + async def update_o_auth2_hugging_face( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2257,7 +2257,7 @@ def update_o_auth2_hugging_face( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2270,7 +2270,7 @@ def update_o_auth2_hugging_face( return self._parse_response(response, model=OAuth2HuggingFace) - def update_o_auth2_kakao( + async def update_o_auth2_kakao( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2312,7 +2312,7 @@ def update_o_auth2_kakao( if prompt is not None: api_params['prompt'] = self._normalize_value(prompt) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2325,7 +2325,7 @@ def update_o_auth2_kakao( return self._parse_response(response, model=OAuth2Kakao) - def update_o_auth2_keycloak( + async def update_o_auth2_keycloak( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2372,7 +2372,7 @@ def update_o_auth2_keycloak( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2385,7 +2385,7 @@ def update_o_auth2_keycloak( return self._parse_response(response, model=OAuth2Keycloak) - def update_o_auth2_kick( + async def update_o_auth2_kick( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2422,7 +2422,7 @@ def update_o_auth2_kick( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2435,7 +2435,7 @@ def update_o_auth2_kick( return self._parse_response(response, model=OAuth2Kick) - def update_o_auth2_linkedin( + async def update_o_auth2_linkedin( self, client_id: Optional[str] = None, primary_client_secret: Optional[str] = None, @@ -2472,7 +2472,7 @@ def update_o_auth2_linkedin( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2485,7 +2485,7 @@ def update_o_auth2_linkedin( return self._parse_response(response, model=OAuth2Linkedin) - def update_o_auth2_microsoft( + async def update_o_auth2_microsoft( self, application_id: Optional[str] = None, application_secret: Optional[str] = None, @@ -2532,7 +2532,7 @@ def update_o_auth2_microsoft( if prompt is not None: api_params['prompt'] = self._normalize_value(prompt) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2545,7 +2545,7 @@ def update_o_auth2_microsoft( return self._parse_response(response, model=OAuth2Microsoft) - def update_o_auth2_notion( + async def update_o_auth2_notion( self, oauth_client_id: Optional[str] = None, oauth_client_secret: Optional[str] = None, @@ -2582,7 +2582,7 @@ def update_o_auth2_notion( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2595,7 +2595,7 @@ def update_o_auth2_notion( return self._parse_response(response, model=OAuth2Notion) - def update_o_auth2_oidc( + async def update_o_auth2_oidc( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2662,7 +2662,7 @@ def update_o_auth2_oidc( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2675,7 +2675,7 @@ def update_o_auth2_oidc( return self._parse_response(response, model=OAuth2Oidc) - def update_o_auth2_okta( + async def update_o_auth2_okta( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2727,7 +2727,7 @@ def update_o_auth2_okta( if prompt is not None: api_params['prompt'] = self._normalize_value(prompt) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2740,7 +2740,7 @@ def update_o_auth2_okta( return self._parse_response(response, model=OAuth2Okta) - def update_o_auth2_paypal( + async def update_o_auth2_paypal( self, client_id: Optional[str] = None, secret_key: Optional[str] = None, @@ -2777,7 +2777,7 @@ def update_o_auth2_paypal( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2790,7 +2790,7 @@ def update_o_auth2_paypal( return self._parse_response(response, model=OAuth2Paypal) - def update_o_auth2_paypal_sandbox( + async def update_o_auth2_paypal_sandbox( self, client_id: Optional[str] = None, secret_key: Optional[str] = None, @@ -2827,7 +2827,7 @@ def update_o_auth2_paypal_sandbox( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2840,7 +2840,7 @@ def update_o_auth2_paypal_sandbox( return self._parse_response(response, model=OAuth2Paypal) - def update_o_auth2_podio( + async def update_o_auth2_podio( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2877,7 +2877,7 @@ def update_o_auth2_podio( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2890,7 +2890,7 @@ def update_o_auth2_podio( return self._parse_response(response, model=OAuth2Podio) - def update_o_auth2_resend( + async def update_o_auth2_resend( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -2927,7 +2927,7 @@ def update_o_auth2_resend( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2940,7 +2940,7 @@ def update_o_auth2_resend( return self._parse_response(response, model=OAuth2Resend) - def update_o_auth2_salesforce( + async def update_o_auth2_salesforce( self, customer_key: Optional[str] = None, customer_secret: Optional[str] = None, @@ -2982,7 +2982,7 @@ def update_o_auth2_salesforce( if prompt is not None: api_params['prompt'] = self._normalize_value(prompt) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2995,7 +2995,7 @@ def update_o_auth2_salesforce( return self._parse_response(response, model=OAuth2Salesforce) - def update_o_auth2_slack( + async def update_o_auth2_slack( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3032,7 +3032,7 @@ def update_o_auth2_slack( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3045,7 +3045,7 @@ def update_o_auth2_slack( return self._parse_response(response, model=OAuth2Slack) - def update_o_auth2_spotify( + async def update_o_auth2_spotify( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3082,7 +3082,7 @@ def update_o_auth2_spotify( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3095,7 +3095,7 @@ def update_o_auth2_spotify( return self._parse_response(response, model=OAuth2Spotify) - def update_o_auth2_stripe( + async def update_o_auth2_stripe( self, client_id: Optional[str] = None, api_secret_key: Optional[str] = None, @@ -3132,7 +3132,7 @@ def update_o_auth2_stripe( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3145,7 +3145,7 @@ def update_o_auth2_stripe( return self._parse_response(response, model=OAuth2Stripe) - def update_o_auth2_tik_tok( + async def update_o_auth2_tik_tok( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3182,7 +3182,7 @@ def update_o_auth2_tik_tok( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3195,7 +3195,7 @@ def update_o_auth2_tik_tok( return self._parse_response(response, model=OAuth2TikTok) - def update_o_auth2_tradeshift( + async def update_o_auth2_tradeshift( self, oauth2_client_id: Optional[str] = None, oauth2_client_secret: Optional[str] = None, @@ -3232,7 +3232,7 @@ def update_o_auth2_tradeshift( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3245,7 +3245,7 @@ def update_o_auth2_tradeshift( return self._parse_response(response, model=OAuth2Tradeshift) - def update_o_auth2_tradeshift_sandbox( + async def update_o_auth2_tradeshift_sandbox( self, oauth2_client_id: Optional[str] = None, oauth2_client_secret: Optional[str] = None, @@ -3282,7 +3282,7 @@ def update_o_auth2_tradeshift_sandbox( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3295,7 +3295,7 @@ def update_o_auth2_tradeshift_sandbox( return self._parse_response(response, model=OAuth2Tradeshift) - def update_o_auth2_twitch( + async def update_o_auth2_twitch( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3332,7 +3332,7 @@ def update_o_auth2_twitch( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3345,7 +3345,7 @@ def update_o_auth2_twitch( return self._parse_response(response, model=OAuth2Twitch) - def update_o_auth2_webflow( + async def update_o_auth2_webflow( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3382,7 +3382,7 @@ def update_o_auth2_webflow( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3395,7 +3395,7 @@ def update_o_auth2_webflow( return self._parse_response(response, model=OAuth2Webflow) - def update_o_auth2_word_press( + async def update_o_auth2_word_press( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3432,7 +3432,7 @@ def update_o_auth2_word_press( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3445,7 +3445,7 @@ def update_o_auth2_word_press( return self._parse_response(response, model=OAuth2WordPress) - def update_o_auth2_x( + async def update_o_auth2_x( self, customer_key: Optional[str] = None, secret_key: Optional[str] = None, @@ -3482,7 +3482,7 @@ def update_o_auth2_x( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3495,7 +3495,7 @@ def update_o_auth2_x( return self._parse_response(response, model=OAuth2X) - def update_o_auth2_yahoo( + async def update_o_auth2_yahoo( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3532,7 +3532,7 @@ def update_o_auth2_yahoo( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3545,7 +3545,7 @@ def update_o_auth2_yahoo( return self._parse_response(response, model=OAuth2Yahoo) - def update_o_auth2_yandex( + async def update_o_auth2_yandex( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3582,7 +3582,7 @@ def update_o_auth2_yandex( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3595,7 +3595,7 @@ def update_o_auth2_yandex( return self._parse_response(response, model=OAuth2Yandex) - def update_o_auth2_zoho( + async def update_o_auth2_zoho( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3637,7 +3637,7 @@ def update_o_auth2_zoho( if prompt is not None: api_params['prompt'] = self._normalize_value(prompt) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3650,7 +3650,7 @@ def update_o_auth2_zoho( return self._parse_response(response, model=OAuth2Zoho) - def update_o_auth2_zoom( + async def update_o_auth2_zoom( self, client_id: Optional[str] = None, client_secret: Optional[str] = None, @@ -3687,7 +3687,7 @@ def update_o_auth2_zoom( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3700,7 +3700,7 @@ def update_o_auth2_zoom( return self._parse_response(response, model=OAuth2Zoom) - def get_o_auth2_provider( + async def get_o_auth2_provider( self, provider_id: ProjectOAuthProviderId, ) -> Union[ @@ -3775,7 +3775,7 @@ def get_o_auth2_provider( raise AppwriteException('Missing required parameter: "provider_id"') api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -3927,7 +3927,7 @@ def get_o_auth2_provider( raise AppwriteException('Unable to match response to any known model') - def list_platforms( + async def list_platforms( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -3959,7 +3959,7 @@ def list_platforms( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -3971,7 +3971,7 @@ def list_platforms( return self._parse_response(response, model=PlatformList) - def create_android_platform( + async def create_android_platform( self, platform_id: str, name: str, @@ -4016,7 +4016,7 @@ def create_android_platform( if fingerprints is not None: api_params['fingerprints'] = self._normalize_value(fingerprints) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4029,7 +4029,7 @@ def create_android_platform( return self._parse_response(response, model=PlatformAndroid) - def update_android_platform( + async def update_android_platform( self, platform_id: str, name: str, @@ -4074,7 +4074,7 @@ def update_android_platform( if fingerprints is not None: api_params['fingerprints'] = self._normalize_value(fingerprints) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -4087,7 +4087,7 @@ def update_android_platform( return self._parse_response(response, model=PlatformAndroid) - def create_apple_platform( + async def create_apple_platform( self, platform_id: str, name: str, @@ -4127,7 +4127,7 @@ def create_apple_platform( api_params['name'] = self._normalize_value(name) api_params['bundleIdentifier'] = self._normalize_value(bundle_identifier) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4140,7 +4140,7 @@ def create_apple_platform( return self._parse_response(response, model=PlatformApple) - def update_apple_platform( + async def update_apple_platform( self, platform_id: str, name: str, @@ -4180,7 +4180,7 @@ def update_apple_platform( api_params['name'] = self._normalize_value(name) api_params['bundleIdentifier'] = self._normalize_value(bundle_identifier) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -4193,7 +4193,7 @@ def update_apple_platform( return self._parse_response(response, model=PlatformApple) - def create_linux_platform( + async def create_linux_platform( self, platform_id: str, name: str, @@ -4233,7 +4233,7 @@ def create_linux_platform( api_params['name'] = self._normalize_value(name) api_params['packageName'] = self._normalize_value(package_name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4246,7 +4246,7 @@ def create_linux_platform( return self._parse_response(response, model=PlatformLinux) - def update_linux_platform( + async def update_linux_platform( self, platform_id: str, name: str, @@ -4286,7 +4286,7 @@ def update_linux_platform( api_params['name'] = self._normalize_value(name) api_params['packageName'] = self._normalize_value(package_name) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -4299,7 +4299,7 @@ def update_linux_platform( return self._parse_response(response, model=PlatformLinux) - def create_web_platform( + async def create_web_platform( self, platform_id: str, name: str, @@ -4339,7 +4339,7 @@ def create_web_platform( api_params['name'] = self._normalize_value(name) api_params['hostname'] = self._normalize_value(hostname) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4352,7 +4352,7 @@ def create_web_platform( return self._parse_response(response, model=PlatformWeb) - def update_web_platform( + async def update_web_platform( self, platform_id: str, name: str, @@ -4392,7 +4392,7 @@ def update_web_platform( api_params['name'] = self._normalize_value(name) api_params['hostname'] = self._normalize_value(hostname) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -4405,7 +4405,7 @@ def update_web_platform( return self._parse_response(response, model=PlatformWeb) - def create_windows_platform( + async def create_windows_platform( self, platform_id: str, name: str, @@ -4445,7 +4445,7 @@ def create_windows_platform( api_params['name'] = self._normalize_value(name) api_params['packageIdentifierName'] = self._normalize_value(package_identifier_name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4458,7 +4458,7 @@ def create_windows_platform( return self._parse_response(response, model=PlatformWindows) - def update_windows_platform( + async def update_windows_platform( self, platform_id: str, name: str, @@ -4498,7 +4498,7 @@ def update_windows_platform( api_params['name'] = self._normalize_value(name) api_params['packageIdentifierName'] = self._normalize_value(package_identifier_name) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -4511,7 +4511,7 @@ def update_windows_platform( return self._parse_response(response, model=PlatformWindows) - def get_platform( + async def get_platform( self, platform_id: str, ) -> Union[ @@ -4545,7 +4545,7 @@ def get_platform( raise AppwriteException('Missing required parameter: "platform_id"') api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -4574,7 +4574,7 @@ def get_platform( raise AppwriteException('Unable to match response to any known model') - def delete_platform( + async def delete_platform( self, platform_id: str, ) -> Dict[str, Any]: @@ -4602,7 +4602,7 @@ def delete_platform( raise AppwriteException('Missing required parameter: "platform_id"') api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -4615,7 +4615,7 @@ def delete_platform( return response - def list_policies( + async def list_policies( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -4647,7 +4647,7 @@ def list_policies( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -4659,7 +4659,7 @@ def list_policies( return self._parse_response(response, model=PolicyList) - def update_deny_aliased_email_policy( + async def update_deny_aliased_email_policy( self, enabled: bool, ) -> ProjectModel: @@ -4687,7 +4687,7 @@ def update_deny_aliased_email_policy( raise AppwriteException('Missing required parameter: "enabled"') api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4700,7 +4700,7 @@ def update_deny_aliased_email_policy( return self._parse_response(response, model=ProjectModel) - def update_deny_corporate_email_policy( + async def update_deny_corporate_email_policy( self, enabled: bool, ) -> ProjectModel: @@ -4728,7 +4728,7 @@ def update_deny_corporate_email_policy( raise AppwriteException('Missing required parameter: "enabled"') api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4741,7 +4741,7 @@ def update_deny_corporate_email_policy( return self._parse_response(response, model=ProjectModel) - def update_deny_disposable_email_policy( + async def update_deny_disposable_email_policy( self, enabled: bool, ) -> ProjectModel: @@ -4769,7 +4769,7 @@ def update_deny_disposable_email_policy( raise AppwriteException('Missing required parameter: "enabled"') api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4782,7 +4782,7 @@ def update_deny_disposable_email_policy( return self._parse_response(response, model=ProjectModel) - def update_deny_free_email_policy( + async def update_deny_free_email_policy( self, enabled: bool, ) -> ProjectModel: @@ -4810,7 +4810,7 @@ def update_deny_free_email_policy( raise AppwriteException('Missing required parameter: "enabled"') api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4823,7 +4823,7 @@ def update_deny_free_email_policy( return self._parse_response(response, model=ProjectModel) - def update_membership_privacy_policy( + async def update_membership_privacy_policy( self, user_id: Optional[bool] = None, user_email: Optional[bool] = None, @@ -4875,7 +4875,7 @@ def update_membership_privacy_policy( if user_accessed_at is not None: api_params['userAccessedAt'] = self._normalize_value(user_accessed_at) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4888,7 +4888,7 @@ def update_membership_privacy_policy( return self._parse_response(response, model=ProjectModel) - def update_mfa_factors_policy( + async def update_mfa_factors_policy( self, totp: Optional[bool] = None, email: Optional[bool] = None, @@ -4930,7 +4930,7 @@ def update_mfa_factors_policy( if custom is not None: api_params['custom'] = self._normalize_value(custom) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4943,7 +4943,7 @@ def update_mfa_factors_policy( return self._parse_response(response, model=ProjectModel) - def update_passkey_policy( + async def update_passkey_policy( self, rp_id: str, ) -> ProjectModel: @@ -4971,7 +4971,7 @@ def update_passkey_policy( raise AppwriteException('Missing required parameter: "rp_id"') api_params['rpId'] = self._normalize_value(rp_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4984,7 +4984,7 @@ def update_passkey_policy( return self._parse_response(response, model=ProjectModel) - def update_password_dictionary_policy( + async def update_password_dictionary_policy( self, enabled: bool, deny_list: Optional[List[str]] = None, @@ -5019,7 +5019,7 @@ def update_password_dictionary_policy( if deny_list is not None: api_params['denyList'] = self._normalize_value(deny_list) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5032,7 +5032,7 @@ def update_password_dictionary_policy( return self._parse_response(response, model=ProjectModel) - def update_password_history_policy( + async def update_password_history_policy( self, total: Optional[float], ) -> ProjectModel: @@ -5060,7 +5060,7 @@ def update_password_history_policy( api_params = {} api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5073,7 +5073,7 @@ def update_password_history_policy( return self._parse_response(response, model=ProjectModel) - def update_password_personal_data_policy( + async def update_password_personal_data_policy( self, enabled: bool, deny_list: Optional[List[str]] = None, @@ -5109,7 +5109,7 @@ def update_password_personal_data_policy( if deny_list is not None: api_params['denyList'] = self._normalize_value(deny_list) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5122,7 +5122,7 @@ def update_password_personal_data_policy( return self._parse_response(response, model=ProjectModel) - def update_password_pwned_policy( + async def update_password_pwned_policy( self, enabled: Optional[bool] = None, sessions: Optional[bool] = None, @@ -5159,7 +5159,7 @@ def update_password_pwned_policy( if users is not None: api_params['users'] = self._normalize_value(users) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5172,7 +5172,7 @@ def update_password_pwned_policy( return self._parse_response(response, model=ProjectModel) - def update_password_rotation_policy( + async def update_password_rotation_policy( self, enabled: Optional[bool] = None, max_age: Optional[float] = None, @@ -5204,7 +5204,7 @@ def update_password_rotation_policy( if max_age is not None: api_params['maxAge'] = self._normalize_value(max_age) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5217,7 +5217,7 @@ def update_password_rotation_policy( return self._parse_response(response, model=ProjectModel) - def update_password_strength_policy( + async def update_password_strength_policy( self, min: Optional[float] = None, uppercase: Optional[bool] = None, @@ -5264,7 +5264,7 @@ def update_password_strength_policy( if symbols is not None: api_params['symbols'] = self._normalize_value(symbols) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5277,7 +5277,7 @@ def update_password_strength_policy( return self._parse_response(response, model=PolicyPasswordStrength) - def update_session_alert_policy( + async def update_session_alert_policy( self, enabled: bool, ) -> ProjectModel: @@ -5305,7 +5305,7 @@ def update_session_alert_policy( raise AppwriteException('Missing required parameter: "enabled"') api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5318,7 +5318,7 @@ def update_session_alert_policy( return self._parse_response(response, model=ProjectModel) - def update_session_duration_policy( + async def update_session_duration_policy( self, duration: float, ) -> ProjectModel: @@ -5346,7 +5346,7 @@ def update_session_duration_policy( raise AppwriteException('Missing required parameter: "duration"') api_params['duration'] = self._normalize_value(duration) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5359,7 +5359,7 @@ def update_session_duration_policy( return self._parse_response(response, model=ProjectModel) - def update_session_invalidation_policy( + async def update_session_invalidation_policy( self, enabled: bool, ) -> ProjectModel: @@ -5387,7 +5387,7 @@ def update_session_invalidation_policy( raise AppwriteException('Missing required parameter: "enabled"') api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5400,7 +5400,7 @@ def update_session_invalidation_policy( return self._parse_response(response, model=ProjectModel) - def update_session_limit_policy( + async def update_session_limit_policy( self, total: float, ) -> ProjectModel: @@ -5428,7 +5428,7 @@ def update_session_limit_policy( raise AppwriteException('Missing required parameter: "total"') api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5441,7 +5441,7 @@ def update_session_limit_policy( return self._parse_response(response, model=ProjectModel) - def update_user_limit_policy( + async def update_user_limit_policy( self, total: Optional[float], ) -> ProjectModel: @@ -5467,7 +5467,7 @@ def update_user_limit_policy( api_params = {} api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5480,7 +5480,7 @@ def update_user_limit_policy( return self._parse_response(response, model=ProjectModel) - def get_policy( + async def get_policy( self, policy_id: ProjectPolicyId, ) -> Union[ @@ -5527,7 +5527,7 @@ def get_policy( raise AppwriteException('Missing required parameter: "policy_id"') api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -5595,7 +5595,7 @@ def get_policy( raise AppwriteException('Unable to match response to any known model') - def update_protocol( + async def update_protocol( self, protocol_id: ProjectProtocolId, enabled: bool, @@ -5629,7 +5629,7 @@ def update_protocol( api_path = api_path.replace('{protocolId}', str(self._normalize_value(protocol_id))) api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5642,7 +5642,7 @@ def update_protocol( return self._parse_response(response, model=ProjectModel) - def update_service( + async def update_service( self, service_id: ProjectServiceId, enabled: bool, @@ -5676,7 +5676,7 @@ def update_service( api_path = api_path.replace('{serviceId}', str(self._normalize_value(service_id))) api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5689,7 +5689,7 @@ def update_service( return self._parse_response(response, model=ProjectModel) - def update_smtp( + async def update_smtp( self, host: Optional[str] = None, port: Optional[float] = None, @@ -5761,7 +5761,7 @@ def update_smtp( if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5774,7 +5774,7 @@ def update_smtp( return self._parse_response(response, model=ProjectModel) - def create_smtp_test( + async def create_smtp_test( self, emails: List[str], ) -> Dict[str, Any]: @@ -5802,7 +5802,7 @@ def create_smtp_test( raise AppwriteException('Missing required parameter: "emails"') api_params['emails'] = self._normalize_value(emails) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -5815,7 +5815,7 @@ def create_smtp_test( return response - def list_email_templates( + async def list_email_templates( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -5847,7 +5847,7 @@ def list_email_templates( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -5859,7 +5859,7 @@ def list_email_templates( return self._parse_response(response, model=EmailTemplateList) - def update_email_template( + async def update_email_template( self, template_id: ProjectEmailTemplateId, locale: Optional[ProjectEmailTemplateLocale] = None, @@ -5922,7 +5922,7 @@ def update_email_template( if reply_to_name is not None: api_params['replyToName'] = self._normalize_value(reply_to_name) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5935,7 +5935,7 @@ def update_email_template( return self._parse_response(response, model=EmailTemplate) - def get_email_template( + async def get_email_template( self, template_id: ProjectEmailTemplateId, locale: Optional[ProjectEmailTemplateLocale] = None, @@ -5968,7 +5968,7 @@ def get_email_template( if locale is not None: api_params['locale'] = self._normalize_value(locale) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -5980,7 +5980,7 @@ def get_email_template( return self._parse_response(response, model=EmailTemplate) - def list_variables( + async def list_variables( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -6012,7 +6012,7 @@ def list_variables( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -6024,7 +6024,7 @@ def list_variables( return self._parse_response(response, model=VariableList) - def create_variable( + async def create_variable( self, variable_id: str, key: str, @@ -6074,7 +6074,7 @@ def create_variable( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -6087,7 +6087,7 @@ def create_variable( return self._parse_response(response, model=Variable) - def get_variable( + async def get_variable( self, variable_id: str, ) -> Variable: @@ -6115,7 +6115,7 @@ def get_variable( raise AppwriteException('Missing required parameter: "variable_id"') api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -6127,7 +6127,7 @@ def get_variable( return self._parse_response(response, model=Variable) - def update_variable( + async def update_variable( self, variable_id: str, key: Optional[str] = None, @@ -6175,7 +6175,7 @@ def update_variable( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -6188,7 +6188,7 @@ def update_variable( return self._parse_response(response, model=Variable) - def delete_variable( + async def delete_variable( self, variable_id: str, ) -> Dict[str, Any]: @@ -6216,7 +6216,7 @@ def delete_variable( raise AppwriteException('Missing required parameter: "variable_id"') api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/proxy.py b/appwrite/services/proxy.py index 5f4e5c68..3f50e593 100644 --- a/appwrite/services/proxy.py +++ b/appwrite/services/proxy.py @@ -16,7 +16,7 @@ class Proxy(Service): def __init__(self, client) -> None: super(Proxy, self).__init__(client) - def create_invalidation( + async def create_invalidation( self, domain: str, type: InvalidationType, @@ -59,7 +59,7 @@ def create_invalidation( if reference is not None: api_params['reference'] = self._normalize_value(reference) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -72,7 +72,7 @@ def create_invalidation( return self._parse_response(response, model=ProxyInvalidation) - def list_rules( + async def list_rules( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -104,7 +104,7 @@ def list_rules( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -116,7 +116,7 @@ def list_rules( return self._parse_response(response, model=ProxyRuleList) - def create_api_rule( + async def create_api_rule( self, domain: str, ) -> ProxyRule: @@ -146,7 +146,7 @@ def create_api_rule( raise AppwriteException('Missing required parameter: "domain"') api_params['domain'] = self._normalize_value(domain) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -159,7 +159,7 @@ def create_api_rule( return self._parse_response(response, model=ProxyRule) - def create_function_rule( + async def create_function_rule( self, domain: str, function_id: str, @@ -200,7 +200,7 @@ def create_function_rule( if branch is not None: api_params['branch'] = self._normalize_value(branch) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -213,7 +213,7 @@ def create_function_rule( return self._parse_response(response, model=ProxyRule) - def create_redirect_rule( + async def create_redirect_rule( self, domain: str, url: str, @@ -267,7 +267,7 @@ def create_redirect_rule( api_params['resourceId'] = self._normalize_value(resource_id) api_params['resourceType'] = self._normalize_value(resource_type) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -280,7 +280,7 @@ def create_redirect_rule( return self._parse_response(response, model=ProxyRule) - def create_site_rule( + async def create_site_rule( self, domain: str, site_id: str, @@ -321,7 +321,7 @@ def create_site_rule( if branch is not None: api_params['branch'] = self._normalize_value(branch) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -334,7 +334,7 @@ def create_site_rule( return self._parse_response(response, model=ProxyRule) - def create_smtp_rule( + async def create_smtp_rule( self, domain: str, function_id: str, @@ -373,7 +373,7 @@ def create_smtp_rule( if branch is not None: api_params['branch'] = self._normalize_value(branch) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -386,7 +386,7 @@ def create_smtp_rule( return self._parse_response(response, model=ProxyRule) - def get_rule( + async def get_rule( self, rule_id: str, ) -> ProxyRule: @@ -414,7 +414,7 @@ def get_rule( raise AppwriteException('Missing required parameter: "rule_id"') api_path = api_path.replace('{ruleId}', str(self._normalize_value(rule_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -426,7 +426,7 @@ def get_rule( return self._parse_response(response, model=ProxyRule) - def delete_rule( + async def delete_rule( self, rule_id: str, ) -> Dict[str, Any]: @@ -454,7 +454,7 @@ def delete_rule( raise AppwriteException('Missing required parameter: "rule_id"') api_path = api_path.replace('{ruleId}', str(self._normalize_value(rule_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -467,7 +467,7 @@ def delete_rule( return response - def update_rule_status( + async def update_rule_status( self, rule_id: str, ) -> ProxyRule: @@ -495,7 +495,7 @@ def update_rule_status( raise AppwriteException('Missing required parameter: "rule_id"') api_path = api_path.replace('{ruleId}', str(self._normalize_value(rule_id))) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index f3320934..2c8fed21 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -28,7 +28,7 @@ class Sites(Service): def __init__(self, client) -> None: super(Sites, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -65,7 +65,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -77,7 +77,7 @@ def list( return self._parse_response(response, model=SiteList) - def create( + async def create( self, site_id: str, name: str, @@ -228,7 +228,7 @@ def create( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -241,7 +241,7 @@ def create( return self._parse_response(response, model=Site) - def list_frameworks( + async def list_frameworks( self, total: Optional[bool] = None, ) -> FrameworkList: @@ -268,7 +268,7 @@ def list_frameworks( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -280,7 +280,7 @@ def list_frameworks( return self._parse_response(response, model=FrameworkList) - def list_specifications( + async def list_specifications( self, type: Optional[str] = None, total: Optional[bool] = None, @@ -312,7 +312,7 @@ def list_specifications( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -324,7 +324,7 @@ def list_specifications( return self._parse_response(response, model=SpecificationList) - def get( + async def get( self, site_id: str, ) -> Site: @@ -352,7 +352,7 @@ def get( raise AppwriteException('Missing required parameter: "site_id"') api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -364,7 +364,7 @@ def get( return self._parse_response(response, model=Site) - def update( + async def update( self, site_id: str, name: str, @@ -514,7 +514,7 @@ def update( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -527,7 +527,7 @@ def update( return self._parse_response(response, model=Site) - def delete( + async def delete( self, site_id: str, ) -> Dict[str, Any]: @@ -555,7 +555,7 @@ def delete( raise AppwriteException('Missing required parameter: "site_id"') api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -568,7 +568,7 @@ def delete( return response - def update_site_deployment( + async def update_site_deployment( self, site_id: str, deployment_id: str, @@ -602,7 +602,7 @@ def update_site_deployment( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_params['deploymentId'] = self._normalize_value(deployment_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -615,7 +615,7 @@ def update_site_deployment( return self._parse_response(response, model=Site) - def list_deployments( + async def list_deployments( self, site_id: str, queries: Optional[List[str]] = None, @@ -658,7 +658,7 @@ def list_deployments( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -670,7 +670,7 @@ def list_deployments( return self._parse_response(response, model=DeploymentList) - def create_deployment( + async def create_deployment( self, site_id: str, code: InputFile, @@ -734,7 +734,7 @@ def create_deployment( upload_id = '' - response = self.client.chunked_upload( + response = await self.client.chunked_upload( api_path, { 'X-Appwrite-Project': self.client.get_config('project'), @@ -750,7 +750,7 @@ def create_deployment( return self._parse_response(response, model=Deployment) - def create_duplicate_deployment( + async def create_duplicate_deployment( self, site_id: str, deployment_id: str, @@ -784,7 +784,7 @@ def create_duplicate_deployment( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_params['deploymentId'] = self._normalize_value(deployment_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -797,7 +797,7 @@ def create_duplicate_deployment( return self._parse_response(response, model=Deployment) - def create_template_deployment( + async def create_template_deployment( self, site_id: str, repository: str, @@ -862,7 +862,7 @@ def create_template_deployment( if activate is not None: api_params['activate'] = self._normalize_value(activate) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -875,7 +875,7 @@ def create_template_deployment( return self._parse_response(response, model=Deployment) - def create_vcs_deployment( + async def create_vcs_deployment( self, site_id: str, type: VCSReferenceType, @@ -922,7 +922,7 @@ def create_vcs_deployment( if activate is not None: api_params['activate'] = self._normalize_value(activate) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -935,7 +935,7 @@ def create_vcs_deployment( return self._parse_response(response, model=Deployment) - def get_deployment( + async def get_deployment( self, site_id: str, deployment_id: str, @@ -969,7 +969,7 @@ def get_deployment( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -981,7 +981,7 @@ def get_deployment( return self._parse_response(response, model=Deployment) - def delete_deployment( + async def delete_deployment( self, site_id: str, deployment_id: str, @@ -1015,7 +1015,7 @@ def delete_deployment( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1028,7 +1028,7 @@ def delete_deployment( return response - def get_deployment_download( + async def get_deployment_download( self, site_id: str, deployment_id: str, @@ -1072,7 +1072,7 @@ def get_deployment_download( if token is not None: api_params['token'] = self._normalize_value(token) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1084,7 +1084,7 @@ def get_deployment_download( return response - def update_deployment_status( + async def update_deployment_status( self, site_id: str, deployment_id: str, @@ -1118,7 +1118,7 @@ def update_deployment_status( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1131,7 +1131,7 @@ def update_deployment_status( return self._parse_response(response, model=Deployment) - def list_logs( + async def list_logs( self, site_id: str, queries: Optional[List[str]] = None, @@ -1169,7 +1169,7 @@ def list_logs( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1181,7 +1181,7 @@ def list_logs( return self._parse_response(response, model=ExecutionList) - def get_log( + async def get_log( self, site_id: str, log_id: str, @@ -1215,7 +1215,7 @@ def get_log( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_path = api_path.replace('{logId}', str(self._normalize_value(log_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1227,7 +1227,7 @@ def get_log( return self._parse_response(response, model=Execution) - def delete_log( + async def delete_log( self, site_id: str, log_id: str, @@ -1261,7 +1261,7 @@ def delete_log( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_path = api_path.replace('{logId}', str(self._normalize_value(log_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1274,7 +1274,7 @@ def delete_log( return response - def list_variables( + async def list_variables( self, site_id: str, queries: Optional[List[str]] = None, @@ -1312,7 +1312,7 @@ def list_variables( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1324,7 +1324,7 @@ def list_variables( return self._parse_response(response, model=VariableList) - def create_variable( + async def create_variable( self, site_id: str, variable_id: str, @@ -1380,7 +1380,7 @@ def create_variable( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1393,7 +1393,7 @@ def create_variable( return self._parse_response(response, model=Variable) - def get_variable( + async def get_variable( self, site_id: str, variable_id: str, @@ -1427,7 +1427,7 @@ def get_variable( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1439,7 +1439,7 @@ def get_variable( return self._parse_response(response, model=Variable) - def update_variable( + async def update_variable( self, site_id: str, variable_id: str, @@ -1493,7 +1493,7 @@ def update_variable( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1506,7 +1506,7 @@ def update_variable( return self._parse_response(response, model=Variable) - def delete_variable( + async def delete_variable( self, site_id: str, variable_id: str, @@ -1540,7 +1540,7 @@ def delete_variable( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index 2981f526..0245fe07 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -18,7 +18,7 @@ class Storage(Service): def __init__(self, client) -> None: super(Storage, self).__init__(client) - def list_buckets( + async def list_buckets( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -55,7 +55,7 @@ def list_buckets( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -67,7 +67,7 @@ def list_buckets( return self._parse_response(response, model=BucketList) - def create_bucket( + async def create_bucket( self, bucket_id: str, name: str, @@ -156,7 +156,7 @@ def create_bucket( if strip_metadata is not None: api_params['stripMetadata'] = self._normalize_value(strip_metadata) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -169,7 +169,7 @@ def create_bucket( return self._parse_response(response, model=Bucket) - def get_bucket( + async def get_bucket( self, bucket_id: str, ) -> Bucket: @@ -197,7 +197,7 @@ def get_bucket( raise AppwriteException('Missing required parameter: "bucket_id"') api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -209,7 +209,7 @@ def get_bucket( return self._parse_response(response, model=Bucket) - def update_bucket( + async def update_bucket( self, bucket_id: str, name: str, @@ -298,7 +298,7 @@ def update_bucket( if strip_metadata is not None: api_params['stripMetadata'] = self._normalize_value(strip_metadata) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -311,7 +311,7 @@ def update_bucket( return self._parse_response(response, model=Bucket) - def delete_bucket( + async def delete_bucket( self, bucket_id: str, ) -> Dict[str, Any]: @@ -339,7 +339,7 @@ def delete_bucket( raise AppwriteException('Missing required parameter: "bucket_id"') api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -352,7 +352,7 @@ def delete_bucket( return response - def list_files( + async def list_files( self, bucket_id: str, queries: Optional[List[str]] = None, @@ -395,7 +395,7 @@ def list_files( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -407,7 +407,7 @@ def list_files( return self._parse_response(response, model=FileList) - def create_file( + async def create_file( self, bucket_id: str, file_id: str, @@ -472,7 +472,7 @@ def create_file( upload_id = '' upload_id = file_id - response = self.client.chunked_upload( + response = await self.client.chunked_upload( api_path, { 'X-Appwrite-Project': self.client.get_config('project'), @@ -488,7 +488,7 @@ def create_file( return self._parse_response(response, model=File) - def get_file( + async def get_file( self, bucket_id: str, file_id: str, @@ -522,7 +522,7 @@ def get_file( api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -534,7 +534,7 @@ def get_file( return self._parse_response(response, model=File) - def update_file( + async def update_file( self, bucket_id: str, file_id: str, @@ -578,7 +578,7 @@ def update_file( if permissions is not None: api_params['permissions'] = self._normalize_value(permissions) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -591,7 +591,7 @@ def update_file( return self._parse_response(response, model=File) - def delete_file( + async def delete_file( self, bucket_id: str, file_id: str, @@ -625,7 +625,7 @@ def delete_file( api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -638,7 +638,7 @@ def delete_file( return response - def get_file_download( + async def get_file_download( self, bucket_id: str, file_id: str, @@ -677,7 +677,7 @@ def get_file_download( if token is not None: api_params['token'] = self._normalize_value(token) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -689,7 +689,7 @@ def get_file_download( return response - def get_file_preview( + async def get_file_preview( self, bucket_id: str, file_id: str, @@ -783,7 +783,7 @@ def get_file_preview( if token is not None: api_params['token'] = self._normalize_value(token) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -795,7 +795,7 @@ def get_file_preview( return response - def get_file_view( + async def get_file_view( self, bucket_id: str, file_id: str, @@ -834,7 +834,7 @@ def get_file_view( if token is not None: api_params['token'] = self._normalize_value(token) - response = self.client.call( + response = await self.client.call( 'get', api_path, { diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index 19f181a5..da8fa180 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -52,7 +52,7 @@ class TablesDB(Service): def __init__(self, client) -> None: super(TablesDB, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -89,7 +89,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -101,7 +101,7 @@ def list( return self._parse_response(response, model=DatabaseList) - def create( + async def create( self, database_id: str, name: str, @@ -160,7 +160,7 @@ def create( if sync_mode is not None: api_params['syncMode'] = self._normalize_value(sync_mode) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -173,7 +173,7 @@ def create( return self._parse_response(response, model=Database) - def list_specifications( + async def list_specifications( self, ) -> DedicatedDatabaseSpecificationList: """ @@ -192,7 +192,7 @@ def list_specifications( api_path = '/tablesdb/specifications' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -204,7 +204,7 @@ def list_specifications( return self._parse_response(response, model=DedicatedDatabaseSpecificationList) - def list_transactions( + async def list_transactions( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -236,7 +236,7 @@ def list_transactions( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -248,7 +248,7 @@ def list_transactions( return self._parse_response(response, model=TransactionList) - def create_transaction( + async def create_transaction( self, ttl: Optional[float] = None, ) -> Transaction: @@ -275,7 +275,7 @@ def create_transaction( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -288,7 +288,7 @@ def create_transaction( return self._parse_response(response, model=Transaction) - def get_transaction( + async def get_transaction( self, transaction_id: str, ) -> Transaction: @@ -316,7 +316,7 @@ def get_transaction( raise AppwriteException('Missing required parameter: "transaction_id"') api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -328,7 +328,7 @@ def get_transaction( return self._parse_response(response, model=Transaction) - def update_transaction( + async def update_transaction( self, transaction_id: str, commit: Optional[bool] = None, @@ -366,7 +366,7 @@ def update_transaction( if rollback is not None: api_params['rollback'] = self._normalize_value(rollback) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -379,7 +379,7 @@ def update_transaction( return self._parse_response(response, model=Transaction) - def delete_transaction( + async def delete_transaction( self, transaction_id: str, ) -> Dict[str, Any]: @@ -407,7 +407,7 @@ def delete_transaction( raise AppwriteException('Missing required parameter: "transaction_id"') api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -420,7 +420,7 @@ def delete_transaction( return response - def create_operations( + async def create_operations( self, transaction_id: str, operations: Optional[List[Dict[str, Any]]] = None, @@ -453,7 +453,7 @@ def create_operations( if operations is not None: api_params['operations'] = self._normalize_value(operations) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -466,7 +466,7 @@ def create_operations( return self._parse_response(response, model=Transaction) - def get( + async def get( self, database_id: str, ) -> Database: @@ -494,7 +494,7 @@ def get( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -506,7 +506,7 @@ def get( return self._parse_response(response, model=Database) - def update( + async def update( self, database_id: str, name: Optional[str] = None, @@ -564,7 +564,7 @@ def update( if sync_mode is not None: api_params['syncMode'] = self._normalize_value(sync_mode) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -577,7 +577,7 @@ def update( return self._parse_response(response, model=Database) - def delete( + async def delete( self, database_id: str, ) -> Dict[str, Any]: @@ -605,7 +605,7 @@ def delete( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -618,7 +618,7 @@ def delete( return response - def create_failover( + async def create_failover( self, database_id: str, target_replica_id: Optional[str] = None, @@ -651,7 +651,7 @@ def create_failover( if target_replica_id is not None: api_params['targetReplicaId'] = self._normalize_value(target_replica_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -664,7 +664,7 @@ def create_failover( return self._parse_response(response, model=DedicatedDatabase) - def list_migrations( + async def list_migrations( self, database_id: str, ) -> DatabaseMigrationList: @@ -692,7 +692,7 @@ def list_migrations( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -704,7 +704,7 @@ def list_migrations( return self._parse_response(response, model=DatabaseMigrationList) - def create_migration( + async def create_migration( self, database_id: str, specification: str, @@ -743,7 +743,7 @@ def create_migration( if auto_cutover is not None: api_params['autoCutover'] = self._normalize_value(auto_cutover) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -756,7 +756,7 @@ def create_migration( return self._parse_response(response, model=DatabaseMigration) - def get_migration( + async def get_migration( self, database_id: str, migration_id: str, @@ -790,7 +790,7 @@ def get_migration( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{migrationId}', str(self._normalize_value(migration_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -802,7 +802,7 @@ def get_migration( return self._parse_response(response, model=DatabaseMigration) - def delete_migration( + async def delete_migration( self, database_id: str, migration_id: str, @@ -836,7 +836,7 @@ def delete_migration( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{migrationId}', str(self._normalize_value(migration_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -849,7 +849,7 @@ def delete_migration( return response - def create_cutover( + async def create_cutover( self, database_id: str, migration_id: str, @@ -883,7 +883,7 @@ def create_cutover( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{migrationId}', str(self._normalize_value(migration_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -896,7 +896,7 @@ def create_cutover( return self._parse_response(response, model=DatabaseMigration) - def list_operations( + async def list_operations( self, database_id: str, status: Optional[str] = None, @@ -939,7 +939,7 @@ def list_operations( if offset is not None: api_params['offset'] = self._normalize_value(offset) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -951,7 +951,7 @@ def list_operations( return self._parse_response(response, model=DedicatedDatabaseOperationList) - def get_replicas( + async def get_replicas( self, database_id: str, ) -> DedicatedDatabaseReplicas: @@ -979,7 +979,7 @@ def get_replicas( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -991,7 +991,7 @@ def get_replicas( return self._parse_response(response, model=DedicatedDatabaseReplicas) - def get_status( + async def get_status( self, database_id: str, ) -> DatabaseStatus: @@ -1019,7 +1019,7 @@ def get_status( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1031,7 +1031,7 @@ def get_status( return self._parse_response(response, model=DatabaseStatus) - def list_tables( + async def list_tables( self, database_id: str, queries: Optional[List[str]] = None, @@ -1074,7 +1074,7 @@ def list_tables( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1086,7 +1086,7 @@ def list_tables( return self._parse_response(response, model=TableList) - def create_table( + async def create_table( self, database_id: str, table_id: str, @@ -1156,7 +1156,7 @@ def create_table( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1169,7 +1169,7 @@ def create_table( return self._parse_response(response, model=Table) - def get_table( + async def get_table( self, database_id: str, table_id: str, @@ -1203,7 +1203,7 @@ def get_table( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1215,7 +1215,7 @@ def get_table( return self._parse_response(response, model=Table) - def update_table( + async def update_table( self, database_id: str, table_id: str, @@ -1279,7 +1279,7 @@ def update_table( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1292,7 +1292,7 @@ def update_table( return self._parse_response(response, model=Table) - def delete_table( + async def delete_table( self, database_id: str, table_id: str, @@ -1326,7 +1326,7 @@ def delete_table( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1339,7 +1339,7 @@ def delete_table( return response - def list_columns( + async def list_columns( self, database_id: str, table_id: str, @@ -1383,7 +1383,7 @@ def list_columns( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1395,7 +1395,7 @@ def list_columns( return self._parse_response(response, model=ColumnList) - def create_big_int_column( + async def create_big_int_column( self, database_id: str, table_id: str, @@ -1466,7 +1466,7 @@ def create_big_int_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1479,7 +1479,7 @@ def create_big_int_column( return self._parse_response(response, model=ColumnBigint) - def update_big_int_column( + async def update_big_int_column( self, database_id: str, table_id: str, @@ -1549,7 +1549,7 @@ def update_big_int_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1562,7 +1562,7 @@ def update_big_int_column( return self._parse_response(response, model=ColumnBigint) - def create_boolean_column( + async def create_boolean_column( self, database_id: str, table_id: str, @@ -1623,7 +1623,7 @@ def create_boolean_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1636,7 +1636,7 @@ def create_boolean_column( return self._parse_response(response, model=ColumnBoolean) - def update_boolean_column( + async def update_boolean_column( self, database_id: str, table_id: str, @@ -1696,7 +1696,7 @@ def update_boolean_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1709,7 +1709,7 @@ def update_boolean_column( return self._parse_response(response, model=ColumnBoolean) - def create_datetime_column( + async def create_datetime_column( self, database_id: str, table_id: str, @@ -1770,7 +1770,7 @@ def create_datetime_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1783,7 +1783,7 @@ def create_datetime_column( return self._parse_response(response, model=ColumnDatetime) - def update_datetime_column( + async def update_datetime_column( self, database_id: str, table_id: str, @@ -1843,7 +1843,7 @@ def update_datetime_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1856,7 +1856,7 @@ def update_datetime_column( return self._parse_response(response, model=ColumnDatetime) - def create_email_column( + async def create_email_column( self, database_id: str, table_id: str, @@ -1917,7 +1917,7 @@ def create_email_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1930,7 +1930,7 @@ def create_email_column( return self._parse_response(response, model=ColumnEmail) - def update_email_column( + async def update_email_column( self, database_id: str, table_id: str, @@ -1990,7 +1990,7 @@ def update_email_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2003,7 +2003,7 @@ def update_email_column( return self._parse_response(response, model=ColumnEmail) - def create_enum_column( + async def create_enum_column( self, database_id: str, table_id: str, @@ -2070,7 +2070,7 @@ def create_enum_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2083,7 +2083,7 @@ def create_enum_column( return self._parse_response(response, model=ColumnEnum) - def update_enum_column( + async def update_enum_column( self, database_id: str, table_id: str, @@ -2149,7 +2149,7 @@ def update_enum_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2162,7 +2162,7 @@ def update_enum_column( return self._parse_response(response, model=ColumnEnum) - def create_float_column( + async def create_float_column( self, database_id: str, table_id: str, @@ -2233,7 +2233,7 @@ def create_float_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2246,7 +2246,7 @@ def create_float_column( return self._parse_response(response, model=ColumnFloat) - def update_float_column( + async def update_float_column( self, database_id: str, table_id: str, @@ -2316,7 +2316,7 @@ def update_float_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2329,7 +2329,7 @@ def update_float_column( return self._parse_response(response, model=ColumnFloat) - def create_integer_column( + async def create_integer_column( self, database_id: str, table_id: str, @@ -2400,7 +2400,7 @@ def create_integer_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2413,7 +2413,7 @@ def create_integer_column( return self._parse_response(response, model=ColumnInteger) - def update_integer_column( + async def update_integer_column( self, database_id: str, table_id: str, @@ -2483,7 +2483,7 @@ def update_integer_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2496,7 +2496,7 @@ def update_integer_column( return self._parse_response(response, model=ColumnInteger) - def create_ip_column( + async def create_ip_column( self, database_id: str, table_id: str, @@ -2557,7 +2557,7 @@ def create_ip_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2570,7 +2570,7 @@ def create_ip_column( return self._parse_response(response, model=ColumnIp) - def update_ip_column( + async def update_ip_column( self, database_id: str, table_id: str, @@ -2630,7 +2630,7 @@ def update_ip_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2643,7 +2643,7 @@ def update_ip_column( return self._parse_response(response, model=ColumnIp) - def create_line_column( + async def create_line_column( self, database_id: str, table_id: str, @@ -2699,7 +2699,7 @@ def create_line_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2712,7 +2712,7 @@ def create_line_column( return self._parse_response(response, model=ColumnLine) - def update_line_column( + async def update_line_column( self, database_id: str, table_id: str, @@ -2773,7 +2773,7 @@ def update_line_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2786,7 +2786,7 @@ def update_line_column( return self._parse_response(response, model=ColumnLine) - def create_longtext_column( + async def create_longtext_column( self, database_id: str, table_id: str, @@ -2852,7 +2852,7 @@ def create_longtext_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2865,7 +2865,7 @@ def create_longtext_column( return self._parse_response(response, model=ColumnLongtext) - def update_longtext_column( + async def update_longtext_column( self, database_id: str, table_id: str, @@ -2925,7 +2925,7 @@ def update_longtext_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2938,7 +2938,7 @@ def update_longtext_column( return self._parse_response(response, model=ColumnLongtext) - def create_mediumtext_column( + async def create_mediumtext_column( self, database_id: str, table_id: str, @@ -3004,7 +3004,7 @@ def create_mediumtext_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3017,7 +3017,7 @@ def create_mediumtext_column( return self._parse_response(response, model=ColumnMediumtext) - def update_mediumtext_column( + async def update_mediumtext_column( self, database_id: str, table_id: str, @@ -3077,7 +3077,7 @@ def update_mediumtext_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3090,7 +3090,7 @@ def update_mediumtext_column( return self._parse_response(response, model=ColumnMediumtext) - def create_point_column( + async def create_point_column( self, database_id: str, table_id: str, @@ -3146,7 +3146,7 @@ def create_point_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3159,7 +3159,7 @@ def create_point_column( return self._parse_response(response, model=ColumnPoint) - def update_point_column( + async def update_point_column( self, database_id: str, table_id: str, @@ -3220,7 +3220,7 @@ def update_point_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3233,7 +3233,7 @@ def update_point_column( return self._parse_response(response, model=ColumnPoint) - def create_polygon_column( + async def create_polygon_column( self, database_id: str, table_id: str, @@ -3289,7 +3289,7 @@ def create_polygon_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3302,7 +3302,7 @@ def create_polygon_column( return self._parse_response(response, model=ColumnPolygon) - def update_polygon_column( + async def update_polygon_column( self, database_id: str, table_id: str, @@ -3363,7 +3363,7 @@ def update_polygon_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3376,7 +3376,7 @@ def update_polygon_column( return self._parse_response(response, model=ColumnPolygon) - def create_relationship_column( + async def create_relationship_column( self, database_id: str, table_id: str, @@ -3447,7 +3447,7 @@ def create_relationship_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3460,7 +3460,7 @@ def create_relationship_column( return self._parse_response(response, model=ColumnRelationship) - def update_relationship_column( + async def update_relationship_column( self, database_id: str, table_id: str, @@ -3515,7 +3515,7 @@ def update_relationship_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3529,7 +3529,7 @@ def update_relationship_column( return self._parse_response(response, model=ColumnRelationship) @deprecated("This API has been deprecated since 1.9.0. Please use `tablesDB.create_text_column` instead.") - def create_string_column( + async def create_string_column( self, database_id: str, table_id: str, @@ -3603,7 +3603,7 @@ def create_string_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3617,7 +3617,7 @@ def create_string_column( return self._parse_response(response, model=ColumnString) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_text_column` instead.") - def update_string_column( + async def update_string_column( self, database_id: str, table_id: str, @@ -3684,7 +3684,7 @@ def update_string_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3697,7 +3697,7 @@ def update_string_column( return self._parse_response(response, model=ColumnString) - def create_text_column( + async def create_text_column( self, database_id: str, table_id: str, @@ -3763,7 +3763,7 @@ def create_text_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3776,7 +3776,7 @@ def create_text_column( return self._parse_response(response, model=ColumnText) - def update_text_column( + async def update_text_column( self, database_id: str, table_id: str, @@ -3836,7 +3836,7 @@ def update_text_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3849,7 +3849,7 @@ def update_text_column( return self._parse_response(response, model=ColumnText) - def create_url_column( + async def create_url_column( self, database_id: str, table_id: str, @@ -3910,7 +3910,7 @@ def create_url_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -3923,7 +3923,7 @@ def create_url_column( return self._parse_response(response, model=ColumnUrl) - def update_url_column( + async def update_url_column( self, database_id: str, table_id: str, @@ -3983,7 +3983,7 @@ def update_url_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -3996,7 +3996,7 @@ def update_url_column( return self._parse_response(response, model=ColumnUrl) - def create_varchar_column( + async def create_varchar_column( self, database_id: str, table_id: str, @@ -4068,7 +4068,7 @@ def create_varchar_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4081,7 +4081,7 @@ def create_varchar_column( return self._parse_response(response, model=ColumnVarchar) - def update_varchar_column( + async def update_varchar_column( self, database_id: str, table_id: str, @@ -4146,7 +4146,7 @@ def update_varchar_column( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4159,7 +4159,7 @@ def update_varchar_column( return self._parse_response(response, model=ColumnVarchar) - def get_column( + async def get_column( self, database_id: str, table_id: str, @@ -4218,7 +4218,7 @@ def get_column( api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -4286,7 +4286,7 @@ def get_column( raise AppwriteException('Unable to match response to any known model') - def delete_column( + async def delete_column( self, database_id: str, table_id: str, @@ -4326,7 +4326,7 @@ def delete_column( api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -4339,7 +4339,7 @@ def delete_column( return response - def list_indexes( + async def list_indexes( self, database_id: str, table_id: str, @@ -4383,7 +4383,7 @@ def list_indexes( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -4395,7 +4395,7 @@ def list_indexes( return self._parse_response(response, model=ColumnIndexList) - def create_index( + async def create_index( self, database_id: str, table_id: str, @@ -4463,7 +4463,7 @@ def create_index( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4476,7 +4476,7 @@ def create_index( return self._parse_response(response, model=ColumnIndex) - def get_index( + async def get_index( self, database_id: str, table_id: str, @@ -4516,7 +4516,7 @@ def get_index( api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -4528,7 +4528,7 @@ def get_index( return self._parse_response(response, model=ColumnIndex) - def delete_index( + async def delete_index( self, database_id: str, table_id: str, @@ -4568,7 +4568,7 @@ def delete_index( api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -4581,7 +4581,7 @@ def delete_index( return response - def list_rows( + async def list_rows( self, database_id: str, table_id: str, @@ -4641,7 +4641,7 @@ def list_rows( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -4653,7 +4653,7 @@ def list_rows( return RowList.with_data(response, model_type) - def create_row( + async def create_row( self, database_id: str, table_id: str, @@ -4713,7 +4713,7 @@ def create_row( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4726,7 +4726,7 @@ def create_row( return Row.with_data(response, model_type) - def create_rows( + async def create_rows( self, database_id: str, table_id: str, @@ -4775,7 +4775,7 @@ def create_rows( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -4788,7 +4788,7 @@ def create_rows( return RowList.with_data(response, model_type) - def upsert_rows( + async def upsert_rows( self, database_id: str, table_id: str, @@ -4837,7 +4837,7 @@ def upsert_rows( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -4850,7 +4850,7 @@ def upsert_rows( return RowList.with_data(response, model_type) - def update_rows( + async def update_rows( self, database_id: str, table_id: str, @@ -4903,7 +4903,7 @@ def update_rows( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -4916,7 +4916,7 @@ def update_rows( return RowList.with_data(response, model_type) - def delete_rows( + async def delete_rows( self, database_id: str, table_id: str, @@ -4964,7 +4964,7 @@ def delete_rows( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -4977,7 +4977,7 @@ def delete_rows( return RowList.with_data(response, model_type) - def create_query( + async def create_query( self, database_id: str, table_id: str, @@ -5035,7 +5035,7 @@ def create_query( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -5048,7 +5048,7 @@ def create_query( return RowList.with_data(response, model_type) - def get_row( + async def get_row( self, database_id: str, table_id: str, @@ -5102,7 +5102,7 @@ def get_row( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -5114,7 +5114,7 @@ def get_row( return Row.with_data(response, model_type) - def upsert_row( + async def upsert_row( self, database_id: str, table_id: str, @@ -5173,7 +5173,7 @@ def upsert_row( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -5186,7 +5186,7 @@ def upsert_row( return Row.with_data(response, model_type) - def update_row( + async def update_row( self, database_id: str, table_id: str, @@ -5245,7 +5245,7 @@ def update_row( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5258,7 +5258,7 @@ def update_row( return Row.with_data(response, model_type) - def delete_row( + async def delete_row( self, database_id: str, table_id: str, @@ -5303,7 +5303,7 @@ def delete_row( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -5316,7 +5316,7 @@ def delete_row( return response - def decrement_row_column( + async def decrement_row_column( self, database_id: str, table_id: str, @@ -5381,7 +5381,7 @@ def decrement_row_column( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -5394,7 +5394,7 @@ def decrement_row_column( return Row.with_data(response, model_type) - def increment_row_column( + async def increment_row_column( self, database_id: str, table_id: str, @@ -5459,7 +5459,7 @@ def increment_row_column( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 00a695d3..93488b0e 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -19,7 +19,7 @@ class Teams(Service): def __init__(self, client) -> None: super(Teams, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -60,7 +60,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -72,7 +72,7 @@ def list( return TeamList.with_data(response, model_type) - def create( + async def create( self, team_id: str, name: str, @@ -115,7 +115,7 @@ def create( if roles is not None: api_params['roles'] = self._normalize_value(roles) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -128,7 +128,7 @@ def create( return Team.with_data(response, model_type) - def get( + async def get( self, team_id: str, model_type: Type[T] = dict, @@ -160,7 +160,7 @@ def get( raise AppwriteException('Missing required parameter: "team_id"') api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -172,7 +172,7 @@ def get( return Team.with_data(response, model_type) - def update_name( + async def update_name( self, team_id: str, name: str, @@ -210,7 +210,7 @@ def update_name( api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -223,7 +223,7 @@ def update_name( return Team.with_data(response, model_type) - def delete( + async def delete( self, team_id: str, ) -> Dict[str, Any]: @@ -251,7 +251,7 @@ def delete( raise AppwriteException('Missing required parameter: "team_id"') api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -264,7 +264,7 @@ def delete( return response - def list_installations( + async def list_installations( self, team_id: str, queries: Optional[List[str]] = None, @@ -302,7 +302,7 @@ def list_installations( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -314,7 +314,7 @@ def list_installations( return self._parse_response(response, model=AppInstallationList) - def create_installation( + async def create_installation( self, team_id: str, app_id: str, @@ -353,7 +353,7 @@ def create_installation( if authorization_details is not None: api_params['authorizationDetails'] = self._normalize_value(authorization_details) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -366,7 +366,7 @@ def create_installation( return self._parse_response(response, model=AppInstallation) - def get_installation( + async def get_installation( self, team_id: str, installation_id: str, @@ -400,7 +400,7 @@ def get_installation( api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) api_path = api_path.replace('{installationId}', str(self._normalize_value(installation_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -412,7 +412,7 @@ def get_installation( return self._parse_response(response, model=AppInstallation) - def update_installation( + async def update_installation( self, team_id: str, installation_id: str, @@ -451,7 +451,7 @@ def update_installation( if authorization_details is not None: api_params['authorizationDetails'] = self._normalize_value(authorization_details) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -464,7 +464,7 @@ def update_installation( return self._parse_response(response, model=AppInstallation) - def delete_installation( + async def delete_installation( self, team_id: str, installation_id: str, @@ -498,7 +498,7 @@ def delete_installation( api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) api_path = api_path.replace('{installationId}', str(self._normalize_value(installation_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -511,7 +511,7 @@ def delete_installation( return response - def list_memberships( + async def list_memberships( self, team_id: str, queries: Optional[List[str]] = None, @@ -554,7 +554,7 @@ def list_memberships( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -566,7 +566,7 @@ def list_memberships( return self._parse_response(response, model=MembershipList) - def create_membership( + async def create_membership( self, team_id: str, roles: List[str], @@ -636,7 +636,7 @@ def create_membership( if membership_id is not None: api_params['membershipId'] = self._normalize_value(membership_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -649,7 +649,7 @@ def create_membership( return self._parse_response(response, model=Membership) - def get_membership( + async def get_membership( self, team_id: str, membership_id: str, @@ -683,7 +683,7 @@ def get_membership( api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -695,7 +695,7 @@ def get_membership( return self._parse_response(response, model=Membership) - def update_membership( + async def update_membership( self, team_id: str, membership_id: str, @@ -735,7 +735,7 @@ def update_membership( api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) api_params['roles'] = self._normalize_value(roles) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -748,7 +748,7 @@ def update_membership( return self._parse_response(response, model=Membership) - def delete_membership( + async def delete_membership( self, team_id: str, membership_id: str, @@ -782,7 +782,7 @@ def delete_membership( api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -795,7 +795,7 @@ def delete_membership( return response - def update_membership_status( + async def update_membership_status( self, team_id: str, membership_id: str, @@ -843,7 +843,7 @@ def update_membership_status( api_params['userId'] = self._normalize_value(user_id) api_params['secret'] = self._normalize_value(secret) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -856,7 +856,7 @@ def update_membership_status( return self._parse_response(response, model=Membership) - def get_prefs( + async def get_prefs( self, team_id: str, model_type: Type[T] = dict, @@ -888,7 +888,7 @@ def get_prefs( raise AppwriteException('Missing required parameter: "team_id"') api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -900,7 +900,7 @@ def get_prefs( return Preferences.with_data(response, model_type) - def update_prefs( + async def update_prefs( self, team_id: str, prefs: Dict[str, Any], @@ -938,7 +938,7 @@ def update_prefs( api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) api_params['prefs'] = self._normalize_value(prefs) - response = self.client.call( + response = await self.client.call( 'put', api_path, { diff --git a/appwrite/services/tokens.py b/appwrite/services/tokens.py index b3edf492..20cc01fd 100644 --- a/appwrite/services/tokens.py +++ b/appwrite/services/tokens.py @@ -12,7 +12,7 @@ class Tokens(Service): def __init__(self, client) -> None: super(Tokens, self).__init__(client) - def list( + async def list( self, bucket_id: str, file_id: str, @@ -56,7 +56,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -68,7 +68,7 @@ def list( return self._parse_response(response, model=ResourceTokenList) - def create_file_token( + async def create_file_token( self, bucket_id: str, file_id: str, @@ -107,7 +107,7 @@ def create_file_token( if expire is not None: api_params['expire'] = self._normalize_value(expire) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -120,7 +120,7 @@ def create_file_token( return self._parse_response(response, model=ResourceToken) - def get( + async def get( self, token_id: str, ) -> ResourceToken: @@ -148,7 +148,7 @@ def get( raise AppwriteException('Missing required parameter: "token_id"') api_path = api_path.replace('{tokenId}', str(self._normalize_value(token_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -160,7 +160,7 @@ def get( return self._parse_response(response, model=ResourceToken) - def update( + async def update( self, token_id: str, expire: Optional[str] = None, @@ -193,7 +193,7 @@ def update( if expire is not None: api_params['expire'] = self._normalize_value(expire) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -206,7 +206,7 @@ def update( return self._parse_response(response, model=ResourceToken) - def delete( + async def delete( self, token_id: str, ) -> Dict[str, Any]: @@ -234,7 +234,7 @@ def delete( raise AppwriteException('Missing required parameter: "token_id"') api_path = api_path.replace('{tokenId}', str(self._normalize_value(token_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/users.py b/appwrite/services/users.py index 6e89654b..32df1f7b 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -31,7 +31,7 @@ class Users(Service): def __init__(self, client) -> None: super(Users, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -72,7 +72,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -84,7 +84,7 @@ def list( return UserList.with_data(response, model_type) - def create( + async def create( self, user_id: str, email: Optional[str] = None, @@ -136,7 +136,7 @@ def create( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -149,7 +149,7 @@ def create( return User.with_data(response, model_type) - def create_argon2_user( + async def create_argon2_user( self, user_id: str, email: str, @@ -198,7 +198,7 @@ def create_argon2_user( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -211,7 +211,7 @@ def create_argon2_user( return User.with_data(response, model_type) - def create_bcrypt_user( + async def create_bcrypt_user( self, user_id: str, email: str, @@ -260,7 +260,7 @@ def create_bcrypt_user( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -273,7 +273,7 @@ def create_bcrypt_user( return User.with_data(response, model_type) - def list_identities( + async def list_identities( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -310,7 +310,7 @@ def list_identities( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -322,7 +322,7 @@ def list_identities( return self._parse_response(response, model=IdentityList) - def delete_identity( + async def delete_identity( self, identity_id: str, ) -> Dict[str, Any]: @@ -350,7 +350,7 @@ def delete_identity( raise AppwriteException('Missing required parameter: "identity_id"') api_path = api_path.replace('{identityId}', str(self._normalize_value(identity_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -363,7 +363,7 @@ def delete_identity( return response - def create_md5_user( + async def create_md5_user( self, user_id: str, email: str, @@ -412,7 +412,7 @@ def create_md5_user( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -425,7 +425,7 @@ def create_md5_user( return User.with_data(response, model_type) - def create_ph_pass_user( + async def create_ph_pass_user( self, user_id: str, email: str, @@ -474,7 +474,7 @@ def create_ph_pass_user( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -487,7 +487,7 @@ def create_ph_pass_user( return User.with_data(response, model_type) - def create_scrypt_user( + async def create_scrypt_user( self, user_id: str, email: str, @@ -566,7 +566,7 @@ def create_scrypt_user( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -579,7 +579,7 @@ def create_scrypt_user( return User.with_data(response, model_type) - def create_scrypt_modified_user( + async def create_scrypt_modified_user( self, user_id: str, email: str, @@ -646,7 +646,7 @@ def create_scrypt_modified_user( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -659,7 +659,7 @@ def create_scrypt_modified_user( return User.with_data(response, model_type) - def create_sha_user( + async def create_sha_user( self, user_id: str, email: str, @@ -713,7 +713,7 @@ def create_sha_user( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -726,7 +726,7 @@ def create_sha_user( return User.with_data(response, model_type) - def get( + async def get( self, user_id: str, model_type: Type[T] = dict, @@ -758,7 +758,7 @@ def get( raise AppwriteException('Missing required parameter: "user_id"') api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -770,7 +770,7 @@ def get( return User.with_data(response, model_type) - def delete( + async def delete( self, user_id: str, ) -> Dict[str, Any]: @@ -798,7 +798,7 @@ def delete( raise AppwriteException('Missing required parameter: "user_id"') api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -811,7 +811,7 @@ def delete( return response - def update_email( + async def update_email( self, user_id: str, email: str, @@ -849,7 +849,7 @@ def update_email( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['email'] = self._normalize_value(email) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -862,7 +862,7 @@ def update_email( return User.with_data(response, model_type) - def update_impersonator( + async def update_impersonator( self, user_id: str, impersonator: bool, @@ -900,7 +900,7 @@ def update_impersonator( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['impersonator'] = self._normalize_value(impersonator) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -913,7 +913,7 @@ def update_impersonator( return User.with_data(response, model_type) - def create_jwt( + async def create_jwt( self, user_id: str, session_id: Optional[str] = None, @@ -951,7 +951,7 @@ def create_jwt( if duration is not None: api_params['duration'] = self._normalize_value(duration) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -964,7 +964,7 @@ def create_jwt( return self._parse_response(response, model=Jwt) - def update_labels( + async def update_labels( self, user_id: str, labels: List[str], @@ -1004,7 +1004,7 @@ def update_labels( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['labels'] = self._normalize_value(labels) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1017,7 +1017,7 @@ def update_labels( return User.with_data(response, model_type) - def list_memberships( + async def list_memberships( self, user_id: str, queries: Optional[List[str]] = None, @@ -1060,7 +1060,7 @@ def list_memberships( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1072,7 +1072,7 @@ def list_memberships( return self._parse_response(response, model=MembershipList) - def update_mfa( + async def update_mfa( self, user_id: str, mfa: bool, @@ -1110,7 +1110,7 @@ def update_mfa( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['mfa'] = self._normalize_value(mfa) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1123,7 +1123,7 @@ def update_mfa( return User.with_data(response, model_type) - def delete_mfa_authenticator( + async def delete_mfa_authenticator( self, user_id: str, type: AuthenticatorType, @@ -1157,7 +1157,7 @@ def delete_mfa_authenticator( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_path = api_path.replace('{type}', str(self._normalize_value(type))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1170,7 +1170,7 @@ def delete_mfa_authenticator( return response - def get_mfa_challenge( + async def get_mfa_challenge( self, user_id: str, challenge_id: str, @@ -1204,7 +1204,7 @@ def get_mfa_challenge( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_path = api_path.replace('{challengeId}', str(self._normalize_value(challenge_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1216,7 +1216,7 @@ def get_mfa_challenge( return self._parse_response(response, model=MfaChallengeSecret) - def list_mfa_factors( + async def list_mfa_factors( self, user_id: str, ) -> MfaFactors: @@ -1244,7 +1244,7 @@ def list_mfa_factors( raise AppwriteException('Missing required parameter: "user_id"') api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1256,7 +1256,7 @@ def list_mfa_factors( return self._parse_response(response, model=MfaFactors) - def get_mfa_recovery_codes( + async def get_mfa_recovery_codes( self, user_id: str, ) -> MfaRecoveryCodes: @@ -1284,7 +1284,7 @@ def get_mfa_recovery_codes( raise AppwriteException('Missing required parameter: "user_id"') api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1296,7 +1296,7 @@ def get_mfa_recovery_codes( return self._parse_response(response, model=MfaRecoveryCodes) - def update_mfa_recovery_codes( + async def update_mfa_recovery_codes( self, user_id: str, ) -> MfaRecoveryCodes: @@ -1324,7 +1324,7 @@ def update_mfa_recovery_codes( raise AppwriteException('Missing required parameter: "user_id"') api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1337,7 +1337,7 @@ def update_mfa_recovery_codes( return self._parse_response(response, model=MfaRecoveryCodes) - def create_mfa_recovery_codes( + async def create_mfa_recovery_codes( self, user_id: str, ) -> MfaRecoveryCodes: @@ -1365,7 +1365,7 @@ def create_mfa_recovery_codes( raise AppwriteException('Missing required parameter: "user_id"') api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1378,7 +1378,7 @@ def create_mfa_recovery_codes( return self._parse_response(response, model=MfaRecoveryCodes) - def update_name( + async def update_name( self, user_id: str, name: str, @@ -1416,7 +1416,7 @@ def update_name( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1429,7 +1429,7 @@ def update_name( return User.with_data(response, model_type) - def list_passkeys( + async def list_passkeys( self, user_id: str, queries: Optional[List[str]] = None, @@ -1467,7 +1467,7 @@ def list_passkeys( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1479,7 +1479,7 @@ def list_passkeys( return self._parse_response(response, model=PasskeyList) - def get_passkey( + async def get_passkey( self, user_id: str, passkey_id: str, @@ -1513,7 +1513,7 @@ def get_passkey( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_path = api_path.replace('{passkeyId}', str(self._normalize_value(passkey_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1525,7 +1525,7 @@ def get_passkey( return self._parse_response(response, model=Passkey) - def update_passkey( + async def update_passkey( self, user_id: str, passkey_id: str, @@ -1565,7 +1565,7 @@ def update_passkey( api_path = api_path.replace('{passkeyId}', str(self._normalize_value(passkey_id))) api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1578,7 +1578,7 @@ def update_passkey( return self._parse_response(response, model=Passkey) - def delete_passkey( + async def delete_passkey( self, user_id: str, passkey_id: str, @@ -1612,7 +1612,7 @@ def delete_passkey( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_path = api_path.replace('{passkeyId}', str(self._normalize_value(passkey_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1625,7 +1625,7 @@ def delete_passkey( return response - def update_password( + async def update_password( self, user_id: str, password: str, @@ -1663,7 +1663,7 @@ def update_password( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['password'] = self._normalize_value(password) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1676,7 +1676,7 @@ def update_password( return User.with_data(response, model_type) - def update_phone( + async def update_phone( self, user_id: str, number: str, @@ -1714,7 +1714,7 @@ def update_phone( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['number'] = self._normalize_value(number) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1727,7 +1727,7 @@ def update_phone( return User.with_data(response, model_type) - def get_prefs( + async def get_prefs( self, user_id: str, model_type: Type[T] = dict, @@ -1759,7 +1759,7 @@ def get_prefs( raise AppwriteException('Missing required parameter: "user_id"') api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1771,7 +1771,7 @@ def get_prefs( return Preferences.with_data(response, model_type) - def update_prefs( + async def update_prefs( self, user_id: str, prefs: Dict[str, Any], @@ -1809,7 +1809,7 @@ def update_prefs( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['prefs'] = self._normalize_value(prefs) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1822,7 +1822,7 @@ def update_prefs( return Preferences.with_data(response, model_type) - def list_sessions( + async def list_sessions( self, user_id: str, total: Optional[bool] = None, @@ -1855,7 +1855,7 @@ def list_sessions( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1867,7 +1867,7 @@ def list_sessions( return self._parse_response(response, model=SessionList) - def create_session( + async def create_session( self, user_id: str, ) -> Session: @@ -1897,7 +1897,7 @@ def create_session( raise AppwriteException('Missing required parameter: "user_id"') api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1910,7 +1910,7 @@ def create_session( return self._parse_response(response, model=Session) - def delete_sessions( + async def delete_sessions( self, user_id: str, ) -> Dict[str, Any]: @@ -1938,7 +1938,7 @@ def delete_sessions( raise AppwriteException('Missing required parameter: "user_id"') api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1951,7 +1951,7 @@ def delete_sessions( return response - def delete_session( + async def delete_session( self, user_id: str, session_id: str, @@ -1985,7 +1985,7 @@ def delete_session( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_path = api_path.replace('{sessionId}', str(self._normalize_value(session_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1998,7 +1998,7 @@ def delete_session( return response - def update_status( + async def update_status( self, user_id: str, status: bool, @@ -2036,7 +2036,7 @@ def update_status( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['status'] = self._normalize_value(status) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2049,7 +2049,7 @@ def update_status( return User.with_data(response, model_type) - def list_targets( + async def list_targets( self, user_id: str, queries: Optional[List[str]] = None, @@ -2087,7 +2087,7 @@ def list_targets( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2099,7 +2099,7 @@ def list_targets( return self._parse_response(response, model=TargetList) - def create_target( + async def create_target( self, user_id: str, target_id: str, @@ -2155,7 +2155,7 @@ def create_target( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2168,7 +2168,7 @@ def create_target( return self._parse_response(response, model=Target) - def get_target( + async def get_target( self, user_id: str, target_id: str, @@ -2202,7 +2202,7 @@ def get_target( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_path = api_path.replace('{targetId}', str(self._normalize_value(target_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2214,7 +2214,7 @@ def get_target( return self._parse_response(response, model=Target) - def update_target( + async def update_target( self, user_id: str, target_id: str, @@ -2263,7 +2263,7 @@ def update_target( if name is not None: api_params['name'] = self._normalize_value(name) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2276,7 +2276,7 @@ def update_target( return self._parse_response(response, model=Target) - def delete_target( + async def delete_target( self, user_id: str, target_id: str, @@ -2310,7 +2310,7 @@ def delete_target( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_path = api_path.replace('{targetId}', str(self._normalize_value(target_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -2323,7 +2323,7 @@ def delete_target( return response - def create_token( + async def create_token( self, user_id: str, length: Optional[float] = None, @@ -2361,7 +2361,7 @@ def create_token( if expire is not None: api_params['expire'] = self._normalize_value(expire) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -2374,7 +2374,7 @@ def create_token( return self._parse_response(response, model=Token) - def update_email_verification( + async def update_email_verification( self, user_id: str, email_verification: bool, @@ -2412,7 +2412,7 @@ def update_email_verification( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['emailVerification'] = self._normalize_value(email_verification) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -2425,7 +2425,7 @@ def update_email_verification( return User.with_data(response, model_type) - def update_phone_verification( + async def update_phone_verification( self, user_id: str, phone_verification: bool, @@ -2463,7 +2463,7 @@ def update_phone_verification( api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) api_params['phoneVerification'] = self._normalize_value(phone_verification) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { diff --git a/appwrite/services/vectors_db.py b/appwrite/services/vectors_db.py index eda5f00d..f49408a0 100644 --- a/appwrite/services/vectors_db.py +++ b/appwrite/services/vectors_db.py @@ -29,7 +29,7 @@ class VectorsDB(Service): def __init__(self, client) -> None: super(VectorsDB, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -61,7 +61,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -73,7 +73,7 @@ def list( return self._parse_response(response, model=DatabaseList) - def create( + async def create( self, database_id: str, name: str, @@ -132,7 +132,7 @@ def create( if sync_mode is not None: api_params['syncMode'] = self._normalize_value(sync_mode) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -145,7 +145,7 @@ def create( return self._parse_response(response, model=Database) - def list_specifications( + async def list_specifications( self, ) -> DedicatedDatabaseSpecificationList: """ @@ -164,7 +164,7 @@ def list_specifications( api_path = '/vectorsdb/specifications' api_params = {} - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -176,7 +176,7 @@ def list_specifications( return self._parse_response(response, model=DedicatedDatabaseSpecificationList) - def list_transactions( + async def list_transactions( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -208,7 +208,7 @@ def list_transactions( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -220,7 +220,7 @@ def list_transactions( return self._parse_response(response, model=TransactionList) - def create_transaction( + async def create_transaction( self, ttl: Optional[float] = None, ) -> Transaction: @@ -247,7 +247,7 @@ def create_transaction( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -260,7 +260,7 @@ def create_transaction( return self._parse_response(response, model=Transaction) - def get_transaction( + async def get_transaction( self, transaction_id: str, ) -> Transaction: @@ -288,7 +288,7 @@ def get_transaction( raise AppwriteException('Missing required parameter: "transaction_id"') api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -300,7 +300,7 @@ def get_transaction( return self._parse_response(response, model=Transaction) - def update_transaction( + async def update_transaction( self, transaction_id: str, commit: Optional[bool] = None, @@ -338,7 +338,7 @@ def update_transaction( if rollback is not None: api_params['rollback'] = self._normalize_value(rollback) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -351,7 +351,7 @@ def update_transaction( return self._parse_response(response, model=Transaction) - def delete_transaction( + async def delete_transaction( self, transaction_id: str, ) -> Dict[str, Any]: @@ -379,7 +379,7 @@ def delete_transaction( raise AppwriteException('Missing required parameter: "transaction_id"') api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -392,7 +392,7 @@ def delete_transaction( return response - def create_operations( + async def create_operations( self, transaction_id: str, operations: Optional[List[Dict[str, Any]]] = None, @@ -425,7 +425,7 @@ def create_operations( if operations is not None: api_params['operations'] = self._normalize_value(operations) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -438,7 +438,7 @@ def create_operations( return self._parse_response(response, model=Transaction) - def get( + async def get( self, database_id: str, ) -> Database: @@ -466,7 +466,7 @@ def get( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -478,7 +478,7 @@ def get( return self._parse_response(response, model=Database) - def update( + async def update( self, database_id: str, name: str, @@ -537,7 +537,7 @@ def update( if sync_mode is not None: api_params['syncMode'] = self._normalize_value(sync_mode) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -550,7 +550,7 @@ def update( return self._parse_response(response, model=Database) - def delete( + async def delete( self, database_id: str, ) -> Dict[str, Any]: @@ -578,7 +578,7 @@ def delete( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -591,7 +591,7 @@ def delete( return response - def list_collections( + async def list_collections( self, database_id: str, queries: Optional[List[str]] = None, @@ -634,7 +634,7 @@ def list_collections( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -646,7 +646,7 @@ def list_collections( return self._parse_response(response, model=VectorsdbCollectionList) - def create_collection( + async def create_collection( self, database_id: str, collection_id: str, @@ -712,7 +712,7 @@ def create_collection( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -725,7 +725,7 @@ def create_collection( return self._parse_response(response, model=VectorsdbCollection) - def get_collection( + async def get_collection( self, database_id: str, collection_id: str, @@ -759,7 +759,7 @@ def get_collection( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -771,7 +771,7 @@ def get_collection( return self._parse_response(response, model=VectorsdbCollection) - def update_collection( + async def update_collection( self, database_id: str, collection_id: str, @@ -836,7 +836,7 @@ def update_collection( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -849,7 +849,7 @@ def update_collection( return self._parse_response(response, model=VectorsdbCollection) - def delete_collection( + async def delete_collection( self, database_id: str, collection_id: str, @@ -883,7 +883,7 @@ def delete_collection( api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -896,7 +896,7 @@ def delete_collection( return response - def list_documents( + async def list_documents( self, database_id: str, collection_id: str, @@ -954,7 +954,7 @@ def list_documents( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -966,7 +966,7 @@ def list_documents( return DocumentList.with_data(response, model_type) - def create_document( + async def create_document( self, database_id: str, collection_id: str, @@ -1026,7 +1026,7 @@ def create_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1039,7 +1039,7 @@ def create_document( return Document.with_data(response, model_type) - def create_documents( + async def create_documents( self, database_id: str, collection_id: str, @@ -1088,7 +1088,7 @@ def create_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1101,7 +1101,7 @@ def create_documents( return DocumentList.with_data(response, model_type) - def upsert_documents( + async def upsert_documents( self, database_id: str, collection_id: str, @@ -1150,7 +1150,7 @@ def upsert_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1163,7 +1163,7 @@ def upsert_documents( return DocumentList.with_data(response, model_type) - def update_documents( + async def update_documents( self, database_id: str, collection_id: str, @@ -1216,7 +1216,7 @@ def update_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1229,7 +1229,7 @@ def update_documents( return DocumentList.with_data(response, model_type) - def delete_documents( + async def delete_documents( self, database_id: str, collection_id: str, @@ -1277,7 +1277,7 @@ def delete_documents( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1290,7 +1290,7 @@ def delete_documents( return DocumentList.with_data(response, model_type) - def create_query( + async def create_query( self, database_id: str, collection_id: str, @@ -1348,7 +1348,7 @@ def create_query( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1361,7 +1361,7 @@ def create_query( return DocumentList.with_data(response, model_type) - def get_document( + async def get_document( self, database_id: str, collection_id: str, @@ -1415,7 +1415,7 @@ def get_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1427,7 +1427,7 @@ def get_document( return Document.with_data(response, model_type) - def upsert_document( + async def upsert_document( self, database_id: str, collection_id: str, @@ -1486,7 +1486,7 @@ def upsert_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -1499,7 +1499,7 @@ def upsert_document( return Document.with_data(response, model_type) - def update_document( + async def update_document( self, database_id: str, collection_id: str, @@ -1558,7 +1558,7 @@ def update_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -1571,7 +1571,7 @@ def update_document( return Document.with_data(response, model_type) - def delete_document( + async def delete_document( self, database_id: str, collection_id: str, @@ -1616,7 +1616,7 @@ def delete_document( if transaction_id is not None: api_params['transactionId'] = self._normalize_value(transaction_id) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1629,7 +1629,7 @@ def delete_document( return response - def list_indexes( + async def list_indexes( self, database_id: str, collection_id: str, @@ -1673,7 +1673,7 @@ def list_indexes( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1685,7 +1685,7 @@ def list_indexes( return self._parse_response(response, model=IndexList) - def create_index( + async def create_index( self, database_id: str, collection_id: str, @@ -1753,7 +1753,7 @@ def create_index( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1766,7 +1766,7 @@ def create_index( return self._parse_response(response, model=Index) - def get_index( + async def get_index( self, database_id: str, collection_id: str, @@ -1806,7 +1806,7 @@ def get_index( api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1818,7 +1818,7 @@ def get_index( return self._parse_response(response, model=Index) - def delete_index( + async def delete_index( self, database_id: str, collection_id: str, @@ -1858,7 +1858,7 @@ def delete_index( api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) api_path = api_path.replace('{key}', str(self._normalize_value(key))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -1871,7 +1871,7 @@ def delete_index( return response - def create_failover( + async def create_failover( self, database_id: str, target_replica_id: Optional[str] = None, @@ -1904,7 +1904,7 @@ def create_failover( if target_replica_id is not None: api_params['targetReplicaId'] = self._normalize_value(target_replica_id) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -1917,7 +1917,7 @@ def create_failover( return self._parse_response(response, model=DedicatedDatabase) - def list_operations( + async def list_operations( self, database_id: str, status: Optional[str] = None, @@ -1960,7 +1960,7 @@ def list_operations( if offset is not None: api_params['offset'] = self._normalize_value(offset) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -1972,7 +1972,7 @@ def list_operations( return self._parse_response(response, model=DedicatedDatabaseOperationList) - def get_replicas( + async def get_replicas( self, database_id: str, ) -> DedicatedDatabaseReplicas: @@ -2000,7 +2000,7 @@ def get_replicas( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -2012,7 +2012,7 @@ def get_replicas( return self._parse_response(response, model=DedicatedDatabaseReplicas) - def get_status( + async def get_status( self, database_id: str, ) -> DatabaseStatus: @@ -2040,7 +2040,7 @@ def get_status( raise AppwriteException('Missing required parameter: "database_id"') api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { diff --git a/appwrite/services/waf.py b/appwrite/services/waf.py index 8aaa3ebc..184434d5 100644 --- a/appwrite/services/waf.py +++ b/appwrite/services/waf.py @@ -16,7 +16,7 @@ class Waf(Service): def __init__(self, client) -> None: super(Waf, self).__init__(client) - def list_rules( + async def list_rules( self, queries: Optional[List[str]] = None, search: Optional[str] = None, @@ -53,7 +53,7 @@ def list_rules( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -65,7 +65,7 @@ def list_rules( return self._parse_response(response, model=WafRuleList) - def create_bypass_rule( + async def create_bypass_rule( self, rule_id: str, resource_type: str, @@ -130,7 +130,7 @@ def create_bypass_rule( if conditions is not None: api_params['conditions'] = self._normalize_value(conditions) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -143,7 +143,7 @@ def create_bypass_rule( return self._parse_response(response, model=WafRuleBypass) - def update_bypass_rule( + async def update_bypass_rule( self, rule_id: str, resource_type: Optional[str] = None, @@ -206,7 +206,7 @@ def update_bypass_rule( if conditions is not None: api_params['conditions'] = self._normalize_value(conditions) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -219,7 +219,7 @@ def update_bypass_rule( return self._parse_response(response, model=WafRuleBypass) - def create_challenge_rule( + async def create_challenge_rule( self, rule_id: str, resource_type: str, @@ -299,7 +299,7 @@ def create_challenge_rule( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -312,7 +312,7 @@ def create_challenge_rule( return self._parse_response(response, model=WafRuleChallenge) - def update_challenge_rule( + async def update_challenge_rule( self, rule_id: str, resource_type: Optional[str] = None, @@ -390,7 +390,7 @@ def update_challenge_rule( if ttl is not None: api_params['ttl'] = self._normalize_value(ttl) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -403,7 +403,7 @@ def update_challenge_rule( return self._parse_response(response, model=WafRuleChallenge) - def create_deny_rule( + async def create_deny_rule( self, rule_id: str, resource_type: str, @@ -468,7 +468,7 @@ def create_deny_rule( if conditions is not None: api_params['conditions'] = self._normalize_value(conditions) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -481,7 +481,7 @@ def create_deny_rule( return self._parse_response(response, model=WafRuleDeny) - def update_deny_rule( + async def update_deny_rule( self, rule_id: str, resource_type: Optional[str] = None, @@ -544,7 +544,7 @@ def update_deny_rule( if conditions is not None: api_params['conditions'] = self._normalize_value(conditions) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -557,7 +557,7 @@ def update_deny_rule( return self._parse_response(response, model=WafRuleDeny) - def create_rate_limit_rule( + async def create_rate_limit_rule( self, rule_id: str, resource_type: str, @@ -649,7 +649,7 @@ def create_rate_limit_rule( if conditions is not None: api_params['conditions'] = self._normalize_value(conditions) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -662,7 +662,7 @@ def create_rate_limit_rule( return self._parse_response(response, model=WafRuleRateLimit) - def update_rate_limit_rule( + async def update_rate_limit_rule( self, rule_id: str, resource_type: Optional[str] = None, @@ -745,7 +745,7 @@ def update_rate_limit_rule( if conditions is not None: api_params['conditions'] = self._normalize_value(conditions) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -758,7 +758,7 @@ def update_rate_limit_rule( return self._parse_response(response, model=WafRuleRateLimit) - def create_redirect_rule( + async def create_redirect_rule( self, rule_id: str, resource_type: str, @@ -835,7 +835,7 @@ def create_redirect_rule( if conditions is not None: api_params['conditions'] = self._normalize_value(conditions) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -848,7 +848,7 @@ def create_redirect_rule( return self._parse_response(response, model=WafRuleRedirect) - def update_redirect_rule( + async def update_redirect_rule( self, rule_id: str, resource_type: Optional[str] = None, @@ -921,7 +921,7 @@ def update_redirect_rule( if conditions is not None: api_params['conditions'] = self._normalize_value(conditions) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { @@ -934,7 +934,7 @@ def update_redirect_rule( return self._parse_response(response, model=WafRuleRedirect) - def get_rule( + async def get_rule( self, rule_id: str, ) -> Union[ @@ -968,7 +968,7 @@ def get_rule( raise AppwriteException('Missing required parameter: "rule_id"') api_path = api_path.replace('{ruleId}', str(self._normalize_value(rule_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -997,7 +997,7 @@ def get_rule( raise AppwriteException('Unable to match response to any known model') - def delete_rule( + async def delete_rule( self, rule_id: str, ) -> Dict[str, Any]: @@ -1025,7 +1025,7 @@ def delete_rule( raise AppwriteException('Missing required parameter: "rule_id"') api_path = api_path.replace('{ruleId}', str(self._normalize_value(rule_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { diff --git a/appwrite/services/webhooks.py b/appwrite/services/webhooks.py index 41f4ef49..ba00688c 100644 --- a/appwrite/services/webhooks.py +++ b/appwrite/services/webhooks.py @@ -12,7 +12,7 @@ class Webhooks(Service): def __init__(self, client) -> None: super(Webhooks, self).__init__(client) - def list( + async def list( self, queries: Optional[List[str]] = None, total: Optional[bool] = None, @@ -44,7 +44,7 @@ def list( if total is not None: api_params['total'] = self._normalize_value(total) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -56,7 +56,7 @@ def list( return self._parse_response(response, model=WebhookList) - def create( + async def create( self, webhook_id: str, url: str, @@ -132,7 +132,7 @@ def create( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'post', api_path, { @@ -145,7 +145,7 @@ def create( return self._parse_response(response, model=Webhook) - def get( + async def get( self, webhook_id: str, ) -> Webhook: @@ -173,7 +173,7 @@ def get( raise AppwriteException('Missing required parameter: "webhook_id"') api_path = api_path.replace('{webhookId}', str(self._normalize_value(webhook_id))) - response = self.client.call( + response = await self.client.call( 'get', api_path, { @@ -185,7 +185,7 @@ def get( return self._parse_response(response, model=Webhook) - def update( + async def update( self, webhook_id: str, name: str, @@ -256,7 +256,7 @@ def update( if description is not None: api_params['description'] = self._normalize_value(description) - response = self.client.call( + response = await self.client.call( 'put', api_path, { @@ -269,7 +269,7 @@ def update( return self._parse_response(response, model=Webhook) - def delete( + async def delete( self, webhook_id: str, ) -> Dict[str, Any]: @@ -297,7 +297,7 @@ def delete( raise AppwriteException('Missing required parameter: "webhook_id"') api_path = api_path.replace('{webhookId}', str(self._normalize_value(webhook_id))) - response = self.client.call( + response = await self.client.call( 'delete', api_path, { @@ -310,7 +310,7 @@ def delete( return response - def update_secret( + async def update_secret( self, webhook_id: str, secret: Optional[str] = None, @@ -343,7 +343,7 @@ def update_secret( if secret is not None: api_params['secret'] = self._normalize_value(secret) - response = self.client.call( + response = await self.client.call( 'patch', api_path, { diff --git a/appwrite/utils/deprecated.py b/appwrite/utils/deprecated.py index d384ec0d..cadbc813 100644 --- a/appwrite/utils/deprecated.py +++ b/appwrite/utils/deprecated.py @@ -6,6 +6,7 @@ """ import functools +import inspect import warnings @@ -26,6 +27,19 @@ def old_function(...): def decorator(func): message = "Call to deprecated function '{}'.{}".format(func.__name__, " " + reason if reason else "") + if inspect.iscoroutinefunction(func): + + @functools.wraps(func) + async def wrapped(*args, **kwargs): + warnings.simplefilter('always', DeprecationWarning) # show warning every time + try: + warnings.warn(message, category=DeprecationWarning, stacklevel=2) + return await func(*args, **kwargs) + finally: + warnings.simplefilter('default', DeprecationWarning) # reset filter + + return wrapped + @functools.wraps(func) def wrapped(*args, **kwargs): warnings.simplefilter('always', DeprecationWarning) # show warning every time diff --git a/pyproject.toml b/pyproject.toml index a963b294..f453ce99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "appwrite" version = "26.0.0" description = "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API" readme = "README.md" -requires-python = ">=3.9" +requires-python = ">=3.11" license = { text = "BSD-3-Clause" } authors = [ { name = "Appwrite Team", email = "team@appwrite.io" } @@ -16,7 +16,7 @@ maintainers = [ { name = "Appwrite Team", email = "team@appwrite.io" } ] dependencies = [ - "requests", + "httpx2>=2.0,<3", "pydantic>=2,<3", ] classifiers = [ @@ -26,8 +26,6 @@ classifiers = [ "Topic :: Software Development", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", @@ -35,8 +33,8 @@ classifiers = [ [project.optional-dependencies] test = [ - "black==26.10.1; python_version >= '3.10'", - "requests_mock==1.11.0", + "black==26.10.1", + "respx>=0.21,<1", ] [project.urls] @@ -46,7 +44,7 @@ Repository = "https://github.com/appwrite/sdk-for-python" [tool.black] line-length = 120 skip-string-normalization = true -target-version = ['py39'] +target-version = ['py311'] [tool.setuptools.packages.find] include = ["appwrite*"] diff --git a/requirements.txt b/requirements.txt index b3386211..eb7b2075 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -requests>=2.31,<3 -requests_mock==1.12.1 +httpx2>=2.0,<3 +respx>=0.21,<1 pydantic>=2,<3 diff --git a/setup.py b/setup.py index 88f54765..741345aa 100644 --- a/setup.py +++ b/setup.py @@ -20,10 +20,10 @@ url='https://appwrite.io/support', download_url='https://github.com/appwrite/sdk-for-python/archive/26.0.0.tar.gz', install_requires=[ - 'requests', + 'httpx2>=2.0,<3', 'pydantic>=2,<3', ], - python_requires='>=3.9', + python_requires='>=3.11', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -31,8 +31,6 @@ 'Topic :: Software Development', 'License :: OSI Approved :: BSD License', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: 3.13', diff --git a/test/__init__.py b/test/__init__.py index e69de29b..e4a4d0f4 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -0,0 +1,4 @@ +import httpx2 + +# Point `import httpx` at httpx2 so respx patches the transport the SDK actually uses. +httpx2.alias_httpx() diff --git a/test/services/test_account.py b/test/services/test_account.py index e37d5b47..271bbb98 100644 --- a/test/services/test_account.py +++ b/test/services/test_account.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,14 +9,17 @@ from appwrite.services.account import Account -class AccountServiceTest(unittest.TestCase): +class AccountServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.account = Account(self.client) - @requests_mock.Mocker() - def test_get(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -35,17 +39,14 @@ def test_get(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.get() + response = await self.account.get() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -65,37 +66,31 @@ def test_create(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create( + response = await self.account.create( '', 'email@example.com', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_consents(self, m): + @respx.mock + async def test_list_consents(self): data = { "total": 5.0, "consents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.list_consents() + response = await self.account.list_consents() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_consent(self, m): + @respx.mock + async def test_get_consent(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -109,52 +104,43 @@ def test_get_consent(self, m): "expire": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.get_consent( + response = await self.account.get_consent( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_consent(self, m): + @respx.mock + async def test_delete_consent(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.delete_consent( + response = await self.account.delete_consent( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_consent_tokens(self, m): + @respx.mock + async def test_list_consent_tokens(self): data = { "total": 5.0, "tokens": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.list_consent_tokens( + response = await self.account.list_consent_tokens( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_consent_token(self, m): + @respx.mock + async def test_get_consent_token(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -169,36 +155,30 @@ def test_get_consent_token(self, m): "expire": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.get_consent_token( + response = await self.account.get_consent_token( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_consent_token(self, m): + @respx.mock + async def test_delete_consent_token(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.delete_consent_token( + response = await self.account.delete_consent_token( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_email(self, m): + @respx.mock + async def test_update_email(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -218,67 +198,55 @@ def test_update_email(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_email( + response = await self.account.update_email( 'email@example.com', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_identities(self, m): + @respx.mock + async def test_list_identities(self): data = { "total": 5.0, "identities": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.list_identities() + response = await self.account.list_identities() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_identity(self, m): + @respx.mock + async def test_delete_identity(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.delete_identity( + response = await self.account.delete_identity( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_memberships(self, m): + @respx.mock + async def test_list_memberships(self): data = { "total": 5.0, "memberships": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.list_memberships() + response = await self.account.list_memberships() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa(self, m): + @respx.mock + async def test_update_mfa(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -298,55 +266,46 @@ def test_update_mfa(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_mfa( + response = await self.account.update_mfa( True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mfa_authenticator(self, m): + @respx.mock + async def test_create_mfa_authenticator(self): data = { "secret": "[SHARED_SECRET]", "uri": "otpauth:\/\/totp\/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_mfa_authenticator( + response = await self.account.create_mfa_authenticator( 'totp', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mfa_authenticator(self, m): + @respx.mock + async def test_create_mfa_authenticator(self): data = { "secret": "[SHARED_SECRET]", "uri": "otpauth:\/\/totp\/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_mfa_authenticator( + response = await self.account.create_mfa_authenticator( 'totp', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa_authenticator(self, m): + @respx.mock + async def test_update_mfa_authenticator(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -366,20 +325,17 @@ def test_update_mfa_authenticator(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_mfa_authenticator( + response = await self.account.update_mfa_authenticator( 'totp', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa_authenticator(self, m): + @respx.mock + async def test_update_mfa_authenticator(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -399,50 +355,41 @@ def test_update_mfa_authenticator(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_mfa_authenticator( + response = await self.account.update_mfa_authenticator( 'totp', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_mfa_authenticator(self, m): + @respx.mock + async def test_delete_mfa_authenticator(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.delete_mfa_authenticator( + response = await self.account.delete_mfa_authenticator( 'totp', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_delete_mfa_authenticator(self, m): + @respx.mock + async def test_delete_mfa_authenticator(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.delete_mfa_authenticator( + response = await self.account.delete_mfa_authenticator( 'totp', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_mfa_challenge(self, m): + @respx.mock + async def test_create_mfa_challenge(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -450,19 +397,16 @@ def test_create_mfa_challenge(self, m): "expire": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_mfa_challenge( + response = await self.account.create_mfa_challenge( 'email', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mfa_challenge(self, m): + @respx.mock + async def test_create_mfa_challenge(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -470,19 +414,16 @@ def test_create_mfa_challenge(self, m): "expire": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_mfa_challenge( + response = await self.account.create_mfa_challenge( 'email', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa_challenge(self, m): + @respx.mock + async def test_update_mfa_challenge(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -515,20 +456,17 @@ def test_update_mfa_challenge(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_mfa_challenge( + response = await self.account.update_mfa_challenge( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa_challenge(self, m): + @respx.mock + async def test_update_mfa_challenge(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -561,20 +499,17 @@ def test_update_mfa_challenge(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_mfa_challenge( + response = await self.account.update_mfa_challenge( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_mfa_factors(self, m): + @respx.mock + async def test_list_mfa_factors(self): data = { "totp": True, "phone": True, @@ -583,17 +518,14 @@ def test_list_mfa_factors(self, m): "custom": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.list_mfa_factors() + response = await self.account.list_mfa_factors() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_mfa_factors(self, m): + @respx.mock + async def test_list_mfa_factors(self): data = { "totp": True, "phone": True, @@ -602,107 +534,86 @@ def test_list_mfa_factors(self, m): "custom": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.list_mfa_factors() + response = await self.account.list_mfa_factors() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_mfa_recovery_codes(self, m): + @respx.mock + async def test_get_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.get_mfa_recovery_codes() + response = await self.account.get_mfa_recovery_codes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_mfa_recovery_codes(self, m): + @respx.mock + async def test_get_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.get_mfa_recovery_codes() + response = await self.account.get_mfa_recovery_codes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mfa_recovery_codes(self, m): + @respx.mock + async def test_create_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_mfa_recovery_codes() + response = await self.account.create_mfa_recovery_codes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mfa_recovery_codes(self, m): + @respx.mock + async def test_create_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_mfa_recovery_codes() + response = await self.account.create_mfa_recovery_codes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa_recovery_codes(self, m): + @respx.mock + async def test_update_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_mfa_recovery_codes() + response = await self.account.update_mfa_recovery_codes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa_recovery_codes(self, m): + @respx.mock + async def test_update_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_mfa_recovery_codes() + response = await self.account.update_mfa_recovery_codes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_name(self, m): + @respx.mock + async def test_update_name(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -722,35 +633,29 @@ def test_update_name(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_name( + response = await self.account.update_name( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_passkeys(self, m): + @respx.mock + async def test_list_passkeys(self): data = { "total": 5.0, "passkeys": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.list_passkeys() + response = await self.account.list_passkeys() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_passkey(self, m): + @respx.mock + async def test_create_passkey(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -759,17 +664,14 @@ def test_create_passkey(self, m): "publicKey": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_passkey() + response = await self.account.create_passkey() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_passkey(self, m): + @respx.mock + async def test_get_passkey(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -778,19 +680,16 @@ def test_get_passkey(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.get_passkey( + response = await self.account.get_passkey( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_passkey(self, m): + @respx.mock + async def test_update_passkey(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -799,35 +698,29 @@ def test_update_passkey(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_passkey( + response = await self.account.update_passkey( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_passkey(self, m): + @respx.mock + async def test_delete_passkey(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.delete_passkey( + response = await self.account.delete_passkey( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_passkey_verification(self, m): + @respx.mock + async def test_update_passkey_verification(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -836,20 +729,17 @@ def test_update_passkey_verification(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_passkey_verification( + response = await self.account.update_passkey_verification( '', {}, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_password(self, m): + @respx.mock + async def test_update_password(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -869,19 +759,16 @@ def test_update_password(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_password( + response = await self.account.update_password( 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_phone(self, m): + @respx.mock + async def test_update_phone(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -901,33 +788,27 @@ def test_update_phone(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_phone( + response = await self.account.update_phone( '+12065550100', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_prefs(self, m): + @respx.mock + async def test_get_prefs(self): data = {} headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.get_prefs() + response = await self.account.get_prefs() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_prefs(self, m): + @respx.mock + async def test_update_prefs(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -947,19 +828,16 @@ def test_update_prefs(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_prefs( + response = await self.account.update_prefs( {}, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_recovery(self, m): + @respx.mock + async def test_create_recovery(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -969,20 +847,17 @@ def test_create_recovery(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_recovery( + response = await self.account.create_recovery( 'email@example.com', 'https://example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_recovery(self, m): + @respx.mock + async def test_update_recovery(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -992,21 +867,18 @@ def test_update_recovery(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_recovery( + response = await self.account.update_recovery( '', '', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_recovery_otp(self, m): + @respx.mock + async def test_create_recovery_otp(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1016,19 +888,16 @@ def test_create_recovery_otp(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_recovery_otp( + response = await self.account.create_recovery_otp( 'email@example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_recovery_otp(self, m): + @respx.mock + async def test_update_recovery_otp(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1038,50 +907,41 @@ def test_update_recovery_otp(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_recovery_otp( + response = await self.account.update_recovery_otp( '', '', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_sessions(self, m): + @respx.mock + async def test_list_sessions(self): data = { "total": 5.0, "sessions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.list_sessions() + response = await self.account.list_sessions() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_sessions(self, m): + @respx.mock + async def test_delete_sessions(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.delete_sessions() + response = await self.account.delete_sessions() self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_anonymous_session(self, m): + @respx.mock + async def test_create_anonymous_session(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1114,17 +974,14 @@ def test_create_anonymous_session(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_anonymous_session() + response = await self.account.create_anonymous_session() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_email_password_session(self, m): + @respx.mock + async def test_create_email_password_session(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1157,20 +1014,17 @@ def test_create_email_password_session(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_email_password_session( + response = await self.account.create_email_password_session( 'email@example.com', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_id_token_session(self, m): + @respx.mock + async def test_create_id_token_session(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1203,20 +1057,17 @@ def test_create_id_token_session(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_id_token_session( + response = await self.account.create_id_token_session( 'apple', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_magic_url_session(self, m): + @respx.mock + async def test_update_magic_url_session(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1249,20 +1100,17 @@ def test_update_magic_url_session(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_magic_url_session( + response = await self.account.update_magic_url_session( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_phone_session(self, m): + @respx.mock + async def test_update_phone_session(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1295,20 +1143,17 @@ def test_update_phone_session(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_phone_session( + response = await self.account.update_phone_session( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_session(self, m): + @respx.mock + async def test_create_session(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1341,20 +1186,17 @@ def test_create_session(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_session( + response = await self.account.create_session( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_session(self, m): + @respx.mock + async def test_get_session(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1387,19 +1229,16 @@ def test_get_session(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.get_session( + response = await self.account.get_session( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_session(self, m): + @respx.mock + async def test_update_session(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1432,34 +1271,28 @@ def test_update_session(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_session( + response = await self.account.update_session( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_session(self, m): + @respx.mock + async def test_delete_session(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.delete_session( + response = await self.account.delete_session( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_status(self, m): + @respx.mock + async def test_update_status(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1479,17 +1312,14 @@ def test_update_status(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_status() + response = await self.account.update_status() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_email_token(self, m): + @respx.mock + async def test_create_email_token(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1499,20 +1329,17 @@ def test_create_email_token(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_email_token( + response = await self.account.create_email_token( '', 'email@example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_magic_url_token(self, m): + @respx.mock + async def test_create_magic_url_token(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1522,35 +1349,29 @@ def test_create_magic_url_token(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_magic_url_token( + response = await self.account.create_magic_url_token( '', 'email@example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_o_auth2_token(self, m): + @respx.mock + async def test_create_o_auth2_token(self): data = None headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_o_auth2_token( + response = await self.account.create_o_auth2_token( 'amazon', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_passkey_token(self, m): + @respx.mock + async def test_create_passkey_token(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1559,17 +1380,14 @@ def test_create_passkey_token(self, m): "publicKey": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_passkey_token() + response = await self.account.create_passkey_token() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_passkey_token(self, m): + @respx.mock + async def test_update_passkey_token(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1579,20 +1397,17 @@ def test_update_passkey_token(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_passkey_token( + response = await self.account.update_passkey_token( '', {}, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_phone_token(self, m): + @respx.mock + async def test_create_phone_token(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1602,20 +1417,17 @@ def test_create_phone_token(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_phone_token( + response = await self.account.create_phone_token( '', '+12065550100', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_email_verification(self, m): + @respx.mock + async def test_create_email_verification(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1625,19 +1437,16 @@ def test_create_email_verification(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_email_verification( + response = await self.account.create_email_verification( 'https://example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_verification(self, m): + @respx.mock + async def test_create_verification(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1647,19 +1456,16 @@ def test_create_verification(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_verification( + response = await self.account.create_verification( 'https://example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_email_verification(self, m): + @respx.mock + async def test_update_email_verification(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1669,20 +1475,17 @@ def test_update_email_verification(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_email_verification( + response = await self.account.update_email_verification( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_verification(self, m): + @respx.mock + async def test_update_verification(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1692,20 +1495,17 @@ def test_update_verification(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_verification( + response = await self.account.update_verification( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_email_verification_otp(self, m): + @respx.mock + async def test_create_email_verification_otp(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1715,17 +1515,14 @@ def test_create_email_verification_otp(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_email_verification_otp() + response = await self.account.create_email_verification_otp() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_email_verification_otp(self, m): + @respx.mock + async def test_update_email_verification_otp(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1735,20 +1532,17 @@ def test_update_email_verification_otp(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_email_verification_otp( + response = await self.account.update_email_verification_otp( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_phone_verification(self, m): + @respx.mock + async def test_create_phone_verification(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1758,17 +1552,14 @@ def test_create_phone_verification(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.create_phone_verification() + response = await self.account.create_phone_verification() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_phone_verification(self, m): + @respx.mock + async def test_update_phone_verification(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1778,13 +1569,10 @@ def test_update_phone_verification(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.account.update_phone_verification( + response = await self.account.update_phone_verification( '', '', ) diff --git a/test/services/test_activities.py b/test/services/test_activities.py index d9d1e662..074ad5dd 100644 --- a/test/services/test_activities.py +++ b/test/services/test_activities.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.activities import Activities -class ActivitiesServiceTest(unittest.TestCase): +class ActivitiesServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.activities = Activities(self.client) - @requests_mock.Mocker() - def test_list_events(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list_events(self): data = { "total": 5.0, "events": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.activities.list_events() + response = await self.activities.list_events() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_event(self, m): + @respx.mock + async def test_get_event(self): data = { "$id": "5e5ea5c16897e", "actorType": "user", @@ -64,13 +65,10 @@ def test_get_event(self, m): "sdkVersion": "14.0.0", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.activities.get_event( + response = await self.activities.get_event( '', ) self.assertEqual(response.to_dict(), data) diff --git a/test/services/test_advisor.py b/test/services/test_advisor.py index 74d8eb1d..63c1e880 100644 --- a/test/services/test_advisor.py +++ b/test/services/test_advisor.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.advisor import Advisor -class AdvisorServiceTest(unittest.TestCase): +class AdvisorServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.advisor = Advisor(self.client) - @requests_mock.Mocker() - def test_list_reports(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list_reports(self): data = { "total": 5.0, "reports": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.advisor.list_reports() + response = await self.advisor.list_reports() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_report(self, m): + @respx.mock + async def test_get_report(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -46,52 +47,43 @@ def test_get_report(self, m): "insights": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.advisor.get_report( + response = await self.advisor.get_report( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_report(self, m): + @respx.mock + async def test_delete_report(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.advisor.delete_report( + response = await self.advisor.delete_report( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_insights(self, m): + @respx.mock + async def test_list_insights(self): data = { "total": 5.0, "insights": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.advisor.list_insights( + response = await self.advisor.list_insights( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_insight(self, m): + @respx.mock + async def test_get_insight(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -109,13 +101,10 @@ def test_get_insight(self, m): "ctas": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.advisor.get_insight( + response = await self.advisor.get_insight( '', '', ) diff --git a/test/services/test_apps.py b/test/services/test_apps.py index 0e6c2628..97da3d21 100644 --- a/test/services/test_apps.py +++ b/test/services/test_apps.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.apps import Apps -class AppsServiceTest(unittest.TestCase): +class AppsServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.apps = Apps(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "apps": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.list() + response = await self.apps.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -61,53 +62,44 @@ def test_create(self, m): "secrets": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.create( + response = await self.apps.create( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_installation_scopes(self, m): + @respx.mock + async def test_list_installation_scopes(self): data = { "total": 5.0, "scopes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.list_installation_scopes() + response = await self.apps.list_installation_scopes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_o_auth2_scopes(self, m): + @respx.mock + async def test_list_o_auth2_scopes(self): data = { "total": 5.0, "scopes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.list_o_auth2_scopes() + response = await self.apps.list_o_auth2_scopes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -137,19 +129,16 @@ def test_get(self, m): "secrets": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.get( + response = await self.apps.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -179,53 +168,44 @@ def test_update(self, m): "secrets": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.update( + response = await self.apps.update( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.delete( + response = await self.apps.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_installations(self, m): + @respx.mock + async def test_list_installations(self): data = { "total": 5.0, "installations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.list_installations( + response = await self.apps.list_installations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_installation(self, m): + @respx.mock + async def test_get_installation(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -238,36 +218,30 @@ def test_get_installation(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.get_installation( + response = await self.apps.get_installation( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_installation(self, m): + @respx.mock + async def test_delete_installation(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.delete_installation( + response = await self.apps.delete_installation( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_installation_token(self, m): + @respx.mock + async def test_create_installation_token(self): data = { "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...", "token_type": "Bearer", @@ -276,38 +250,32 @@ def test_create_installation_token(self, m): "scope": "openid email profile", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.create_installation_token( + response = await self.apps.create_installation_token( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_keys(self, m): + @respx.mock + async def test_list_keys(self): data = { "total": 5.0, "keys": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.list_keys( + response = await self.apps.list_keys( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_key(self, m): + @respx.mock + async def test_create_key(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -319,19 +287,16 @@ def test_create_key(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.create_key( + response = await self.apps.create_key( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_key(self, m): + @respx.mock + async def test_get_key(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -343,36 +308,30 @@ def test_get_key(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.get_key( + response = await self.apps.get_key( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_key(self, m): + @respx.mock + async def test_delete_key(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.delete_key( + response = await self.apps.delete_key( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_labels(self, m): + @respx.mock + async def test_update_labels(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -402,38 +361,32 @@ def test_update_labels(self, m): "secrets": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.update_labels( + response = await self.apps.update_labels( '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_secrets(self, m): + @respx.mock + async def test_list_secrets(self): data = { "total": 5.0, "secrets": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.list_secrets( + response = await self.apps.list_secrets( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_secret(self, m): + @respx.mock + async def test_create_secret(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -445,19 +398,16 @@ def test_create_secret(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.create_secret( + response = await self.apps.create_secret( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_secret(self, m): + @respx.mock + async def test_get_secret(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -469,36 +419,30 @@ def test_get_secret(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.get_secret( + response = await self.apps.get_secret( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_secret(self, m): + @respx.mock + async def test_delete_secret(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.delete_secret( + response = await self.apps.delete_secret( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_team(self, m): + @respx.mock + async def test_update_team(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -528,29 +472,23 @@ def test_update_team(self, m): "secrets": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.update_team( + response = await self.apps.update_team( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_tokens(self, m): + @respx.mock + async def test_delete_tokens(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.apps.delete_tokens( + response = await self.apps.delete_tokens( '', ) self.assertEqual(response, data) diff --git a/test/services/test_avatars.py b/test/services/test_avatars.py index c54fe183..fc584443 100644 --- a/test/services/test_avatars.py +++ b/test/services/test_avatars.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,115 +9,97 @@ from appwrite.services.avatars import Avatars -class AvatarsServiceTest(unittest.TestCase): +class AvatarsServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.avatars = Avatars(self.client) - @requests_mock.Mocker() - def test_get_browser(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_get_browser(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.avatars.get_browser( + response = await self.avatars.get_browser( 'aa', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_credit_card(self, m): + @respx.mock + async def test_get_credit_card(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.avatars.get_credit_card( + response = await self.avatars.get_credit_card( 'amex', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_favicon(self, m): + @respx.mock + async def test_get_favicon(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.avatars.get_favicon( + response = await self.avatars.get_favicon( 'https://example.com', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_flag(self, m): + @respx.mock + async def test_get_flag(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.avatars.get_flag( + response = await self.avatars.get_flag( 'af', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_image(self, m): + @respx.mock + async def test_get_image(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.avatars.get_image( + response = await self.avatars.get_image( 'https://example.com', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_initials(self, m): + @respx.mock + async def test_get_initials(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.avatars.get_initials() + response = await self.avatars.get_initials() self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_photo(self, m): + @respx.mock + async def test_get_photo(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.avatars.get_photo() + response = await self.avatars.get_photo() self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_photo(self, m): + @respx.mock + async def test_update_photo(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -136,56 +119,44 @@ def test_update_photo(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.avatars.update_photo( + response = await self.avatars.update_photo( InputFile.from_bytes(bytearray(), "example.file"), ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_photo(self, m): + @respx.mock + async def test_delete_photo(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.avatars.delete_photo() + response = await self.avatars.delete_photo() self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_qr(self, m): + @respx.mock + async def test_get_qr(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.avatars.get_qr( + response = await self.avatars.get_qr( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_screenshot(self, m): + @respx.mock + async def test_get_screenshot(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.avatars.get_screenshot( + response = await self.avatars.get_screenshot( 'https://example.com', ) self.assertEqual(response, data) diff --git a/test/services/test_backups.py b/test/services/test_backups.py index 175b3515..d92fae6c 100644 --- a/test/services/test_backups.py +++ b/test/services/test_backups.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.backups import Backups -class BackupsServiceTest(unittest.TestCase): +class BackupsServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.backups = Backups(self.client) - @requests_mock.Mocker() - def test_list_archives(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list_archives(self): data = { "total": 5.0, "archives": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.list_archives() + response = await self.backups.list_archives() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_archive(self, m): + @respx.mock + async def test_create_archive(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -43,19 +44,16 @@ def test_create_archive(self, m): "resources": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.create_archive( + response = await self.backups.create_archive( [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_archive(self, m): + @respx.mock + async def test_get_archive(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -67,50 +65,41 @@ def test_get_archive(self, m): "resources": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.get_archive( + response = await self.backups.get_archive( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_archive(self, m): + @respx.mock + async def test_delete_archive(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.delete_archive( + response = await self.backups.delete_archive( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_policies(self, m): + @respx.mock + async def test_list_policies(self): data = { "total": 5.0, "policies": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.list_policies() + response = await self.backups.list_policies() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_policy(self, m): + @respx.mock + async def test_create_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -124,13 +113,10 @@ def test_create_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.create_policy( + response = await self.backups.create_policy( '', [], 1, @@ -138,8 +124,8 @@ def test_create_policy(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_policy(self, m): + @respx.mock + async def test_get_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -153,19 +139,16 @@ def test_get_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.get_policy( + response = await self.backups.get_policy( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_policy(self, m): + @respx.mock + async def test_update_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -179,34 +162,28 @@ def test_update_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.update_policy( + response = await self.backups.update_policy( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_policy(self, m): + @respx.mock + async def test_delete_policy(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.delete_policy( + response = await self.backups.delete_policy( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_restoration(self, m): + @respx.mock + async def test_create_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -220,36 +197,30 @@ def test_create_restoration(self, m): "options": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.create_restoration( + response = await self.backups.create_restoration( '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_restorations(self, m): + @respx.mock + async def test_list_restorations(self): data = { "total": 5.0, "restorations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.list_restorations() + response = await self.backups.list_restorations() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_restoration(self, m): + @respx.mock + async def test_get_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -263,13 +234,10 @@ def test_get_restoration(self, m): "options": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.backups.get_restoration( + response = await self.backups.get_restoration( '', ) self.assertEqual(response.to_dict(), data) diff --git a/test/services/test_databases.py b/test/services/test_databases.py index 14d81297..6b52f20b 100644 --- a/test/services/test_databases.py +++ b/test/services/test_databases.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.databases import Databases -class DatabasesServiceTest(unittest.TestCase): +class DatabasesServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.databases = Databases(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "databases": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.list() + response = await self.databases.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -42,36 +43,30 @@ def test_create(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create( + response = await self.databases.create( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_transactions(self, m): + @respx.mock + async def test_list_transactions(self): data = { "total": 5.0, "transactions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.list_transactions() + response = await self.databases.list_transactions() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_transaction(self, m): + @respx.mock + async def test_create_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -81,17 +76,14 @@ def test_create_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_transaction() + response = await self.databases.create_transaction() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_transaction(self, m): + @respx.mock + async def test_get_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -101,19 +93,16 @@ def test_get_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.get_transaction( + response = await self.databases.get_transaction( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_transaction(self, m): + @respx.mock + async def test_update_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -123,34 +112,28 @@ def test_update_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_transaction( + response = await self.databases.update_transaction( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_transaction(self, m): + @respx.mock + async def test_delete_transaction(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.delete_transaction( + response = await self.databases.delete_transaction( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_operations(self, m): + @respx.mock + async def test_create_operations(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -160,19 +143,16 @@ def test_create_operations(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_operations( + response = await self.databases.create_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -183,19 +163,16 @@ def test_get(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.get( + response = await self.databases.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -206,52 +183,43 @@ def test_update(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update( + response = await self.databases.update( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.delete( + response = await self.databases.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_collections(self, m): + @respx.mock + async def test_list_collections(self): data = { "total": 5.0, "collections": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.list_collections( + response = await self.databases.list_collections( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_collection(self, m): + @respx.mock + async def test_create_collection(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -268,21 +236,18 @@ def test_create_collection(self, m): "bytesUsed": 1500.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_collection( + response = await self.databases.create_collection( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_collection(self, m): + @respx.mock + async def test_get_collection(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -299,20 +264,17 @@ def test_get_collection(self, m): "bytesUsed": 1500.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.get_collection( + response = await self.databases.get_collection( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_collection(self, m): + @respx.mock + async def test_update_collection(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -329,55 +291,46 @@ def test_update_collection(self, m): "bytesUsed": 1500.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_collection( + response = await self.databases.update_collection( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_collection(self, m): + @respx.mock + async def test_delete_collection(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.delete_collection( + response = await self.databases.delete_collection( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_attributes(self, m): + @respx.mock + async def test_list_attributes(self): data = { "total": 5.0, "attributes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.list_attributes( + response = await self.databases.list_attributes( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_big_int_attribute(self, m): + @respx.mock + async def test_create_big_int_attribute(self): data = { "key": "count", "description": "Name shown on the public profile.", @@ -389,13 +342,10 @@ def test_create_big_int_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_big_int_attribute( + response = await self.databases.create_big_int_attribute( '', '', '', @@ -403,8 +353,8 @@ def test_create_big_int_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_big_int_attribute(self, m): + @respx.mock + async def test_update_big_int_attribute(self): data = { "key": "count", "description": "Name shown on the public profile.", @@ -416,13 +366,10 @@ def test_update_big_int_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_big_int_attribute( + response = await self.databases.update_big_int_attribute( '', '', '', @@ -431,8 +378,8 @@ def test_update_big_int_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_boolean_attribute(self, m): + @respx.mock + async def test_create_boolean_attribute(self): data = { "key": "isEnabled", "description": "Name shown on the public profile.", @@ -444,13 +391,10 @@ def test_create_boolean_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_boolean_attribute( + response = await self.databases.create_boolean_attribute( '', '', '', @@ -458,8 +402,8 @@ def test_create_boolean_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_boolean_attribute(self, m): + @respx.mock + async def test_update_boolean_attribute(self): data = { "key": "isEnabled", "description": "Name shown on the public profile.", @@ -471,13 +415,10 @@ def test_update_boolean_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_boolean_attribute( + response = await self.databases.update_boolean_attribute( '', '', '', @@ -486,8 +427,8 @@ def test_update_boolean_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_datetime_attribute(self, m): + @respx.mock + async def test_create_datetime_attribute(self): data = { "key": "birthDay", "description": "Name shown on the public profile.", @@ -500,13 +441,10 @@ def test_create_datetime_attribute(self, m): "format": "datetime", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_datetime_attribute( + response = await self.databases.create_datetime_attribute( '', '', '', @@ -514,8 +452,8 @@ def test_create_datetime_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_datetime_attribute(self, m): + @respx.mock + async def test_update_datetime_attribute(self): data = { "key": "birthDay", "description": "Name shown on the public profile.", @@ -528,13 +466,10 @@ def test_update_datetime_attribute(self, m): "format": "datetime", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_datetime_attribute( + response = await self.databases.update_datetime_attribute( '', '', '', @@ -543,8 +478,8 @@ def test_update_datetime_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_email_attribute(self, m): + @respx.mock + async def test_create_email_attribute(self): data = { "key": "userEmail", "description": "Name shown on the public profile.", @@ -557,13 +492,10 @@ def test_create_email_attribute(self, m): "format": "email", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_email_attribute( + response = await self.databases.create_email_attribute( '', '', '', @@ -571,8 +503,8 @@ def test_create_email_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_email_attribute(self, m): + @respx.mock + async def test_update_email_attribute(self): data = { "key": "userEmail", "description": "Name shown on the public profile.", @@ -585,13 +517,10 @@ def test_update_email_attribute(self, m): "format": "email", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_email_attribute( + response = await self.databases.update_email_attribute( '', '', '', @@ -600,8 +529,8 @@ def test_update_email_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_enum_attribute(self, m): + @respx.mock + async def test_create_enum_attribute(self): data = { "key": "status", "description": "Name shown on the public profile.", @@ -615,13 +544,10 @@ def test_create_enum_attribute(self, m): "format": "enum", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_enum_attribute( + response = await self.databases.create_enum_attribute( '', '', '', @@ -630,8 +556,8 @@ def test_create_enum_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_enum_attribute(self, m): + @respx.mock + async def test_update_enum_attribute(self): data = { "key": "status", "description": "Name shown on the public profile.", @@ -645,13 +571,10 @@ def test_update_enum_attribute(self, m): "format": "enum", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_enum_attribute( + response = await self.databases.update_enum_attribute( '', '', '', @@ -661,8 +584,8 @@ def test_update_enum_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_float_attribute(self, m): + @respx.mock + async def test_create_float_attribute(self): data = { "key": "percentageCompleted", "description": "Name shown on the public profile.", @@ -674,13 +597,10 @@ def test_create_float_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_float_attribute( + response = await self.databases.create_float_attribute( '', '', '', @@ -688,8 +608,8 @@ def test_create_float_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_float_attribute(self, m): + @respx.mock + async def test_update_float_attribute(self): data = { "key": "percentageCompleted", "description": "Name shown on the public profile.", @@ -701,13 +621,10 @@ def test_update_float_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_float_attribute( + response = await self.databases.update_float_attribute( '', '', '', @@ -716,8 +633,8 @@ def test_update_float_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_integer_attribute(self, m): + @respx.mock + async def test_create_integer_attribute(self): data = { "key": "count", "description": "Name shown on the public profile.", @@ -729,13 +646,10 @@ def test_create_integer_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_integer_attribute( + response = await self.databases.create_integer_attribute( '', '', '', @@ -743,8 +657,8 @@ def test_create_integer_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_integer_attribute(self, m): + @respx.mock + async def test_update_integer_attribute(self): data = { "key": "count", "description": "Name shown on the public profile.", @@ -756,13 +670,10 @@ def test_update_integer_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_integer_attribute( + response = await self.databases.update_integer_attribute( '', '', '', @@ -771,8 +682,8 @@ def test_update_integer_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_ip_attribute(self, m): + @respx.mock + async def test_create_ip_attribute(self): data = { "key": "ipAddress", "description": "Name shown on the public profile.", @@ -785,13 +696,10 @@ def test_create_ip_attribute(self, m): "format": "ip", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_ip_attribute( + response = await self.databases.create_ip_attribute( '', '', '', @@ -799,8 +707,8 @@ def test_create_ip_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_ip_attribute(self, m): + @respx.mock + async def test_update_ip_attribute(self): data = { "key": "ipAddress", "description": "Name shown on the public profile.", @@ -813,13 +721,10 @@ def test_update_ip_attribute(self, m): "format": "ip", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_ip_attribute( + response = await self.databases.update_ip_attribute( '', '', '', @@ -828,8 +733,8 @@ def test_update_ip_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_line_attribute(self, m): + @respx.mock + async def test_create_line_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -841,13 +746,10 @@ def test_create_line_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_line_attribute( + response = await self.databases.create_line_attribute( '', '', '', @@ -855,8 +757,8 @@ def test_create_line_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_line_attribute(self, m): + @respx.mock + async def test_update_line_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -868,13 +770,10 @@ def test_update_line_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_line_attribute( + response = await self.databases.update_line_attribute( '', '', '', @@ -882,8 +781,8 @@ def test_update_line_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_longtext_attribute(self, m): + @respx.mock + async def test_create_longtext_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -895,13 +794,10 @@ def test_create_longtext_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_longtext_attribute( + response = await self.databases.create_longtext_attribute( '', '', '', @@ -909,8 +805,8 @@ def test_create_longtext_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_longtext_attribute(self, m): + @respx.mock + async def test_update_longtext_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -922,13 +818,10 @@ def test_update_longtext_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_longtext_attribute( + response = await self.databases.update_longtext_attribute( '', '', '', @@ -937,8 +830,8 @@ def test_update_longtext_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mediumtext_attribute(self, m): + @respx.mock + async def test_create_mediumtext_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -950,13 +843,10 @@ def test_create_mediumtext_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_mediumtext_attribute( + response = await self.databases.create_mediumtext_attribute( '', '', '', @@ -964,8 +854,8 @@ def test_create_mediumtext_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mediumtext_attribute(self, m): + @respx.mock + async def test_update_mediumtext_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -977,13 +867,10 @@ def test_update_mediumtext_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_mediumtext_attribute( + response = await self.databases.update_mediumtext_attribute( '', '', '', @@ -992,8 +879,8 @@ def test_update_mediumtext_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_point_attribute(self, m): + @respx.mock + async def test_create_point_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1005,13 +892,10 @@ def test_create_point_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_point_attribute( + response = await self.databases.create_point_attribute( '', '', '', @@ -1019,8 +903,8 @@ def test_create_point_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_point_attribute(self, m): + @respx.mock + async def test_update_point_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1032,13 +916,10 @@ def test_update_point_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_point_attribute( + response = await self.databases.update_point_attribute( '', '', '', @@ -1046,8 +927,8 @@ def test_update_point_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_polygon_attribute(self, m): + @respx.mock + async def test_create_polygon_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1059,13 +940,10 @@ def test_create_polygon_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_polygon_attribute( + response = await self.databases.create_polygon_attribute( '', '', '', @@ -1073,8 +951,8 @@ def test_create_polygon_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_polygon_attribute(self, m): + @respx.mock + async def test_update_polygon_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1086,13 +964,10 @@ def test_update_polygon_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_polygon_attribute( + response = await self.databases.update_polygon_attribute( '', '', '', @@ -1100,8 +975,8 @@ def test_update_polygon_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_relationship_attribute(self, m): + @respx.mock + async def test_create_relationship_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1119,13 +994,10 @@ def test_create_relationship_attribute(self, m): "side": "parent|child", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_relationship_attribute( + response = await self.databases.create_relationship_attribute( '', '', '', @@ -1133,8 +1005,8 @@ def test_create_relationship_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_relationship_attribute(self, m): + @respx.mock + async def test_update_relationship_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1152,21 +1024,18 @@ def test_update_relationship_attribute(self, m): "side": "parent|child", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_relationship_attribute( + response = await self.databases.update_relationship_attribute( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_string_attribute(self, m): + @respx.mock + async def test_create_string_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1179,13 +1048,10 @@ def test_create_string_attribute(self, m): "size": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_string_attribute( + response = await self.databases.create_string_attribute( '', '', '', @@ -1194,8 +1060,8 @@ def test_create_string_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_string_attribute(self, m): + @respx.mock + async def test_update_string_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1208,13 +1074,10 @@ def test_update_string_attribute(self, m): "size": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_string_attribute( + response = await self.databases.update_string_attribute( '', '', '', @@ -1223,8 +1086,8 @@ def test_update_string_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_text_attribute(self, m): + @respx.mock + async def test_create_text_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1236,13 +1099,10 @@ def test_create_text_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_text_attribute( + response = await self.databases.create_text_attribute( '', '', '', @@ -1250,8 +1110,8 @@ def test_create_text_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_text_attribute(self, m): + @respx.mock + async def test_update_text_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1263,13 +1123,10 @@ def test_update_text_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_text_attribute( + response = await self.databases.update_text_attribute( '', '', '', @@ -1278,8 +1135,8 @@ def test_update_text_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_url_attribute(self, m): + @respx.mock + async def test_create_url_attribute(self): data = { "key": "githubUrl", "description": "Name shown on the public profile.", @@ -1292,13 +1149,10 @@ def test_create_url_attribute(self, m): "format": "url", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_url_attribute( + response = await self.databases.create_url_attribute( '', '', '', @@ -1306,8 +1160,8 @@ def test_create_url_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_url_attribute(self, m): + @respx.mock + async def test_update_url_attribute(self): data = { "key": "githubUrl", "description": "Name shown on the public profile.", @@ -1320,13 +1174,10 @@ def test_update_url_attribute(self, m): "format": "url", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_url_attribute( + response = await self.databases.update_url_attribute( '', '', '', @@ -1335,8 +1186,8 @@ def test_update_url_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_varchar_attribute(self, m): + @respx.mock + async def test_create_varchar_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1349,13 +1200,10 @@ def test_create_varchar_attribute(self, m): "size": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_varchar_attribute( + response = await self.databases.create_varchar_attribute( '', '', '', @@ -1364,8 +1212,8 @@ def test_create_varchar_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_varchar_attribute(self, m): + @respx.mock + async def test_update_varchar_attribute(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1378,13 +1226,10 @@ def test_update_varchar_attribute(self, m): "size": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_varchar_attribute( + response = await self.databases.update_varchar_attribute( '', '', '', @@ -1393,8 +1238,8 @@ def test_update_varchar_attribute(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_attribute(self, m): + @respx.mock + async def test_get_attribute(self): data = { "key": "isEnabled", "description": "Name shown on the public profile.", @@ -1406,57 +1251,48 @@ def test_get_attribute(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.get_attribute( + response = await self.databases.get_attribute( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_attribute(self, m): + @respx.mock + async def test_delete_attribute(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.delete_attribute( + response = await self.databases.delete_attribute( '', '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_documents(self, m): + @respx.mock + async def test_list_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.list_documents( + response = await self.databases.list_documents( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_document(self, m): + @respx.mock + async def test_create_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -1467,13 +1303,10 @@ def test_create_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_document( + response = await self.databases.create_document( '', '', '', @@ -1482,105 +1315,90 @@ def test_create_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_documents(self, m): + @respx.mock + async def test_create_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_documents( + response = await self.databases.create_documents( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_upsert_documents(self, m): + @respx.mock + async def test_upsert_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.upsert_documents( + response = await self.databases.upsert_documents( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_documents(self, m): + @respx.mock + async def test_update_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_documents( + response = await self.databases.update_documents( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_documents(self, m): + @respx.mock + async def test_delete_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.delete_documents( + response = await self.databases.delete_documents( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_query(self, m): + @respx.mock + async def test_create_query(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_query( + response = await self.databases.create_query( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_document(self, m): + @respx.mock + async def test_get_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -1591,13 +1409,10 @@ def test_get_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.get_document( + response = await self.databases.get_document( '', '', '', @@ -1605,8 +1420,8 @@ def test_get_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_upsert_document(self, m): + @respx.mock + async def test_upsert_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -1617,13 +1432,10 @@ def test_upsert_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.upsert_document( + response = await self.databases.upsert_document( '', '', '', @@ -1631,8 +1443,8 @@ def test_upsert_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_document(self, m): + @respx.mock + async def test_update_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -1643,13 +1455,10 @@ def test_update_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.update_document( + response = await self.databases.update_document( '', '', '', @@ -1657,25 +1466,22 @@ def test_update_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_document(self, m): + @respx.mock + async def test_delete_document(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.delete_document( + response = await self.databases.delete_document( '', '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_decrement_document_attribute(self, m): + @respx.mock + async def test_decrement_document_attribute(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -1686,13 +1492,10 @@ def test_decrement_document_attribute(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.decrement_document_attribute( + response = await self.databases.decrement_document_attribute( '', '', '', @@ -1701,8 +1504,8 @@ def test_decrement_document_attribute(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_increment_document_attribute(self, m): + @respx.mock + async def test_increment_document_attribute(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -1713,13 +1516,10 @@ def test_increment_document_attribute(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.increment_document_attribute( + response = await self.databases.increment_document_attribute( '', '', '', @@ -1728,27 +1528,24 @@ def test_increment_document_attribute(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_indexes(self, m): + @respx.mock + async def test_list_indexes(self): data = { "total": 5.0, "indexes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.list_indexes( + response = await self.databases.list_indexes( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_index(self, m): + @respx.mock + async def test_create_index(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1762,13 +1559,10 @@ def test_create_index(self, m): "lengths": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.create_index( + response = await self.databases.create_index( '', '', '', @@ -1777,8 +1571,8 @@ def test_create_index(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_index(self, m): + @respx.mock + async def test_get_index(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1792,30 +1586,24 @@ def test_get_index(self, m): "lengths": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.get_index( + response = await self.databases.get_index( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_index(self, m): + @respx.mock + async def test_delete_index(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.databases.delete_index( + response = await self.databases.delete_index( '', '', '', diff --git a/test/services/test_documents_db.py b/test/services/test_documents_db.py index c9840596..5de96e4f 100644 --- a/test/services/test_documents_db.py +++ b/test/services/test_documents_db.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.documents_db import DocumentsDB -class DocumentsDBServiceTest(unittest.TestCase): +class DocumentsDBServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.documents_db = DocumentsDB(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "databases": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.list() + response = await self.documents_db.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -42,52 +43,43 @@ def test_create(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.create( + response = await self.documents_db.create( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_specifications(self, m): + @respx.mock + async def test_list_specifications(self): data = { "specifications": [], "total": 9.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.list_specifications() + response = await self.documents_db.list_specifications() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_transactions(self, m): + @respx.mock + async def test_list_transactions(self): data = { "total": 5.0, "transactions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.list_transactions() + response = await self.documents_db.list_transactions() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_transaction(self, m): + @respx.mock + async def test_create_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -97,17 +89,14 @@ def test_create_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.create_transaction() + response = await self.documents_db.create_transaction() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_transaction(self, m): + @respx.mock + async def test_get_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -117,19 +106,16 @@ def test_get_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.get_transaction( + response = await self.documents_db.get_transaction( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_transaction(self, m): + @respx.mock + async def test_update_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -139,34 +125,28 @@ def test_update_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.update_transaction( + response = await self.documents_db.update_transaction( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_transaction(self, m): + @respx.mock + async def test_delete_transaction(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.delete_transaction( + response = await self.documents_db.delete_transaction( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_operations(self, m): + @respx.mock + async def test_create_operations(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -176,19 +156,16 @@ def test_create_operations(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.create_operations( + response = await self.documents_db.create_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -199,19 +176,16 @@ def test_get(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.get( + response = await self.documents_db.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -222,53 +196,44 @@ def test_update(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.update( + response = await self.documents_db.update( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.delete( + response = await self.documents_db.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_collections(self, m): + @respx.mock + async def test_list_collections(self): data = { "total": 5.0, "collections": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.list_collections( + response = await self.documents_db.list_collections( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_collection(self, m): + @respx.mock + async def test_create_collection(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -285,21 +250,18 @@ def test_create_collection(self, m): "bytesUsed": 1500.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.create_collection( + response = await self.documents_db.create_collection( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_collection(self, m): + @respx.mock + async def test_get_collection(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -316,20 +278,17 @@ def test_get_collection(self, m): "bytesUsed": 1500.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.get_collection( + response = await self.documents_db.get_collection( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_collection(self, m): + @respx.mock + async def test_update_collection(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -346,56 +305,47 @@ def test_update_collection(self, m): "bytesUsed": 1500.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.update_collection( + response = await self.documents_db.update_collection( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_collection(self, m): + @respx.mock + async def test_delete_collection(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.delete_collection( + response = await self.documents_db.delete_collection( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_documents(self, m): + @respx.mock + async def test_list_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.list_documents( + response = await self.documents_db.list_documents( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_document(self, m): + @respx.mock + async def test_create_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -406,13 +356,10 @@ def test_create_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.create_document( + response = await self.documents_db.create_document( '', '', '', @@ -421,105 +368,90 @@ def test_create_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_documents(self, m): + @respx.mock + async def test_create_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.create_documents( + response = await self.documents_db.create_documents( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_upsert_documents(self, m): + @respx.mock + async def test_upsert_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.upsert_documents( + response = await self.documents_db.upsert_documents( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_documents(self, m): + @respx.mock + async def test_update_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.update_documents( + response = await self.documents_db.update_documents( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_documents(self, m): + @respx.mock + async def test_delete_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.delete_documents( + response = await self.documents_db.delete_documents( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_query(self, m): + @respx.mock + async def test_create_query(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.create_query( + response = await self.documents_db.create_query( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_document(self, m): + @respx.mock + async def test_get_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -530,13 +462,10 @@ def test_get_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.get_document( + response = await self.documents_db.get_document( '', '', '', @@ -544,8 +473,8 @@ def test_get_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_upsert_document(self, m): + @respx.mock + async def test_upsert_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -556,13 +485,10 @@ def test_upsert_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.upsert_document( + response = await self.documents_db.upsert_document( '', '', '', @@ -570,8 +496,8 @@ def test_upsert_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_document(self, m): + @respx.mock + async def test_update_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -582,13 +508,10 @@ def test_update_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.update_document( + response = await self.documents_db.update_document( '', '', '', @@ -596,25 +519,22 @@ def test_update_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_document(self, m): + @respx.mock + async def test_delete_document(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.delete_document( + response = await self.documents_db.delete_document( '', '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_decrement_document_attribute(self, m): + @respx.mock + async def test_decrement_document_attribute(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -625,13 +545,10 @@ def test_decrement_document_attribute(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.decrement_document_attribute( + response = await self.documents_db.decrement_document_attribute( '', '', '', @@ -640,8 +557,8 @@ def test_decrement_document_attribute(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_increment_document_attribute(self, m): + @respx.mock + async def test_increment_document_attribute(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -652,13 +569,10 @@ def test_increment_document_attribute(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.increment_document_attribute( + response = await self.documents_db.increment_document_attribute( '', '', '', @@ -667,27 +581,24 @@ def test_increment_document_attribute(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_indexes(self, m): + @respx.mock + async def test_list_indexes(self): data = { "total": 5.0, "indexes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.list_indexes( + response = await self.documents_db.list_indexes( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_index(self, m): + @respx.mock + async def test_create_index(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -701,13 +612,10 @@ def test_create_index(self, m): "lengths": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.create_index( + response = await self.documents_db.create_index( '', '', '', @@ -716,8 +624,8 @@ def test_create_index(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_index(self, m): + @respx.mock + async def test_get_index(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -731,38 +639,32 @@ def test_get_index(self, m): "lengths": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.get_index( + response = await self.documents_db.get_index( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_index(self, m): + @respx.mock + async def test_delete_index(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.delete_index( + response = await self.documents_db.delete_index( '', '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_failover(self, m): + @respx.mock + async def test_create_failover(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -811,37 +713,31 @@ def test_create_failover(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.create_failover( + response = await self.documents_db.create_failover( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_operations(self, m): + @respx.mock + async def test_list_operations(self): data = { "total": 5.0, "operations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.list_operations( + response = await self.documents_db.list_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_replicas(self, m): + @respx.mock + async def test_get_replicas(self): data = { "replicas": 2.0, "syncMode": "async", @@ -851,19 +747,16 @@ def test_get_replicas(self, m): "members": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.get_replicas( + response = await self.documents_db.get_replicas( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_status(self, m): + @respx.mock + async def test_get_status(self): data = { "health": "healthy", "ready": True, @@ -878,13 +771,10 @@ def test_get_status(self, m): "volumes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.documents_db.get_status( + response = await self.documents_db.get_status( '', ) self.assertEqual(response.to_dict(), data) diff --git a/test/services/test_domains.py b/test/services/test_domains.py index 8ae6d3c4..6eca1e2f 100644 --- a/test/services/test_domains.py +++ b/test/services/test_domains.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.domains import Domains -class DomainsServiceTest(unittest.TestCase): +class DomainsServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.domains = Domains(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "domains": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.list() + response = await self.domains.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -47,20 +48,17 @@ def test_create(self, m): "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create( + response = await self.domains.create( '', 'example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_price(self, m): + @respx.mock + async def test_get_price(self): data = { "domain": "example.com", "tld": "com", @@ -70,37 +68,31 @@ def test_get_price(self, m): "renewalPeriodYears": 1.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get_price( + response = await self.domains.get_price( 'example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_prices(self, m): + @respx.mock + async def test_list_prices(self): data = { "total": 5.0, "prices": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.list_prices( + response = await self.domains.list_prices( [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -116,34 +108,28 @@ def test_get(self, m): "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get( + response = await self.domains.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.delete( + response = await self.domains.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_nameservers(self, m): + @respx.mock + async def test_update_nameservers(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -159,19 +145,16 @@ def test_update_nameservers(self, m): "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_nameservers( + response = await self.domains.update_nameservers( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_verify_nameservers(self, m): + @respx.mock + async def test_verify_nameservers(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -187,253 +170,211 @@ def test_verify_nameservers(self, m): "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.verify_nameservers( + response = await self.domains.verify_nameservers( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_preset_google_workspace(self, m): + @respx.mock + async def test_get_preset_google_workspace(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get_preset_google_workspace( + response = await self.domains.get_preset_google_workspace( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_preset_google_workspace(self, m): + @respx.mock + async def test_create_preset_google_workspace(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_preset_google_workspace( + response = await self.domains.create_preset_google_workspace( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_preset_i_cloud(self, m): + @respx.mock + async def test_get_preset_i_cloud(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get_preset_i_cloud( + response = await self.domains.get_preset_i_cloud( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_preset_i_cloud(self, m): + @respx.mock + async def test_create_preset_i_cloud(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_preset_i_cloud( + response = await self.domains.create_preset_i_cloud( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_preset_mailgun(self, m): + @respx.mock + async def test_get_preset_mailgun(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get_preset_mailgun( + response = await self.domains.get_preset_mailgun( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_preset_mailgun(self, m): + @respx.mock + async def test_create_preset_mailgun(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_preset_mailgun( + response = await self.domains.create_preset_mailgun( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_preset_outlook(self, m): + @respx.mock + async def test_get_preset_outlook(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get_preset_outlook( + response = await self.domains.get_preset_outlook( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_preset_outlook(self, m): + @respx.mock + async def test_create_preset_outlook(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_preset_outlook( + response = await self.domains.create_preset_outlook( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_preset_proton_mail(self, m): + @respx.mock + async def test_get_preset_proton_mail(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get_preset_proton_mail( + response = await self.domains.get_preset_proton_mail( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_preset_proton_mail(self, m): + @respx.mock + async def test_create_preset_proton_mail(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_preset_proton_mail( + response = await self.domains.create_preset_proton_mail( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_preset_zoho(self, m): + @respx.mock + async def test_get_preset_zoho(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get_preset_zoho( + response = await self.domains.get_preset_zoho( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_preset_zoho(self, m): + @respx.mock + async def test_create_preset_zoho(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_preset_zoho( + response = await self.domains.create_preset_zoho( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_records(self, m): + @respx.mock + async def test_list_records(self): data = { "total": 5.0, "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.list_records( + response = await self.domains.list_records( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_a(self, m): + @respx.mock + async def test_create_record_a(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -449,13 +390,10 @@ def test_create_record_a(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_a( + response = await self.domains.create_record_a( '', 'name', 'value', @@ -463,8 +401,8 @@ def test_create_record_a(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_a(self, m): + @respx.mock + async def test_update_record_a(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -480,13 +418,10 @@ def test_update_record_a(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_a( + response = await self.domains.update_record_a( '', '', 'name', @@ -495,8 +430,8 @@ def test_update_record_a(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_aaaa(self, m): + @respx.mock + async def test_create_record_aaaa(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -512,13 +447,10 @@ def test_create_record_aaaa(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_aaaa( + response = await self.domains.create_record_aaaa( '', 'name', 'value', @@ -526,8 +458,8 @@ def test_create_record_aaaa(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_aaaa(self, m): + @respx.mock + async def test_update_record_aaaa(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -543,13 +475,10 @@ def test_update_record_aaaa(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_aaaa( + response = await self.domains.update_record_aaaa( '', '', 'name', @@ -558,8 +487,8 @@ def test_update_record_aaaa(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_alias(self, m): + @respx.mock + async def test_create_record_alias(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -575,13 +504,10 @@ def test_create_record_alias(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_alias( + response = await self.domains.create_record_alias( '', 'name', '', @@ -589,8 +515,8 @@ def test_create_record_alias(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_alias(self, m): + @respx.mock + async def test_update_record_alias(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -606,13 +532,10 @@ def test_update_record_alias(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_alias( + response = await self.domains.update_record_alias( '', '', 'name', @@ -621,8 +544,8 @@ def test_update_record_alias(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_caa(self, m): + @respx.mock + async def test_create_record_caa(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -638,13 +561,10 @@ def test_create_record_caa(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_caa( + response = await self.domains.create_record_caa( '', 'name', 'value', @@ -652,8 +572,8 @@ def test_create_record_caa(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_caa(self, m): + @respx.mock + async def test_update_record_caa(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -669,13 +589,10 @@ def test_update_record_caa(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_caa( + response = await self.domains.update_record_caa( '', '', 'name', @@ -684,8 +601,8 @@ def test_update_record_caa(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_cname(self, m): + @respx.mock + async def test_create_record_cname(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -701,13 +618,10 @@ def test_create_record_cname(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_cname( + response = await self.domains.create_record_cname( '', 'name', '', @@ -715,8 +629,8 @@ def test_create_record_cname(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_cname(self, m): + @respx.mock + async def test_update_record_cname(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -732,13 +646,10 @@ def test_update_record_cname(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_cname( + response = await self.domains.update_record_cname( '', '', 'name', @@ -747,8 +658,8 @@ def test_update_record_cname(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_https(self, m): + @respx.mock + async def test_create_record_https(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -764,13 +675,10 @@ def test_create_record_https(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_https( + response = await self.domains.create_record_https( '', 'name', '', @@ -778,8 +686,8 @@ def test_create_record_https(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_https(self, m): + @respx.mock + async def test_update_record_https(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -795,13 +703,10 @@ def test_update_record_https(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_https( + response = await self.domains.update_record_https( '', '', 'name', @@ -810,8 +715,8 @@ def test_update_record_https(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_mx(self, m): + @respx.mock + async def test_create_record_mx(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -827,13 +732,10 @@ def test_create_record_mx(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_mx( + response = await self.domains.create_record_mx( '', 'name', '', @@ -842,8 +744,8 @@ def test_create_record_mx(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_mx(self, m): + @respx.mock + async def test_update_record_mx(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -859,13 +761,10 @@ def test_update_record_mx(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_mx( + response = await self.domains.update_record_mx( '', '', 'name', @@ -875,8 +774,8 @@ def test_update_record_mx(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_ns(self, m): + @respx.mock + async def test_create_record_ns(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -892,13 +791,10 @@ def test_create_record_ns(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_ns( + response = await self.domains.create_record_ns( '', 'name', '', @@ -906,8 +802,8 @@ def test_create_record_ns(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_ns(self, m): + @respx.mock + async def test_update_record_ns(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -923,13 +819,10 @@ def test_update_record_ns(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_ns( + response = await self.domains.update_record_ns( '', '', 'name', @@ -938,8 +831,8 @@ def test_update_record_ns(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_srv(self, m): + @respx.mock + async def test_create_record_srv(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -955,13 +848,10 @@ def test_create_record_srv(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_srv( + response = await self.domains.create_record_srv( '', 'name', '', @@ -972,8 +862,8 @@ def test_create_record_srv(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_srv(self, m): + @respx.mock + async def test_update_record_srv(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -989,13 +879,10 @@ def test_update_record_srv(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_srv( + response = await self.domains.update_record_srv( '', '', 'name', @@ -1007,8 +894,8 @@ def test_update_record_srv(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_record_txt(self, m): + @respx.mock + async def test_create_record_txt(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1024,21 +911,18 @@ def test_create_record_txt(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.create_record_txt( + response = await self.domains.create_record_txt( '', 'name', 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_record_txt(self, m): + @respx.mock + async def test_update_record_txt(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1054,13 +938,10 @@ def test_update_record_txt(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_record_txt( + response = await self.domains.update_record_txt( '', '', 'name', @@ -1069,8 +950,8 @@ def test_update_record_txt(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_record(self, m): + @respx.mock + async def test_get_record(self): data = { "$id": "5f40a6e10c65e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1086,36 +967,30 @@ def test_get_record(self, m): "comment": "Mail server record", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get_record( + response = await self.domains.get_record( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_record(self, m): + @respx.mock + async def test_delete_record(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.delete_record( + response = await self.domains.delete_record( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_team(self, m): + @respx.mock + async def test_update_team(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1131,54 +1006,45 @@ def test_update_team(self, m): "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_team( + response = await self.domains.update_team( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_transfer_status(self, m): + @respx.mock + async def test_get_transfer_status(self): data = { "status": "pending_registry", "reason": "Transfer in progress", "timestamp": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.get_transfer_status( + response = await self.domains.get_transfer_status( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_zone(self, m): + @respx.mock + async def test_get_zone(self): data = '; café zone\nwww 3600 IN A 192.0.2.1\n' headers = {'Content-Type': 'text/plain; charset=utf-8'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=data, headers=headers), ) - response = self.domains.get_zone( + response = await self.domains.get_zone( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_zone(self, m): + @respx.mock + async def test_update_zone(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1194,13 +1060,10 @@ def test_update_zone(self, m): "dnsRecords": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.domains.update_zone( + response = await self.domains.update_zone( '', '', ) diff --git a/test/services/test_embeddings.py b/test/services/test_embeddings.py index 4c37d10d..ca41ad23 100644 --- a/test/services/test_embeddings.py +++ b/test/services/test_embeddings.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,26 +9,26 @@ from appwrite.services.embeddings import Embeddings -class EmbeddingsServiceTest(unittest.TestCase): +class EmbeddingsServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.embeddings = Embeddings(self.client) - @requests_mock.Mocker() - def test_create_text_embeddings(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_create_text_embeddings(self): data = { "total": 5.0, "embeddings": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.embeddings.create_text_embeddings( + response = await self.embeddings.create_text_embeddings( [], ) self.assertEqual(response.to_dict(), data) diff --git a/test/services/test_functions.py b/test/services/test_functions.py index 1f63e700..832d7b80 100644 --- a/test/services/test_functions.py +++ b/test/services/test_functions.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.functions import Functions -class FunctionsServiceTest(unittest.TestCase): +class FunctionsServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.functions = Functions(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "functions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.list() + response = await self.functions.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -69,53 +70,44 @@ def test_create(self, m): "emailEnabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.create( + response = await self.functions.create( '', '', 'node-14.5', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_runtimes(self, m): + @respx.mock + async def test_list_runtimes(self): data = { "total": 5.0, "runtimes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.list_runtimes() + response = await self.functions.list_runtimes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_specifications(self, m): + @respx.mock + async def test_list_specifications(self): data = { "total": 5.0, "specifications": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.list_specifications() + response = await self.functions.list_specifications() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -153,19 +145,16 @@ def test_get(self, m): "emailEnabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.get( + response = await self.functions.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -203,35 +192,29 @@ def test_update(self, m): "emailEnabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.update( + response = await self.functions.update( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.delete( + response = await self.functions.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_function_deployment(self, m): + @respx.mock + async def test_update_function_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -269,38 +252,32 @@ def test_update_function_deployment(self, m): "emailEnabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.update_function_deployment( + response = await self.functions.update_function_deployment( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_deployments(self, m): + @respx.mock + async def test_list_deployments(self): data = { "total": 5.0, "deployments": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.list_deployments( + response = await self.functions.list_deployments( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_deployment(self, m): + @respx.mock + async def test_create_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -331,21 +308,18 @@ def test_create_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.create_deployment( + response = await self.functions.create_deployment( '', InputFile.from_bytes(bytearray(), "example.file"), True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_duplicate_deployment(self, m): + @respx.mock + async def test_create_duplicate_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -376,20 +350,17 @@ def test_create_duplicate_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.create_duplicate_deployment( + response = await self.functions.create_duplicate_deployment( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_template_deployment(self, m): + @respx.mock + async def test_create_template_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -420,13 +391,10 @@ def test_create_template_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.create_template_deployment( + response = await self.functions.create_template_deployment( '', '', '', @@ -436,8 +404,8 @@ def test_create_template_deployment(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_vcs_deployment(self, m): + @respx.mock + async def test_create_vcs_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -468,21 +436,18 @@ def test_create_vcs_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.create_vcs_deployment( + response = await self.functions.create_vcs_deployment( '', 'branch', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_deployment(self, m): + @respx.mock + async def test_get_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -513,52 +478,43 @@ def test_get_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.get_deployment( + response = await self.functions.get_deployment( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_deployment(self, m): + @respx.mock + async def test_delete_deployment(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.delete_deployment( + response = await self.functions.delete_deployment( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_deployment_download(self, m): + @respx.mock + async def test_get_deployment_download(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.functions.get_deployment_download( + response = await self.functions.get_deployment_download( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_deployment_status(self, m): + @respx.mock + async def test_update_deployment_status(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -589,38 +545,32 @@ def test_update_deployment_status(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.update_deployment_status( + response = await self.functions.update_deployment_status( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_executions(self, m): + @respx.mock + async def test_list_executions(self): data = { "total": 5.0, "executions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.list_executions( + response = await self.functions.list_executions( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_execution(self, m): + @respx.mock + async def test_create_execution(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -642,19 +592,16 @@ def test_create_execution(self, m): "duration": 1.23, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.create_execution( + response = await self.functions.create_execution( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_execution(self, m): + @respx.mock + async def test_get_execution(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -676,54 +623,45 @@ def test_get_execution(self, m): "duration": 1.23, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.get_execution( + response = await self.functions.get_execution( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_execution(self, m): + @respx.mock + async def test_delete_execution(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.delete_execution( + response = await self.functions.delete_execution( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_variables(self, m): + @respx.mock + async def test_list_variables(self): data = { "total": 5.0, "variables": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.list_variables( + response = await self.functions.list_variables( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_variable(self, m): + @respx.mock + async def test_create_variable(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -736,13 +674,10 @@ def test_create_variable(self, m): "resourceId": "myAwesomeFunction", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.create_variable( + response = await self.functions.create_variable( '', '', '', @@ -750,8 +685,8 @@ def test_create_variable(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_variable(self, m): + @respx.mock + async def test_get_variable(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -764,20 +699,17 @@ def test_get_variable(self, m): "resourceId": "myAwesomeFunction", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.get_variable( + response = await self.functions.get_variable( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_variable(self, m): + @respx.mock + async def test_update_variable(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -790,29 +722,23 @@ def test_update_variable(self, m): "resourceId": "myAwesomeFunction", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.update_variable( + response = await self.functions.update_variable( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_variable(self, m): + @respx.mock + async def test_delete_variable(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.functions.delete_variable( + response = await self.functions.delete_variable( '', '', ) diff --git a/test/services/test_graphql.py b/test/services/test_graphql.py index d9203da8..4e037993 100644 --- a/test/services/test_graphql.py +++ b/test/services/test_graphql.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,38 +9,35 @@ from appwrite.services.graphql import Graphql -class GraphqlServiceTest(unittest.TestCase): +class GraphqlServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.graphql = Graphql(self.client) - @requests_mock.Mocker() - def test_query(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_query(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.graphql.query( + response = await self.graphql.query( {}, ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_mutation(self, m): + @respx.mock + async def test_mutation(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.graphql.mutation( + response = await self.graphql.mutation( {}, ) self.assertEqual(response, data) diff --git a/test/services/test_locale.py b/test/services/test_locale.py index 1438edfb..196eac93 100644 --- a/test/services/test_locale.py +++ b/test/services/test_locale.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,14 +9,17 @@ from appwrite.services.locale import Locale -class LocaleServiceTest(unittest.TestCase): +class LocaleServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.locale = Locale(self.client) - @requests_mock.Mocker() - def test_get(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_get(self): data = { "ip": "127.0.0.1", "countryCode": "US", @@ -26,123 +30,99 @@ def test_get(self, m): "currency": "USD", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.locale.get() + response = await self.locale.get() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_codes(self, m): + @respx.mock + async def test_list_codes(self): data = { "total": 5.0, "localeCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.locale.list_codes() + response = await self.locale.list_codes() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_continents(self, m): + @respx.mock + async def test_list_continents(self): data = { "total": 5.0, "continents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.locale.list_continents() + response = await self.locale.list_continents() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_countries(self, m): + @respx.mock + async def test_list_countries(self): data = { "total": 5.0, "countries": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.locale.list_countries() + response = await self.locale.list_countries() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_countries_eu(self, m): + @respx.mock + async def test_list_countries_eu(self): data = { "total": 5.0, "countries": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.locale.list_countries_eu() + response = await self.locale.list_countries_eu() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_countries_phones(self, m): + @respx.mock + async def test_list_countries_phones(self): data = { "total": 5.0, "phones": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.locale.list_countries_phones() + response = await self.locale.list_countries_phones() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_currencies(self, m): + @respx.mock + async def test_list_currencies(self): data = { "total": 5.0, "currencies": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.locale.list_currencies() + response = await self.locale.list_currencies() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_languages(self, m): + @respx.mock + async def test_list_languages(self): data = { "total": 5.0, "languages": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.locale.list_languages() + response = await self.locale.list_languages() self.assertEqual(response.to_dict(), data) diff --git a/test/services/test_messaging.py b/test/services/test_messaging.py index d22f32d6..41f023a6 100644 --- a/test/services/test_messaging.py +++ b/test/services/test_messaging.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.messaging import Messaging -class MessagingServiceTest(unittest.TestCase): +class MessagingServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.messaging = Messaging(self.client) - @requests_mock.Mocker() - def test_list_messages(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list_messages(self): data = { "total": 5.0, "messages": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.list_messages() + response = await self.messaging.list_messages() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_email(self, m): + @respx.mock + async def test_create_email(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -45,21 +46,18 @@ def test_create_email(self, m): "status": "processing", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_email( + response = await self.messaging.create_email( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_email(self, m): + @respx.mock + async def test_update_email(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -73,19 +71,16 @@ def test_update_email(self, m): "status": "processing", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_email( + response = await self.messaging.update_email( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_push(self, m): + @respx.mock + async def test_create_push(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -99,19 +94,16 @@ def test_create_push(self, m): "status": "processing", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_push( + response = await self.messaging.create_push( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_push(self, m): + @respx.mock + async def test_update_push(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -125,19 +117,16 @@ def test_update_push(self, m): "status": "processing", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_push( + response = await self.messaging.update_push( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_sms(self, m): + @respx.mock + async def test_create_sms(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -151,20 +140,17 @@ def test_create_sms(self, m): "status": "processing", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_sms( + response = await self.messaging.create_sms( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_sms(self, m): + @respx.mock + async def test_create_sms(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -178,20 +164,17 @@ def test_create_sms(self, m): "status": "processing", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_sms( + response = await self.messaging.create_sms( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_sms(self, m): + @respx.mock + async def test_update_sms(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -205,19 +188,16 @@ def test_update_sms(self, m): "status": "processing", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_sms( + response = await self.messaging.update_sms( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_sms(self, m): + @respx.mock + async def test_update_sms(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -231,19 +211,16 @@ def test_update_sms(self, m): "status": "processing", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_sms( + response = await self.messaging.update_sms( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_message(self, m): + @respx.mock + async def test_get_message(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -257,68 +234,56 @@ def test_get_message(self, m): "status": "processing", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.get_message( + response = await self.messaging.get_message( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.delete( + response = await self.messaging.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_targets(self, m): + @respx.mock + async def test_list_targets(self): data = { "total": 5.0, "targets": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.list_targets( + response = await self.messaging.list_targets( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_providers(self, m): + @respx.mock + async def test_list_providers(self): data = { "total": 5.0, "providers": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.list_providers() + response = await self.messaging.list_providers() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_apns_provider(self, m): + @respx.mock + async def test_create_apns_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -330,20 +295,17 @@ def test_create_apns_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_apns_provider( + response = await self.messaging.create_apns_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_apns_provider(self, m): + @respx.mock + async def test_create_apns_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -355,20 +317,17 @@ def test_create_apns_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_apns_provider( + response = await self.messaging.create_apns_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_apns_provider(self, m): + @respx.mock + async def test_update_apns_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -380,19 +339,16 @@ def test_update_apns_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_apns_provider( + response = await self.messaging.update_apns_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_apns_provider(self, m): + @respx.mock + async def test_update_apns_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -404,19 +360,16 @@ def test_update_apns_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_apns_provider( + response = await self.messaging.update_apns_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_appwrite_provider(self, m): + @respx.mock + async def test_create_appwrite_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -428,20 +381,17 @@ def test_create_appwrite_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_appwrite_provider( + response = await self.messaging.create_appwrite_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_appwrite_provider(self, m): + @respx.mock + async def test_update_appwrite_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -453,19 +403,16 @@ def test_update_appwrite_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_appwrite_provider( + response = await self.messaging.update_appwrite_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_fcm_provider(self, m): + @respx.mock + async def test_create_fcm_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -477,20 +424,17 @@ def test_create_fcm_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_fcm_provider( + response = await self.messaging.create_fcm_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_fcm_provider(self, m): + @respx.mock + async def test_create_fcm_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -502,20 +446,17 @@ def test_create_fcm_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_fcm_provider( + response = await self.messaging.create_fcm_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_fcm_provider(self, m): + @respx.mock + async def test_update_fcm_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -527,19 +468,16 @@ def test_update_fcm_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_fcm_provider( + response = await self.messaging.update_fcm_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_fcm_provider(self, m): + @respx.mock + async def test_update_fcm_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -551,19 +489,16 @@ def test_update_fcm_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_fcm_provider( + response = await self.messaging.update_fcm_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mailgun_provider(self, m): + @respx.mock + async def test_create_mailgun_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -575,20 +510,17 @@ def test_create_mailgun_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_mailgun_provider( + response = await self.messaging.create_mailgun_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mailgun_provider(self, m): + @respx.mock + async def test_update_mailgun_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -600,19 +532,16 @@ def test_update_mailgun_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_mailgun_provider( + response = await self.messaging.update_mailgun_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_msg91_provider(self, m): + @respx.mock + async def test_create_msg91_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -624,20 +553,17 @@ def test_create_msg91_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_msg91_provider( + response = await self.messaging.create_msg91_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_msg91_provider(self, m): + @respx.mock + async def test_update_msg91_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -649,19 +575,16 @@ def test_update_msg91_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_msg91_provider( + response = await self.messaging.update_msg91_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_resend_provider(self, m): + @respx.mock + async def test_create_resend_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -673,20 +596,17 @@ def test_create_resend_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_resend_provider( + response = await self.messaging.create_resend_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_resend_provider(self, m): + @respx.mock + async def test_update_resend_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -698,19 +618,16 @@ def test_update_resend_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_resend_provider( + response = await self.messaging.update_resend_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_sendgrid_provider(self, m): + @respx.mock + async def test_create_sendgrid_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -722,20 +639,17 @@ def test_create_sendgrid_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_sendgrid_provider( + response = await self.messaging.create_sendgrid_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_sendgrid_provider(self, m): + @respx.mock + async def test_update_sendgrid_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -747,19 +661,16 @@ def test_update_sendgrid_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_sendgrid_provider( + response = await self.messaging.update_sendgrid_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_ses_provider(self, m): + @respx.mock + async def test_create_ses_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -771,20 +682,17 @@ def test_create_ses_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_ses_provider( + response = await self.messaging.create_ses_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_ses_provider(self, m): + @respx.mock + async def test_update_ses_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -796,19 +704,16 @@ def test_update_ses_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_ses_provider( + response = await self.messaging.update_ses_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_smtp_provider(self, m): + @respx.mock + async def test_create_smtp_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -820,21 +725,18 @@ def test_create_smtp_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_smtp_provider( + response = await self.messaging.create_smtp_provider( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_smtp_provider(self, m): + @respx.mock + async def test_create_smtp_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -846,21 +748,18 @@ def test_create_smtp_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_smtp_provider( + response = await self.messaging.create_smtp_provider( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_smtp_provider(self, m): + @respx.mock + async def test_update_smtp_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -872,19 +771,16 @@ def test_update_smtp_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_smtp_provider( + response = await self.messaging.update_smtp_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_smtp_provider(self, m): + @respx.mock + async def test_update_smtp_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -896,19 +792,16 @@ def test_update_smtp_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_smtp_provider( + response = await self.messaging.update_smtp_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_telesign_provider(self, m): + @respx.mock + async def test_create_telesign_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -920,20 +813,17 @@ def test_create_telesign_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_telesign_provider( + response = await self.messaging.create_telesign_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_telesign_provider(self, m): + @respx.mock + async def test_update_telesign_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -945,19 +835,16 @@ def test_update_telesign_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_telesign_provider( + response = await self.messaging.update_telesign_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_textmagic_provider(self, m): + @respx.mock + async def test_create_textmagic_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -969,20 +856,17 @@ def test_create_textmagic_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_textmagic_provider( + response = await self.messaging.create_textmagic_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_textmagic_provider(self, m): + @respx.mock + async def test_update_textmagic_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -994,19 +878,16 @@ def test_update_textmagic_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_textmagic_provider( + response = await self.messaging.update_textmagic_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_twilio_provider(self, m): + @respx.mock + async def test_create_twilio_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1018,20 +899,17 @@ def test_create_twilio_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_twilio_provider( + response = await self.messaging.create_twilio_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_twilio_provider(self, m): + @respx.mock + async def test_update_twilio_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1043,19 +921,16 @@ def test_update_twilio_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_twilio_provider( + response = await self.messaging.update_twilio_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_vonage_provider(self, m): + @respx.mock + async def test_create_vonage_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1067,20 +942,17 @@ def test_create_vonage_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_vonage_provider( + response = await self.messaging.create_vonage_provider( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_vonage_provider(self, m): + @respx.mock + async def test_update_vonage_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1092,19 +964,16 @@ def test_update_vonage_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_vonage_provider( + response = await self.messaging.update_vonage_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_provider(self, m): + @respx.mock + async def test_get_provider(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1116,50 +985,41 @@ def test_get_provider(self, m): "credentials": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.get_provider( + response = await self.messaging.get_provider( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_provider(self, m): + @respx.mock + async def test_delete_provider(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.delete_provider( + response = await self.messaging.delete_provider( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_topics(self, m): + @respx.mock + async def test_list_topics(self): data = { "total": 5.0, "topics": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.list_topics() + response = await self.messaging.list_topics() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_topic(self, m): + @respx.mock + async def test_create_topic(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1172,20 +1032,17 @@ def test_create_topic(self, m): "subscribe": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_topic( + response = await self.messaging.create_topic( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_topic(self, m): + @respx.mock + async def test_get_topic(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1198,19 +1055,16 @@ def test_get_topic(self, m): "subscribe": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.get_topic( + response = await self.messaging.get_topic( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_topic(self, m): + @respx.mock + async def test_update_topic(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1223,52 +1077,43 @@ def test_update_topic(self, m): "subscribe": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.update_topic( + response = await self.messaging.update_topic( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_topic(self, m): + @respx.mock + async def test_delete_topic(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.delete_topic( + response = await self.messaging.delete_topic( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_subscribers(self, m): + @respx.mock + async def test_list_subscribers(self): data = { "total": 5.0, "subscribers": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.list_subscribers( + response = await self.messaging.list_subscribers( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_subscriber(self, m): + @respx.mock + async def test_create_subscriber(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1290,21 +1135,18 @@ def test_create_subscriber(self, m): "providerType": "email", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.create_subscriber( + response = await self.messaging.create_subscriber( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_subscriber(self, m): + @respx.mock + async def test_get_subscriber(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1326,29 +1168,23 @@ def test_get_subscriber(self, m): "providerType": "email", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.get_subscriber( + response = await self.messaging.get_subscriber( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_subscriber(self, m): + @respx.mock + async def test_delete_subscriber(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.messaging.delete_subscriber( + response = await self.messaging.delete_subscriber( '', '', ) diff --git a/test/services/test_mongo.py b/test/services/test_mongo.py index 75b37bfa..6602ce9f 100644 --- a/test/services/test_mongo.py +++ b/test/services/test_mongo.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.mongo import Mongo -class MongoServiceTest(unittest.TestCase): +class MongoServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.mongo = Mongo(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "databases": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.list() + response = await self.mongo.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -80,36 +81,30 @@ def test_create(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.create( + response = await self.mongo.create( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_specifications(self, m): + @respx.mock + async def test_list_specifications(self): data = { "specifications": [], "total": 9.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.list_specifications() + response = await self.mongo.list_specifications() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -158,19 +153,16 @@ def test_get(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.get( + response = await self.mongo.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -219,52 +211,43 @@ def test_update(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.update( + response = await self.mongo.update( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.delete( + response = await self.mongo.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_backups(self, m): + @respx.mock + async def test_list_backups(self): data = { "total": 5.0, "backups": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.list_backups( + response = await self.mongo.list_backups( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_backup(self, m): + @respx.mock + async def test_create_backup(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -280,37 +263,31 @@ def test_create_backup(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.create_backup( + response = await self.mongo.create_backup( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_backup_policies(self, m): + @respx.mock + async def test_list_backup_policies(self): data = { "total": 5.0, "policies": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.list_backup_policies( + response = await self.mongo.list_backup_policies( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_backup_policy(self, m): + @respx.mock + async def test_create_backup_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -324,13 +301,10 @@ def test_create_backup_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.create_backup_policy( + response = await self.mongo.create_backup_policy( '', '', '', @@ -339,8 +313,8 @@ def test_create_backup_policy(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_backup_policy(self, m): + @respx.mock + async def test_get_backup_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -354,20 +328,17 @@ def test_get_backup_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.get_backup_policy( + response = await self.mongo.get_backup_policy( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_backup_policy(self, m): + @respx.mock + async def test_update_backup_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -381,36 +352,30 @@ def test_update_backup_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.update_backup_policy( + response = await self.mongo.update_backup_policy( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_backup_policy(self, m): + @respx.mock + async def test_delete_backup_policy(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.delete_backup_policy( + response = await self.mongo.delete_backup_policy( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_backup_storage(self, m): + @respx.mock + async def test_update_backup_storage(self): data = { "provider": "s3", "bucket": "my-backup-bucket", @@ -419,13 +384,10 @@ def test_update_backup_storage(self, m): "endpoint": "https:\/\/minio.example.com", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.update_backup_storage( + response = await self.mongo.update_backup_storage( '', 's3', '', @@ -434,8 +396,8 @@ def test_update_backup_storage(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_backup(self, m): + @respx.mock + async def test_get_backup(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -451,54 +413,45 @@ def test_get_backup(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.get_backup( + response = await self.mongo.get_backup( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_backup(self, m): + @respx.mock + async def test_delete_backup(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.delete_backup( + response = await self.mongo.delete_backup( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_branches(self, m): + @respx.mock + async def test_list_branches(self): data = { "total": 2.0, "branches": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.list_branches( + response = await self.mongo.list_branches( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_branch(self, m): + @respx.mock + async def test_create_branch(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -547,19 +500,16 @@ def test_create_branch(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.create_branch( + response = await self.mongo.create_branch( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_branch(self, m): + @respx.mock + async def test_delete_branch(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -608,20 +558,17 @@ def test_delete_branch(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.delete_branch( + response = await self.mongo.delete_branch( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_credentials(self, m): + @respx.mock + async def test_update_credentials(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -633,19 +580,16 @@ def test_update_credentials(self, m): "errorMessage": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.update_credentials( + response = await self.mongo.update_credentials( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_failover(self, m): + @respx.mock + async def test_create_failover(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -694,19 +638,16 @@ def test_create_failover(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.create_failover( + response = await self.mongo.create_failover( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_maintenance(self, m): + @respx.mock + async def test_update_maintenance(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -755,21 +696,18 @@ def test_update_maintenance(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.update_maintenance( + response = await self.mongo.update_maintenance( '', 'sun', 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_migration(self, m): + @respx.mock + async def test_create_migration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -818,56 +756,47 @@ def test_create_migration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.create_migration( + response = await self.mongo.create_migration( '', 'shared', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_operations(self, m): + @respx.mock + async def test_list_operations(self): data = { "total": 5.0, "operations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.list_operations( + response = await self.mongo.list_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_pitr(self, m): + @respx.mock + async def test_get_pitr(self): data = { "earliest": "2020-10-15T06:38:00.000+00:00", "latest": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.get_pitr( + response = await self.mongo.get_pitr( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_replicas(self, m): + @respx.mock + async def test_get_replicas(self): data = { "replicas": 2.0, "syncMode": "async", @@ -877,37 +806,31 @@ def test_get_replicas(self, m): "members": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.get_replicas( + response = await self.mongo.get_replicas( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_restorations(self, m): + @respx.mock + async def test_list_restorations(self): data = { "total": 5.0, "restorations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.list_restorations( + response = await self.mongo.list_restorations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_restoration(self, m): + @respx.mock + async def test_create_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -919,19 +842,16 @@ def test_create_restoration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.create_restoration( + response = await self.mongo.create_restoration( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_restoration(self, m): + @respx.mock + async def test_get_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -943,20 +863,17 @@ def test_get_restoration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.get_restoration( + response = await self.mongo.get_restoration( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_promote_restoration(self, m): + @respx.mock + async def test_promote_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -968,20 +885,17 @@ def test_promote_restoration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.promote_restoration( + response = await self.mongo.promote_restoration( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_status(self, m): + @respx.mock + async def test_get_status(self): data = { "health": "healthy", "ready": True, @@ -996,19 +910,16 @@ def test_get_status(self, m): "volumes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.get_status( + response = await self.mongo.get_status( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_upgrade(self, m): + @respx.mock + async def test_create_upgrade(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1057,13 +968,10 @@ def test_create_upgrade(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mongo.create_upgrade( + response = await self.mongo.create_upgrade( '', '', ) diff --git a/test/services/test_mysql.py b/test/services/test_mysql.py index 3ea4f7d3..ef36d811 100644 --- a/test/services/test_mysql.py +++ b/test/services/test_mysql.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.mysql import Mysql -class MysqlServiceTest(unittest.TestCase): +class MysqlServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.mysql = Mysql(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "databases": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.list() + response = await self.mysql.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -80,36 +81,30 @@ def test_create(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.create( + response = await self.mysql.create( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_specifications(self, m): + @respx.mock + async def test_list_specifications(self): data = { "specifications": [], "total": 9.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.list_specifications() + response = await self.mysql.list_specifications() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -158,19 +153,16 @@ def test_get(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.get( + response = await self.mysql.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -219,52 +211,43 @@ def test_update(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.update( + response = await self.mysql.update( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.delete( + response = await self.mysql.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_backups(self, m): + @respx.mock + async def test_list_backups(self): data = { "total": 5.0, "backups": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.list_backups( + response = await self.mysql.list_backups( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_backup(self, m): + @respx.mock + async def test_create_backup(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -280,37 +263,31 @@ def test_create_backup(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.create_backup( + response = await self.mysql.create_backup( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_backup_policies(self, m): + @respx.mock + async def test_list_backup_policies(self): data = { "total": 5.0, "policies": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.list_backup_policies( + response = await self.mysql.list_backup_policies( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_backup_policy(self, m): + @respx.mock + async def test_create_backup_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -324,13 +301,10 @@ def test_create_backup_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.create_backup_policy( + response = await self.mysql.create_backup_policy( '', '', '', @@ -339,8 +313,8 @@ def test_create_backup_policy(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_backup_policy(self, m): + @respx.mock + async def test_get_backup_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -354,20 +328,17 @@ def test_get_backup_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.get_backup_policy( + response = await self.mysql.get_backup_policy( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_backup_policy(self, m): + @respx.mock + async def test_update_backup_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -381,36 +352,30 @@ def test_update_backup_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.update_backup_policy( + response = await self.mysql.update_backup_policy( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_backup_policy(self, m): + @respx.mock + async def test_delete_backup_policy(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.delete_backup_policy( + response = await self.mysql.delete_backup_policy( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_backup_storage(self, m): + @respx.mock + async def test_update_backup_storage(self): data = { "provider": "s3", "bucket": "my-backup-bucket", @@ -419,13 +384,10 @@ def test_update_backup_storage(self, m): "endpoint": "https:\/\/minio.example.com", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.update_backup_storage( + response = await self.mysql.update_backup_storage( '', 's3', '', @@ -434,8 +396,8 @@ def test_update_backup_storage(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_backup(self, m): + @respx.mock + async def test_get_backup(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -451,54 +413,45 @@ def test_get_backup(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.get_backup( + response = await self.mysql.get_backup( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_backup(self, m): + @respx.mock + async def test_delete_backup(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.delete_backup( + response = await self.mysql.delete_backup( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_branches(self, m): + @respx.mock + async def test_list_branches(self): data = { "total": 2.0, "branches": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.list_branches( + response = await self.mysql.list_branches( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_branch(self, m): + @respx.mock + async def test_create_branch(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -547,19 +500,16 @@ def test_create_branch(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.create_branch( + response = await self.mysql.create_branch( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_branch(self, m): + @respx.mock + async def test_delete_branch(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -608,20 +558,17 @@ def test_delete_branch(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.delete_branch( + response = await self.mysql.delete_branch( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_credentials(self, m): + @respx.mock + async def test_update_credentials(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -633,19 +580,16 @@ def test_update_credentials(self, m): "errorMessage": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.update_credentials( + response = await self.mysql.update_credentials( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_execution(self, m): + @respx.mock + async def test_create_execution(self): data = { "rows": [], "rowCount": 1.0, @@ -655,20 +599,17 @@ def test_create_execution(self, m): "bytes": 1024.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.create_execution( + response = await self.mysql.create_execution( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_failover(self, m): + @respx.mock + async def test_create_failover(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -717,19 +658,16 @@ def test_create_failover(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.create_failover( + response = await self.mysql.create_failover( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_maintenance(self, m): + @respx.mock + async def test_update_maintenance(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -778,21 +716,18 @@ def test_update_maintenance(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.update_maintenance( + response = await self.mysql.update_maintenance( '', 'sun', 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_migration(self, m): + @respx.mock + async def test_create_migration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -841,56 +776,47 @@ def test_create_migration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.create_migration( + response = await self.mysql.create_migration( '', 'shared', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_operations(self, m): + @respx.mock + async def test_list_operations(self): data = { "total": 5.0, "operations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.list_operations( + response = await self.mysql.list_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_pitr(self, m): + @respx.mock + async def test_get_pitr(self): data = { "earliest": "2020-10-15T06:38:00.000+00:00", "latest": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.get_pitr( + response = await self.mysql.get_pitr( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_pooler(self, m): + @respx.mock + async def test_get_pooler(self): data = { "enabled": True, "mode": "transaction", @@ -904,19 +830,16 @@ def test_get_pooler(self, m): "poolerMemoryLimit": "128Mi", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.get_pooler( + response = await self.mysql.get_pooler( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_pooler(self, m): + @respx.mock + async def test_update_pooler(self): data = { "enabled": True, "mode": "transaction", @@ -930,19 +853,16 @@ def test_update_pooler(self, m): "poolerMemoryLimit": "128Mi", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.update_pooler( + response = await self.mysql.update_pooler( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_replicas(self, m): + @respx.mock + async def test_get_replicas(self): data = { "replicas": 2.0, "syncMode": "async", @@ -952,37 +872,31 @@ def test_get_replicas(self, m): "members": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.get_replicas( + response = await self.mysql.get_replicas( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_restorations(self, m): + @respx.mock + async def test_list_restorations(self): data = { "total": 5.0, "restorations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.list_restorations( + response = await self.mysql.list_restorations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_restoration(self, m): + @respx.mock + async def test_create_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -994,19 +908,16 @@ def test_create_restoration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.create_restoration( + response = await self.mysql.create_restoration( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_restoration(self, m): + @respx.mock + async def test_get_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1018,20 +929,17 @@ def test_get_restoration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.get_restoration( + response = await self.mysql.get_restoration( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_promote_restoration(self, m): + @respx.mock + async def test_promote_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1043,20 +951,17 @@ def test_promote_restoration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.promote_restoration( + response = await self.mysql.promote_restoration( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_status(self, m): + @respx.mock + async def test_get_status(self): data = { "health": "healthy", "ready": True, @@ -1071,19 +976,16 @@ def test_get_status(self, m): "volumes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.get_status( + response = await self.mysql.get_status( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_upgrade(self, m): + @respx.mock + async def test_create_upgrade(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1132,13 +1034,10 @@ def test_create_upgrade(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.mysql.create_upgrade( + response = await self.mysql.create_upgrade( '', '', ) diff --git a/test/services/test_oauth2.py b/test/services/test_oauth2.py index da2520ee..3fba18e6 100644 --- a/test/services/test_oauth2.py +++ b/test/services/test_oauth2.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,63 +9,57 @@ from appwrite.services.oauth2 import Oauth2 -class Oauth2ServiceTest(unittest.TestCase): +class Oauth2ServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.oauth2 = Oauth2(self.client) - @requests_mock.Mocker() - def test_approve(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_approve(self): data = { "redirectUrl": "https:\/\/example.com\/callback?code=abcde&state=fghij", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.approve( + response = await self.oauth2.approve( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_authorize(self, m): + @respx.mock + async def test_authorize(self): data = { "grantId": "5e5ea5c16897e", "redirectUrl": "https:\/\/example.com\/callback?code=abcde&state=fghij", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.authorize() + response = await self.oauth2.authorize() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_authorize_post(self, m): + @respx.mock + async def test_authorize_post(self): data = { "grantId": "5e5ea5c16897e", "redirectUrl": "https:\/\/example.com\/callback?code=abcde&state=fghij", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.authorize_post() + response = await self.oauth2.authorize_post() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_device_authorization(self, m): + @respx.mock + async def test_create_device_authorization(self): data = { "device_code": "5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a", "user_code": "ABCD-EFGH", @@ -74,17 +69,14 @@ def test_create_device_authorization(self, m): "interval": 5.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.create_device_authorization() + response = await self.oauth2.create_device_authorization() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_grant(self, m): + @respx.mock + async def test_create_grant(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -100,19 +92,16 @@ def test_create_grant(self, m): "expire": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.create_grant( + response = await self.oauth2.create_grant( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_grant(self, m): + @respx.mock + async def test_get_grant(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -128,120 +117,99 @@ def test_get_grant(self, m): "expire": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.get_grant( + response = await self.oauth2.get_grant( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_introspect(self, m): + @respx.mock + async def test_introspect(self): data = { "active": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.introspect( + response = await self.oauth2.introspect( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_organizations(self, m): + @respx.mock + async def test_list_organizations(self): data = { "total": 5.0, "organizations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.list_organizations() + response = await self.oauth2.list_organizations() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_par(self, m): + @respx.mock + async def test_create_par(self): data = { "request_uri": "urn:appwrite:oauth2:request:5e5ea5c16897e", "expires_in": 600.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.create_par( + response = await self.oauth2.create_par( '', 'https://example.com', 'code', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_projects(self, m): + @respx.mock + async def test_list_projects(self): data = { "total": 5.0, "projects": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.list_projects() + response = await self.oauth2.list_projects() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_reject(self, m): + @respx.mock + async def test_reject(self): data = { "redirectUrl": "https:\/\/example.com\/callback?error=access_denied&state=fghij", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.reject( + response = await self.oauth2.reject( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_revoke(self, m): + @respx.mock + async def test_revoke(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.revoke( + response = await self.oauth2.revoke( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_token(self, m): + @respx.mock + async def test_create_token(self): data = { "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...", "token_type": "Bearer", @@ -250,13 +218,10 @@ def test_create_token(self, m): "scope": "openid email profile", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.oauth2.create_token( + response = await self.oauth2.create_token( '', ) self.assertEqual(response.to_dict(), data) diff --git a/test/services/test_organization.py b/test/services/test_organization.py index 41206a71..8f9b930f 100644 --- a/test/services/test_organization.py +++ b/test/services/test_organization.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,14 +9,17 @@ from appwrite.services.organization import Organization -class OrganizationServiceTest(unittest.TestCase): +class OrganizationServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.organization = Organization(self.client) - @requests_mock.Mocker() - def test_get(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -104,17 +108,14 @@ def test_get(self, m): "projects": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.get() + response = await self.organization.get() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -203,48 +204,39 @@ def test_update(self, m): "projects": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.update( + response = await self.organization.update( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.delete() + response = await self.organization.delete() self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_installations(self, m): + @respx.mock + async def test_list_installations(self): data = { "total": 5.0, "installations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.list_installations() + response = await self.organization.list_installations() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_installation(self, m): + @respx.mock + async def test_create_installation(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -257,19 +249,16 @@ def test_create_installation(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.create_installation( + response = await self.organization.create_installation( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_installation(self, m): + @respx.mock + async def test_get_installation(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -282,19 +271,16 @@ def test_get_installation(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.get_installation( + response = await self.organization.get_installation( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_installation(self, m): + @respx.mock + async def test_update_installation(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -307,50 +293,41 @@ def test_update_installation(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.update_installation( + response = await self.organization.update_installation( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_installation(self, m): + @respx.mock + async def test_delete_installation(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.delete_installation( + response = await self.organization.delete_installation( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_memberships(self, m): + @respx.mock + async def test_list_memberships(self): data = { "total": 5.0, "memberships": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.list_memberships() + response = await self.organization.list_memberships() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_membership(self, m): + @respx.mock + async def test_create_membership(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -369,19 +346,16 @@ def test_create_membership(self, m): "roles": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.create_membership( + response = await self.organization.create_membership( [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_membership(self, m): + @respx.mock + async def test_get_membership(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -400,19 +374,16 @@ def test_get_membership(self, m): "roles": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.get_membership( + response = await self.organization.get_membership( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_membership(self, m): + @respx.mock + async def test_update_membership(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -431,51 +402,42 @@ def test_update_membership(self, m): "roles": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.update_membership( + response = await self.organization.update_membership( '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_membership(self, m): + @respx.mock + async def test_delete_membership(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.delete_membership( + response = await self.organization.delete_membership( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_projects(self, m): + @respx.mock + async def test_list_projects(self): data = { "total": 5.0, "projects": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.list_projects() + response = await self.organization.list_projects() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_project(self, m): + @respx.mock + async def test_create_project(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -505,20 +467,17 @@ def test_create_project(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.create_project( + response = await self.organization.create_project( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_project(self, m): + @respx.mock + async def test_get_project(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -548,19 +507,16 @@ def test_get_project(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.get_project( + response = await self.organization.get_project( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_project(self, m): + @respx.mock + async def test_update_project(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -590,53 +546,44 @@ def test_update_project(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.update_project( + response = await self.organization.update_project( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_project(self, m): + @respx.mock + async def test_delete_project(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.delete_project( + response = await self.organization.delete_project( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_project_keys(self, m): + @respx.mock + async def test_list_project_keys(self): data = { "total": 5.0, "keys": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.list_project_keys( + response = await self.organization.list_project_keys( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_ephemeral_project_key(self, m): + @respx.mock + async def test_create_ephemeral_project_key(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -650,21 +597,18 @@ def test_create_ephemeral_project_key(self, m): "sdks": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.create_ephemeral_project_key( + response = await self.organization.create_ephemeral_project_key( '', [], 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_project_key(self, m): + @respx.mock + async def test_get_project_key(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -678,20 +622,17 @@ def test_get_project_key(self, m): "sdks": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.get_project_key( + response = await self.organization.get_project_key( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_project_key(self, m): + @respx.mock + async def test_update_project_key(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -705,13 +646,10 @@ def test_update_project_key(self, m): "sdks": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.update_project_key( + response = await self.organization.update_project_key( '', '', '', @@ -719,17 +657,14 @@ def test_update_project_key(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_project_key(self, m): + @respx.mock + async def test_delete_project_key(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.organization.delete_project_key( + response = await self.organization.delete_project_key( '', '', ) diff --git a/test/services/test_postgresql.py b/test/services/test_postgresql.py index 756a1305..cc8cf4a2 100644 --- a/test/services/test_postgresql.py +++ b/test/services/test_postgresql.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.postgresql import Postgresql -class PostgresqlServiceTest(unittest.TestCase): +class PostgresqlServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.postgresql = Postgresql(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "databases": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.list() + response = await self.postgresql.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -80,36 +81,30 @@ def test_create(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create( + response = await self.postgresql.create( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_specifications(self, m): + @respx.mock + async def test_list_specifications(self): data = { "specifications": [], "total": 9.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.list_specifications() + response = await self.postgresql.list_specifications() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -158,19 +153,16 @@ def test_get(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.get( + response = await self.postgresql.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -219,52 +211,43 @@ def test_update(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.update( + response = await self.postgresql.update( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.delete( + response = await self.postgresql.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_backups(self, m): + @respx.mock + async def test_list_backups(self): data = { "total": 5.0, "backups": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.list_backups( + response = await self.postgresql.list_backups( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_backup(self, m): + @respx.mock + async def test_create_backup(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -280,37 +263,31 @@ def test_create_backup(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create_backup( + response = await self.postgresql.create_backup( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_backup_policies(self, m): + @respx.mock + async def test_list_backup_policies(self): data = { "total": 5.0, "policies": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.list_backup_policies( + response = await self.postgresql.list_backup_policies( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_backup_policy(self, m): + @respx.mock + async def test_create_backup_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -324,13 +301,10 @@ def test_create_backup_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create_backup_policy( + response = await self.postgresql.create_backup_policy( '', '', '', @@ -339,8 +313,8 @@ def test_create_backup_policy(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_backup_policy(self, m): + @respx.mock + async def test_get_backup_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -354,20 +328,17 @@ def test_get_backup_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.get_backup_policy( + response = await self.postgresql.get_backup_policy( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_backup_policy(self, m): + @respx.mock + async def test_update_backup_policy(self): data = { "$id": "5e5ea5c16897e", "name": "Hourly backups", @@ -381,36 +352,30 @@ def test_update_backup_policy(self, m): "enabled": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.update_backup_policy( + response = await self.postgresql.update_backup_policy( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_backup_policy(self, m): + @respx.mock + async def test_delete_backup_policy(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.delete_backup_policy( + response = await self.postgresql.delete_backup_policy( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_backup_storage(self, m): + @respx.mock + async def test_update_backup_storage(self): data = { "provider": "s3", "bucket": "my-backup-bucket", @@ -419,13 +384,10 @@ def test_update_backup_storage(self, m): "endpoint": "https:\/\/minio.example.com", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.update_backup_storage( + response = await self.postgresql.update_backup_storage( '', 's3', '', @@ -434,8 +396,8 @@ def test_update_backup_storage(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_backup(self, m): + @respx.mock + async def test_get_backup(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -451,54 +413,45 @@ def test_get_backup(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.get_backup( + response = await self.postgresql.get_backup( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_backup(self, m): + @respx.mock + async def test_delete_backup(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.delete_backup( + response = await self.postgresql.delete_backup( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_branches(self, m): + @respx.mock + async def test_list_branches(self): data = { "total": 2.0, "branches": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.list_branches( + response = await self.postgresql.list_branches( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_branch(self, m): + @respx.mock + async def test_create_branch(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -547,19 +500,16 @@ def test_create_branch(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create_branch( + response = await self.postgresql.create_branch( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_branch(self, m): + @respx.mock + async def test_delete_branch(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -608,20 +558,17 @@ def test_delete_branch(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.delete_branch( + response = await self.postgresql.delete_branch( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_credentials(self, m): + @respx.mock + async def test_update_credentials(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -633,19 +580,16 @@ def test_update_credentials(self, m): "errorMessage": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.update_credentials( + response = await self.postgresql.update_credentials( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_execution(self, m): + @respx.mock + async def test_create_execution(self): data = { "rows": [], "rowCount": 1.0, @@ -655,39 +599,33 @@ def test_create_execution(self, m): "bytes": 1024.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create_execution( + response = await self.postgresql.create_execution( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_extensions(self, m): + @respx.mock + async def test_list_extensions(self): data = { "installed": [], "available": [], "metadata": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.list_extensions( + response = await self.postgresql.list_extensions( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_extension(self, m): + @respx.mock + async def test_create_extension(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -736,20 +674,17 @@ def test_create_extension(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create_extension( + response = await self.postgresql.create_extension( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_extension(self, m): + @respx.mock + async def test_delete_extension(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -798,20 +733,17 @@ def test_delete_extension(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.delete_extension( + response = await self.postgresql.delete_extension( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_failover(self, m): + @respx.mock + async def test_create_failover(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -860,19 +792,16 @@ def test_create_failover(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create_failover( + response = await self.postgresql.create_failover( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_maintenance(self, m): + @respx.mock + async def test_update_maintenance(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -921,21 +850,18 @@ def test_update_maintenance(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.update_maintenance( + response = await self.postgresql.update_maintenance( '', 'sun', 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_migration(self, m): + @respx.mock + async def test_create_migration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -984,56 +910,47 @@ def test_create_migration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create_migration( + response = await self.postgresql.create_migration( '', 'shared', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_operations(self, m): + @respx.mock + async def test_list_operations(self): data = { "total": 5.0, "operations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.list_operations( + response = await self.postgresql.list_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_pitr(self, m): + @respx.mock + async def test_get_pitr(self): data = { "earliest": "2020-10-15T06:38:00.000+00:00", "latest": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.get_pitr( + response = await self.postgresql.get_pitr( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_pooler(self, m): + @respx.mock + async def test_get_pooler(self): data = { "enabled": True, "mode": "transaction", @@ -1047,19 +964,16 @@ def test_get_pooler(self, m): "poolerMemoryLimit": "128Mi", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.get_pooler( + response = await self.postgresql.get_pooler( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_pooler(self, m): + @respx.mock + async def test_update_pooler(self): data = { "enabled": True, "mode": "transaction", @@ -1073,19 +987,16 @@ def test_update_pooler(self, m): "poolerMemoryLimit": "128Mi", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.update_pooler( + response = await self.postgresql.update_pooler( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_replicas(self, m): + @respx.mock + async def test_get_replicas(self): data = { "replicas": 2.0, "syncMode": "async", @@ -1095,37 +1006,31 @@ def test_get_replicas(self, m): "members": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.get_replicas( + response = await self.postgresql.get_replicas( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_restorations(self, m): + @respx.mock + async def test_list_restorations(self): data = { "total": 5.0, "restorations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.list_restorations( + response = await self.postgresql.list_restorations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_restoration(self, m): + @respx.mock + async def test_create_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1137,19 +1042,16 @@ def test_create_restoration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create_restoration( + response = await self.postgresql.create_restoration( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_restoration(self, m): + @respx.mock + async def test_get_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1161,20 +1063,17 @@ def test_get_restoration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.get_restoration( + response = await self.postgresql.get_restoration( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_promote_restoration(self, m): + @respx.mock + async def test_promote_restoration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1186,20 +1085,17 @@ def test_promote_restoration(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.promote_restoration( + response = await self.postgresql.promote_restoration( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_status(self, m): + @respx.mock + async def test_get_status(self): data = { "health": "healthy", "ready": True, @@ -1214,19 +1110,16 @@ def test_get_status(self, m): "volumes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.get_status( + response = await self.postgresql.get_status( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_upgrade(self, m): + @respx.mock + async def test_create_upgrade(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1275,13 +1168,10 @@ def test_create_upgrade(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.postgresql.create_upgrade( + response = await self.postgresql.create_upgrade( '', '', ) diff --git a/test/services/test_presences.py b/test/services/test_presences.py index 709ebb15..6978a262 100644 --- a/test/services/test_presences.py +++ b/test/services/test_presences.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.presences import Presences -class PresencesServiceTest(unittest.TestCase): +class PresencesServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.presences = Presences(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "presences": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.presences.list() + response = await self.presences.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -41,19 +42,16 @@ def test_get(self, m): "source": "HTTP", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.presences.get( + response = await self.presences.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_upsert(self, m): + @respx.mock + async def test_upsert(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -63,21 +61,18 @@ def test_upsert(self, m): "source": "HTTP", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.presences.upsert( + response = await self.presences.upsert( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -87,29 +82,23 @@ def test_update(self, m): "source": "HTTP", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.presences.update( + response = await self.presences.update( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.presences.delete( + response = await self.presences.delete( '', ) self.assertEqual(response, data) diff --git a/test/services/test_project.py b/test/services/test_project.py index d0c94701..788e015d 100644 --- a/test/services/test_project.py +++ b/test/services/test_project.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,14 +9,17 @@ from appwrite.services.project import Project -class ProjectServiceTest(unittest.TestCase): +class ProjectServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.project = Project(self.client) - @requests_mock.Mocker() - def test_get(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -45,30 +49,24 @@ def test_get(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.get() + response = await self.project.get() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.delete() + response = await self.project.delete() self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_auth_method(self, m): + @respx.mock + async def test_update_auth_method(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -98,36 +96,30 @@ def test_update_auth_method(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_auth_method( + response = await self.project.update_auth_method( 'email-password', True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_environments(self, m): + @respx.mock + async def test_list_environments(self): data = { "total": 5.0, "projects": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.list_environments() + response = await self.project.list_environments() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_environment(self, m): + @respx.mock + async def test_create_environment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -157,20 +149,17 @@ def test_create_environment(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_environment( + response = await self.project.create_environment( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_environment(self, m): + @respx.mock + async def test_get_environment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -200,19 +189,16 @@ def test_get_environment(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.get_environment( + response = await self.project.get_environment( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_environment(self, m): + @respx.mock + async def test_update_environment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -242,51 +228,42 @@ def test_update_environment(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_environment( + response = await self.project.update_environment( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_environment(self, m): + @respx.mock + async def test_delete_environment(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.delete_environment( + response = await self.project.delete_environment( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_keys(self, m): + @respx.mock + async def test_list_keys(self): data = { "total": 5.0, "keys": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.list_keys() + response = await self.project.list_keys() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_ephemeral_key(self, m): + @respx.mock + async def test_create_ephemeral_key(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -300,20 +277,17 @@ def test_create_ephemeral_key(self, m): "sdks": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_ephemeral_key( + response = await self.project.create_ephemeral_key( [], 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_key(self, m): + @respx.mock + async def test_get_key(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -327,19 +301,16 @@ def test_get_key(self, m): "sdks": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.get_key( + response = await self.project.get_key( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_key(self, m): + @respx.mock + async def test_update_key(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -353,36 +324,30 @@ def test_update_key(self, m): "sdks": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_key( + response = await self.project.update_key( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_key(self, m): + @respx.mock + async def test_delete_key(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.delete_key( + response = await self.project.delete_key( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_labels(self, m): + @respx.mock + async def test_update_labels(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -412,35 +377,29 @@ def test_update_labels(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_labels( + response = await self.project.update_labels( [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_mock_phones(self, m): + @respx.mock + async def test_list_mock_phones(self): data = { "total": 5.0, "mockNumbers": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.list_mock_phones() + response = await self.project.list_mock_phones() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mock_phone(self, m): + @respx.mock + async def test_create_mock_phone(self): data = { "number": "+1612842323", "otp": "123456", @@ -448,20 +407,17 @@ def test_create_mock_phone(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_mock_phone( + response = await self.project.create_mock_phone( '+12065550100', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_mock_phone(self, m): + @respx.mock + async def test_get_mock_phone(self): data = { "number": "+1612842323", "otp": "123456", @@ -469,19 +425,16 @@ def test_get_mock_phone(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.get_mock_phone( + response = await self.project.get_mock_phone( '+12065550100', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mock_phone(self, m): + @respx.mock + async def test_update_mock_phone(self): data = { "number": "+1612842323", "otp": "123456", @@ -489,51 +442,42 @@ def test_update_mock_phone(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_mock_phone( + response = await self.project.update_mock_phone( '+12065550100', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_mock_phone(self, m): + @respx.mock + async def test_delete_mock_phone(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.delete_mock_phone( + response = await self.project.delete_mock_phone( '+12065550100', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_o_auth2_providers(self, m): + @respx.mock + async def test_list_o_auth2_providers(self): data = { "total": 5.0, "providers": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.list_o_auth2_providers() + response = await self.project.list_o_auth2_providers() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_server(self, m): + @respx.mock + async def test_update_o_auth2_server(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -563,20 +507,17 @@ def test_update_o_auth2_server(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_server( + response = await self.project.update_o_auth2_server( True, 'https://example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_amazon(self, m): + @respx.mock + async def test_update_o_auth2_amazon(self): data = { "$id": "github", "enabled": True, @@ -584,17 +525,14 @@ def test_update_o_auth2_amazon(self, m): "clientSecret": "79ffe4000000000000000000000000000000000000000000000000000002de55", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_amazon() + response = await self.project.update_o_auth2_amazon() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_apple(self, m): + @respx.mock + async def test_update_o_auth2_apple(self): data = { "$id": "apple", "enabled": True, @@ -606,17 +544,14 @@ def test_update_o_auth2_apple(self, m): "nativeClientIds": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_apple() + response = await self.project.update_o_auth2_apple() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_appwrite(self, m): + @respx.mock + async def test_update_o_auth2_appwrite(self): data = { "$id": "github", "enabled": True, @@ -624,17 +559,14 @@ def test_update_o_auth2_appwrite(self, m): "clientSecret": "b86afd000000000000000000000000000000000000000000000000000ced5f93", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_appwrite() + response = await self.project.update_o_auth2_appwrite() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_auth0(self, m): + @respx.mock + async def test_update_o_auth2_auth0(self): data = { "$id": "github", "enabled": True, @@ -644,17 +576,14 @@ def test_update_o_auth2_auth0(self, m): "endpoint": "example.us.auth0.com", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_auth0() + response = await self.project.update_o_auth2_auth0() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_authentik(self, m): + @respx.mock + async def test_update_o_auth2_authentik(self): data = { "$id": "github", "enabled": True, @@ -663,17 +592,14 @@ def test_update_o_auth2_authentik(self, m): "endpoint": "example.authentik.com", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_authentik() + response = await self.project.update_o_auth2_authentik() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_autodesk(self, m): + @respx.mock + async def test_update_o_auth2_autodesk(self): data = { "$id": "github", "enabled": True, @@ -681,17 +607,14 @@ def test_update_o_auth2_autodesk(self, m): "clientSecret": "7I000000000000MW", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_autodesk() + response = await self.project.update_o_auth2_autodesk() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_bitbucket(self, m): + @respx.mock + async def test_update_o_auth2_bitbucket(self): data = { "$id": "github", "enabled": True, @@ -699,17 +622,14 @@ def test_update_o_auth2_bitbucket(self, m): "secret": "NMfLZJ00000000000000000000TLQdDx", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_bitbucket() + response = await self.project.update_o_auth2_bitbucket() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_bitly(self, m): + @respx.mock + async def test_update_o_auth2_bitly(self): data = { "$id": "github", "enabled": True, @@ -717,17 +637,14 @@ def test_update_o_auth2_bitly(self, m): "clientSecret": "a13e250000000000000000000000000000d73095", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_bitly() + response = await self.project.update_o_auth2_bitly() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_box(self, m): + @respx.mock + async def test_update_o_auth2_box(self): data = { "$id": "github", "enabled": True, @@ -735,17 +652,14 @@ def test_update_o_auth2_box(self, m): "clientSecret": "OKM1f100000000000000000000eshEif", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_box() + response = await self.project.update_o_auth2_box() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_cloudflare(self, m): + @respx.mock + async def test_update_o_auth2_cloudflare(self): data = { "$id": "github", "enabled": True, @@ -753,17 +667,14 @@ def test_update_o_auth2_cloudflare(self, m): "clientSecret": "cfoc_5Q6YRl0000000000000000000000000000000000003d214f", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_cloudflare() + response = await self.project.update_o_auth2_cloudflare() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_dailymotion(self, m): + @respx.mock + async def test_update_o_auth2_dailymotion(self): data = { "$id": "github", "enabled": True, @@ -771,17 +682,14 @@ def test_update_o_auth2_dailymotion(self, m): "apiSecret": "a399a90000000000000000000000000000d90639", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_dailymotion() + response = await self.project.update_o_auth2_dailymotion() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_discord(self, m): + @respx.mock + async def test_update_o_auth2_discord(self): data = { "$id": "github", "enabled": True, @@ -790,17 +698,14 @@ def test_update_o_auth2_discord(self, m): "prompt": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_discord() + response = await self.project.update_o_auth2_discord() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_disqus(self, m): + @respx.mock + async def test_update_o_auth2_disqus(self): data = { "$id": "github", "enabled": True, @@ -808,17 +713,14 @@ def test_update_o_auth2_disqus(self, m): "secretKey": "W7Bykj00000000000000000000000000000000000000000000000000003o43w9", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_disqus() + response = await self.project.update_o_auth2_disqus() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_dropbox(self, m): + @respx.mock + async def test_update_o_auth2_dropbox(self): data = { "$id": "github", "enabled": True, @@ -826,17 +728,14 @@ def test_update_o_auth2_dropbox(self, m): "appSecret": "g200000000000vw", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_dropbox() + response = await self.project.update_o_auth2_dropbox() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_etsy(self, m): + @respx.mock + async def test_update_o_auth2_etsy(self): data = { "$id": "github", "enabled": True, @@ -844,17 +743,14 @@ def test_update_o_auth2_etsy(self, m): "sharedSecret": "tp000000ru", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_etsy() + response = await self.project.update_o_auth2_etsy() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_facebook(self, m): + @respx.mock + async def test_update_o_auth2_facebook(self): data = { "$id": "github", "enabled": True, @@ -862,17 +758,14 @@ def test_update_o_auth2_facebook(self, m): "appSecret": "2d0b2800000000000000000000d38af4", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_facebook() + response = await self.project.update_o_auth2_facebook() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_figma(self, m): + @respx.mock + async def test_update_o_auth2_figma(self): data = { "$id": "github", "enabled": True, @@ -880,17 +773,14 @@ def test_update_o_auth2_figma(self, m): "clientSecret": "yEpOYn0000000000000000004iIsU5", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_figma() + response = await self.project.update_o_auth2_figma() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_fusion_auth(self, m): + @respx.mock + async def test_update_o_auth2_fusion_auth(self): data = { "$id": "github", "enabled": True, @@ -899,17 +789,14 @@ def test_update_o_auth2_fusion_auth(self, m): "endpoint": "example.fusionauth.io", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_fusion_auth() + response = await self.project.update_o_auth2_fusion_auth() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_git_hub(self, m): + @respx.mock + async def test_update_o_auth2_git_hub(self): data = { "$id": "github", "enabled": True, @@ -918,17 +805,14 @@ def test_update_o_auth2_git_hub(self, m): "prompt": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_git_hub() + response = await self.project.update_o_auth2_git_hub() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_gitlab(self, m): + @respx.mock + async def test_update_o_auth2_gitlab(self): data = { "$id": "github", "enabled": True, @@ -937,17 +821,14 @@ def test_update_o_auth2_gitlab(self, m): "endpoint": "https:\/\/gitlab.com", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_gitlab() + response = await self.project.update_o_auth2_gitlab() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_google(self, m): + @respx.mock + async def test_update_o_auth2_google(self): data = { "$id": "github", "enabled": True, @@ -958,17 +839,14 @@ def test_update_o_auth2_google(self, m): "nativeClientIds": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_google() + response = await self.project.update_o_auth2_google() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_hugging_face(self, m): + @respx.mock + async def test_update_o_auth2_hugging_face(self): data = { "$id": "github", "enabled": True, @@ -976,17 +854,14 @@ def test_update_o_auth2_hugging_face(self, m): "clientSecret": "oauth_app_secret_wcLhRtl000000000000000000000xbNdLt", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_hugging_face() + response = await self.project.update_o_auth2_hugging_face() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_kakao(self, m): + @respx.mock + async def test_update_o_auth2_kakao(self): data = { "$id": "github", "enabled": True, @@ -995,17 +870,14 @@ def test_update_o_auth2_kakao(self, m): "prompt": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_kakao() + response = await self.project.update_o_auth2_kakao() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_keycloak(self, m): + @respx.mock + async def test_update_o_auth2_keycloak(self): data = { "$id": "github", "enabled": True, @@ -1015,17 +887,14 @@ def test_update_o_auth2_keycloak(self, m): "realmName": "appwrite-realm", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_keycloak() + response = await self.project.update_o_auth2_keycloak() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_kick(self, m): + @respx.mock + async def test_update_o_auth2_kick(self): data = { "$id": "github", "enabled": True, @@ -1033,17 +902,14 @@ def test_update_o_auth2_kick(self, m): "clientSecret": "34ac5600000000000000000000000000000000000000000000000000e830c8b", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_kick() + response = await self.project.update_o_auth2_kick() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_linkedin(self, m): + @respx.mock + async def test_update_o_auth2_linkedin(self): data = { "$id": "github", "enabled": True, @@ -1051,17 +917,14 @@ def test_update_o_auth2_linkedin(self, m): "primaryClientSecret": "WPL_AP1.2Bf0000000000000.\/HtlYw==", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_linkedin() + response = await self.project.update_o_auth2_linkedin() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_microsoft(self, m): + @respx.mock + async def test_update_o_auth2_microsoft(self): data = { "$id": "github", "enabled": True, @@ -1071,17 +934,14 @@ def test_update_o_auth2_microsoft(self, m): "tenant": "common", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_microsoft() + response = await self.project.update_o_auth2_microsoft() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_notion(self, m): + @respx.mock + async def test_update_o_auth2_notion(self): data = { "$id": "github", "enabled": True, @@ -1089,17 +949,14 @@ def test_update_o_auth2_notion(self, m): "oauthClientSecret": "secret_dLUr4b000000000000000000000000000000lFHAa9", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_notion() + response = await self.project.update_o_auth2_notion() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_oidc(self, m): + @respx.mock + async def test_update_o_auth2_oidc(self): data = { "$id": "github", "enabled": True, @@ -1112,17 +969,14 @@ def test_update_o_auth2_oidc(self, m): "userInfoURL": "https:\/\/myoauth.com\/oauth2\/userinfo", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_oidc() + response = await self.project.update_o_auth2_oidc() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_okta(self, m): + @respx.mock + async def test_update_o_auth2_okta(self): data = { "$id": "github", "enabled": True, @@ -1133,17 +987,14 @@ def test_update_o_auth2_okta(self, m): "authorizationServerId": "aus000000000000000h7z", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_okta() + response = await self.project.update_o_auth2_okta() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_paypal(self, m): + @respx.mock + async def test_update_o_auth2_paypal(self): data = { "$id": "github", "enabled": True, @@ -1151,17 +1002,14 @@ def test_update_o_auth2_paypal(self, m): "secretKey": "EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_paypal() + response = await self.project.update_o_auth2_paypal() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_paypal_sandbox(self, m): + @respx.mock + async def test_update_o_auth2_paypal_sandbox(self): data = { "$id": "github", "enabled": True, @@ -1169,17 +1017,14 @@ def test_update_o_auth2_paypal_sandbox(self, m): "secretKey": "EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_paypal_sandbox() + response = await self.project.update_o_auth2_paypal_sandbox() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_podio(self, m): + @respx.mock + async def test_update_o_auth2_podio(self): data = { "$id": "github", "enabled": True, @@ -1187,17 +1032,14 @@ def test_update_o_auth2_podio(self, m): "clientSecret": "Rn247T0000000000000000000000000000000000000000000000000000W2zWTN", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_podio() + response = await self.project.update_o_auth2_podio() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_resend(self, m): + @respx.mock + async def test_update_o_auth2_resend(self): data = { "$id": "github", "enabled": True, @@ -1205,17 +1047,14 @@ def test_update_o_auth2_resend(self, m): "clientSecret": "9c1e4b00000000000000000000000000000000000000000000000000a72d5f4", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_resend() + response = await self.project.update_o_auth2_resend() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_salesforce(self, m): + @respx.mock + async def test_update_o_auth2_salesforce(self): data = { "$id": "github", "enabled": True, @@ -1224,17 +1063,14 @@ def test_update_o_auth2_salesforce(self, m): "prompt": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_salesforce() + response = await self.project.update_o_auth2_salesforce() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_slack(self, m): + @respx.mock + async def test_update_o_auth2_slack(self): data = { "$id": "github", "enabled": True, @@ -1242,17 +1078,14 @@ def test_update_o_auth2_slack(self, m): "clientSecret": "81656000000000000000000000f3d2fd", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_slack() + response = await self.project.update_o_auth2_slack() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_spotify(self, m): + @respx.mock + async def test_update_o_auth2_spotify(self): data = { "$id": "github", "enabled": True, @@ -1260,17 +1093,14 @@ def test_update_o_auth2_spotify(self, m): "clientSecret": "db068a000000000000000000008b5b9f", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_spotify() + response = await self.project.update_o_auth2_spotify() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_stripe(self, m): + @respx.mock + async def test_update_o_auth2_stripe(self): data = { "$id": "github", "enabled": True, @@ -1278,17 +1108,14 @@ def test_update_o_auth2_stripe(self, m): "apiSecretKey": "sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_stripe() + response = await self.project.update_o_auth2_stripe() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_tik_tok(self, m): + @respx.mock + async def test_update_o_auth2_tik_tok(self): data = { "$id": "github", "enabled": True, @@ -1296,17 +1123,14 @@ def test_update_o_auth2_tik_tok(self, m): "clientSecret": "6wXewM00000000000000000000yXnite", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_tik_tok() + response = await self.project.update_o_auth2_tik_tok() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_tradeshift(self, m): + @respx.mock + async def test_update_o_auth2_tradeshift(self): data = { "$id": "github", "enabled": True, @@ -1314,17 +1138,14 @@ def test_update_o_auth2_tradeshift(self, m): "oauth2ClientSecret": "7cb52700-0000-0000-0000-000000ca5b83", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_tradeshift() + response = await self.project.update_o_auth2_tradeshift() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_tradeshift_sandbox(self, m): + @respx.mock + async def test_update_o_auth2_tradeshift_sandbox(self): data = { "$id": "github", "enabled": True, @@ -1332,17 +1153,14 @@ def test_update_o_auth2_tradeshift_sandbox(self, m): "oauth2ClientSecret": "7cb52700-0000-0000-0000-000000ca5b83", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_tradeshift_sandbox() + response = await self.project.update_o_auth2_tradeshift_sandbox() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_twitch(self, m): + @respx.mock + async def test_update_o_auth2_twitch(self): data = { "$id": "github", "enabled": True, @@ -1350,17 +1168,14 @@ def test_update_o_auth2_twitch(self, m): "clientSecret": "pmapue000000000000000000zylw3v", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_twitch() + response = await self.project.update_o_auth2_twitch() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_webflow(self, m): + @respx.mock + async def test_update_o_auth2_webflow(self): data = { "$id": "github", "enabled": True, @@ -1368,17 +1183,14 @@ def test_update_o_auth2_webflow(self, m): "clientSecret": "59bf00000000000000000000000000000000000000000000000000000000fe59", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_webflow() + response = await self.project.update_o_auth2_webflow() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_word_press(self, m): + @respx.mock + async def test_update_o_auth2_word_press(self): data = { "$id": "github", "enabled": True, @@ -1386,17 +1198,14 @@ def test_update_o_auth2_word_press(self, m): "clientSecret": "PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_word_press() + response = await self.project.update_o_auth2_word_press() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_x(self, m): + @respx.mock + async def test_update_o_auth2_x(self): data = { "$id": "github", "enabled": True, @@ -1404,17 +1213,14 @@ def test_update_o_auth2_x(self, m): "secretKey": "tkEPkp00000000000000000000000000000000000000FTxbI9", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_x() + response = await self.project.update_o_auth2_x() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_yahoo(self, m): + @respx.mock + async def test_update_o_auth2_yahoo(self): data = { "$id": "github", "enabled": True, @@ -1422,17 +1228,14 @@ def test_update_o_auth2_yahoo(self, m): "clientSecret": "cf978f0000000000000000000000000000c5e2e9", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_yahoo() + response = await self.project.update_o_auth2_yahoo() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_yandex(self, m): + @respx.mock + async def test_update_o_auth2_yandex(self): data = { "$id": "github", "enabled": True, @@ -1440,17 +1243,14 @@ def test_update_o_auth2_yandex(self, m): "clientSecret": "bbf98500000000000000000000c75a63", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_yandex() + response = await self.project.update_o_auth2_yandex() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_zoho(self, m): + @respx.mock + async def test_update_o_auth2_zoho(self): data = { "$id": "github", "enabled": True, @@ -1459,17 +1259,14 @@ def test_update_o_auth2_zoho(self, m): "prompt": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_zoho() + response = await self.project.update_o_auth2_zoho() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_o_auth2_zoom(self, m): + @respx.mock + async def test_update_o_auth2_zoom(self): data = { "$id": "github", "enabled": True, @@ -1477,17 +1274,14 @@ def test_update_o_auth2_zoom(self, m): "clientSecret": "GAWsG4000000000000000000007U01ON", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_o_auth2_zoom() + response = await self.project.update_o_auth2_zoom() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_o_auth2_provider(self, m): + @respx.mock + async def test_get_o_auth2_provider(self): data = { "$id": "github", "enabled": True, @@ -1496,35 +1290,29 @@ def test_get_o_auth2_provider(self, m): "prompt": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.get_o_auth2_provider( + response = await self.project.get_o_auth2_provider( 'amazon', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_platforms(self, m): + @respx.mock + async def test_list_platforms(self): data = { "total": 5.0, "platforms": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.list_platforms() + response = await self.project.list_platforms() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_android_platform(self, m): + @respx.mock + async def test_create_android_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1535,21 +1323,18 @@ def test_create_android_platform(self, m): "fingerprints": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_android_platform( + response = await self.project.create_android_platform( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_android_platform(self, m): + @respx.mock + async def test_update_android_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1560,21 +1345,18 @@ def test_update_android_platform(self, m): "fingerprints": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_android_platform( + response = await self.project.update_android_platform( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_apple_platform(self, m): + @respx.mock + async def test_create_apple_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1584,21 +1366,18 @@ def test_create_apple_platform(self, m): "bundleIdentifier": "com.company.appname", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_apple_platform( + response = await self.project.create_apple_platform( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_apple_platform(self, m): + @respx.mock + async def test_update_apple_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1608,21 +1387,18 @@ def test_update_apple_platform(self, m): "bundleIdentifier": "com.company.appname", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_apple_platform( + response = await self.project.update_apple_platform( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_linux_platform(self, m): + @respx.mock + async def test_create_linux_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1632,21 +1408,18 @@ def test_create_linux_platform(self, m): "packageName": "com.company.appname", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_linux_platform( + response = await self.project.create_linux_platform( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_linux_platform(self, m): + @respx.mock + async def test_update_linux_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1656,21 +1429,18 @@ def test_update_linux_platform(self, m): "packageName": "com.company.appname", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_linux_platform( + response = await self.project.update_linux_platform( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_web_platform(self, m): + @respx.mock + async def test_create_web_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1680,21 +1450,18 @@ def test_create_web_platform(self, m): "hostname": "app.example.com", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_web_platform( + response = await self.project.create_web_platform( '', '', 'app.example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_web_platform(self, m): + @respx.mock + async def test_update_web_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1704,21 +1471,18 @@ def test_update_web_platform(self, m): "hostname": "app.example.com", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_web_platform( + response = await self.project.update_web_platform( '', '', 'app.example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_windows_platform(self, m): + @respx.mock + async def test_create_windows_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1728,21 +1492,18 @@ def test_create_windows_platform(self, m): "packageIdentifierName": "com.company.appname", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_windows_platform( + response = await self.project.create_windows_platform( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_windows_platform(self, m): + @respx.mock + async def test_update_windows_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1752,21 +1513,18 @@ def test_update_windows_platform(self, m): "packageIdentifierName": "com.company.appname", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_windows_platform( + response = await self.project.update_windows_platform( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_platform(self, m): + @respx.mock + async def test_get_platform(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1776,50 +1534,41 @@ def test_get_platform(self, m): "hostname": "app.example.com", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.get_platform( + response = await self.project.get_platform( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_platform(self, m): + @respx.mock + async def test_delete_platform(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.delete_platform( + response = await self.project.delete_platform( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_policies(self, m): + @respx.mock + async def test_list_policies(self): data = { "total": 10.0, "policies": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.list_policies() + response = await self.project.list_policies() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_deny_aliased_email_policy(self, m): + @respx.mock + async def test_update_deny_aliased_email_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1849,19 +1598,16 @@ def test_update_deny_aliased_email_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_deny_aliased_email_policy( + response = await self.project.update_deny_aliased_email_policy( True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_deny_corporate_email_policy(self, m): + @respx.mock + async def test_update_deny_corporate_email_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1891,19 +1637,16 @@ def test_update_deny_corporate_email_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_deny_corporate_email_policy( + response = await self.project.update_deny_corporate_email_policy( True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_deny_disposable_email_policy(self, m): + @respx.mock + async def test_update_deny_disposable_email_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1933,19 +1676,16 @@ def test_update_deny_disposable_email_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_deny_disposable_email_policy( + response = await self.project.update_deny_disposable_email_policy( True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_deny_free_email_policy(self, m): + @respx.mock + async def test_update_deny_free_email_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1975,19 +1715,16 @@ def test_update_deny_free_email_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_deny_free_email_policy( + response = await self.project.update_deny_free_email_policy( True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_membership_privacy_policy(self, m): + @respx.mock + async def test_update_membership_privacy_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2017,17 +1754,14 @@ def test_update_membership_privacy_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_membership_privacy_policy() + response = await self.project.update_membership_privacy_policy() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa_factors_policy(self, m): + @respx.mock + async def test_update_mfa_factors_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2057,17 +1791,14 @@ def test_update_mfa_factors_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_mfa_factors_policy() + response = await self.project.update_mfa_factors_policy() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_passkey_policy(self, m): + @respx.mock + async def test_update_passkey_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2097,19 +1828,16 @@ def test_update_passkey_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_passkey_policy( + response = await self.project.update_passkey_policy( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_password_dictionary_policy(self, m): + @respx.mock + async def test_update_password_dictionary_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2139,19 +1867,16 @@ def test_update_password_dictionary_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_password_dictionary_policy( + response = await self.project.update_password_dictionary_policy( True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_password_history_policy(self, m): + @respx.mock + async def test_update_password_history_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2181,19 +1906,16 @@ def test_update_password_history_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_password_history_policy( + response = await self.project.update_password_history_policy( 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_password_personal_data_policy(self, m): + @respx.mock + async def test_update_password_personal_data_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2223,19 +1945,16 @@ def test_update_password_personal_data_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_password_personal_data_policy( + response = await self.project.update_password_personal_data_policy( True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_password_pwned_policy(self, m): + @respx.mock + async def test_update_password_pwned_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2265,17 +1984,14 @@ def test_update_password_pwned_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_password_pwned_policy() + response = await self.project.update_password_pwned_policy() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_password_rotation_policy(self, m): + @respx.mock + async def test_update_password_rotation_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2305,17 +2021,14 @@ def test_update_password_rotation_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_password_rotation_policy() + response = await self.project.update_password_rotation_policy() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_password_strength_policy(self, m): + @respx.mock + async def test_update_password_strength_policy(self): data = { "$id": "password-dictionary", "min": 12.0, @@ -2325,17 +2038,14 @@ def test_update_password_strength_policy(self, m): "symbols": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_password_strength_policy() + response = await self.project.update_password_strength_policy() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_session_alert_policy(self, m): + @respx.mock + async def test_update_session_alert_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2365,19 +2075,16 @@ def test_update_session_alert_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_session_alert_policy( + response = await self.project.update_session_alert_policy( True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_session_duration_policy(self, m): + @respx.mock + async def test_update_session_duration_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2407,19 +2114,16 @@ def test_update_session_duration_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_session_duration_policy( + response = await self.project.update_session_duration_policy( 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_session_invalidation_policy(self, m): + @respx.mock + async def test_update_session_invalidation_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2449,19 +2153,16 @@ def test_update_session_invalidation_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_session_invalidation_policy( + response = await self.project.update_session_invalidation_policy( True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_session_limit_policy(self, m): + @respx.mock + async def test_update_session_limit_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2491,19 +2192,16 @@ def test_update_session_limit_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_session_limit_policy( + response = await self.project.update_session_limit_policy( 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_user_limit_policy(self, m): + @respx.mock + async def test_update_user_limit_policy(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2533,38 +2231,32 @@ def test_update_user_limit_policy(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_user_limit_policy( + response = await self.project.update_user_limit_policy( 1, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_policy(self, m): + @respx.mock + async def test_get_policy(self): data = { "$id": "password-dictionary", "enabled": True, "denyList": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.get_policy( + response = await self.project.get_policy( 'password-dictionary', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_protocol(self, m): + @respx.mock + async def test_update_protocol(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2594,20 +2286,17 @@ def test_update_protocol(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_protocol( + response = await self.project.update_protocol( 'rest', True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_service(self, m): + @respx.mock + async def test_update_service(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2637,20 +2326,17 @@ def test_update_service(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_service( + response = await self.project.update_service( 'account', True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_smtp(self, m): + @respx.mock + async def test_update_smtp(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2680,48 +2366,39 @@ def test_update_smtp(self, m): "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_smtp() + response = await self.project.update_smtp() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_smtp_test(self, m): + @respx.mock + async def test_create_smtp_test(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_smtp_test( + response = await self.project.create_smtp_test( [], ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_email_templates(self, m): + @respx.mock + async def test_list_email_templates(self): data = { "total": 5.0, "templates": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.list_email_templates() + response = await self.project.list_email_templates() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_email_template(self, m): + @respx.mock + async def test_update_email_template(self): data = { "templateId": "verification", "locale": "en_us", @@ -2733,19 +2410,16 @@ def test_update_email_template(self, m): "subject": "Please verify your email address", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_email_template( + response = await self.project.update_email_template( 'verification', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_email_template(self, m): + @respx.mock + async def test_get_email_template(self): data = { "templateId": "verification", "locale": "en_us", @@ -2757,35 +2431,29 @@ def test_get_email_template(self, m): "subject": "Please verify your email address", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.get_email_template( + response = await self.project.get_email_template( 'verification', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_variables(self, m): + @respx.mock + async def test_list_variables(self): data = { "total": 5.0, "variables": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.list_variables() + response = await self.project.list_variables() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_variable(self, m): + @respx.mock + async def test_create_variable(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2798,21 +2466,18 @@ def test_create_variable(self, m): "resourceId": "myAwesomeFunction", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.create_variable( + response = await self.project.create_variable( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_variable(self, m): + @respx.mock + async def test_get_variable(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2825,19 +2490,16 @@ def test_get_variable(self, m): "resourceId": "myAwesomeFunction", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.get_variable( + response = await self.project.get_variable( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_variable(self, m): + @respx.mock + async def test_update_variable(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -2850,28 +2512,22 @@ def test_update_variable(self, m): "resourceId": "myAwesomeFunction", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.update_variable( + response = await self.project.update_variable( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_variable(self, m): + @respx.mock + async def test_delete_variable(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.project.delete_variable( + response = await self.project.delete_variable( '', ) self.assertEqual(response, data) diff --git a/test/services/test_proxy.py b/test/services/test_proxy.py index c12c5271..fa67e4d5 100644 --- a/test/services/test_proxy.py +++ b/test/services/test_proxy.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,14 +9,17 @@ from appwrite.services.proxy import Proxy -class ProxyServiceTest(unittest.TestCase): +class ProxyServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.proxy = Proxy(self.client) - @requests_mock.Mocker() - def test_create_invalidation(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_create_invalidation(self): data = { "domain": "appwrite.company.com", "type": "tag", @@ -23,36 +27,30 @@ def test_create_invalidation(self, m): "status": "success", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.create_invalidation( + response = await self.proxy.create_invalidation( 'example.com', 'tag', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_rules(self, m): + @respx.mock + async def test_list_rules(self): data = { "total": 5.0, "rules": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.list_rules() + response = await self.proxy.list_rules() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_api_rule(self, m): + @respx.mock + async def test_create_api_rule(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -71,19 +69,16 @@ def test_create_api_rule(self, m): "protocol": "http", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.create_api_rule( + response = await self.proxy.create_api_rule( 'example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_function_rule(self, m): + @respx.mock + async def test_create_function_rule(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -102,20 +97,17 @@ def test_create_function_rule(self, m): "protocol": "http", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.create_function_rule( + response = await self.proxy.create_function_rule( 'example.com', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_redirect_rule(self, m): + @respx.mock + async def test_create_redirect_rule(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -134,13 +126,10 @@ def test_create_redirect_rule(self, m): "protocol": "http", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.create_redirect_rule( + response = await self.proxy.create_redirect_rule( 'example.com', 'https://example.com', '301', @@ -149,8 +138,8 @@ def test_create_redirect_rule(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_site_rule(self, m): + @respx.mock + async def test_create_site_rule(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -169,20 +158,17 @@ def test_create_site_rule(self, m): "protocol": "http", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.create_site_rule( + response = await self.proxy.create_site_rule( 'example.com', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_smtp_rule(self, m): + @respx.mock + async def test_create_smtp_rule(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -201,20 +187,17 @@ def test_create_smtp_rule(self, m): "protocol": "http", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.create_smtp_rule( + response = await self.proxy.create_smtp_rule( 'example.com', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_rule(self, m): + @respx.mock + async def test_get_rule(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -233,34 +216,28 @@ def test_get_rule(self, m): "protocol": "http", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.get_rule( + response = await self.proxy.get_rule( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_rule(self, m): + @respx.mock + async def test_delete_rule(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.delete_rule( + response = await self.proxy.delete_rule( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_rule_status(self, m): + @respx.mock + async def test_update_rule_status(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -279,13 +256,10 @@ def test_update_rule_status(self, m): "protocol": "http", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.proxy.update_rule_status( + response = await self.proxy.update_rule_status( '', ) self.assertEqual(response.to_dict(), data) diff --git a/test/services/test_sites.py b/test/services/test_sites.py index a1e4354e..4823b1c0 100644 --- a/test/services/test_sites.py +++ b/test/services/test_sites.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.sites import Sites -class SitesServiceTest(unittest.TestCase): +class SitesServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.sites = Sites(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "sites": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.list() + response = await self.sites.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -71,13 +72,10 @@ def test_create(self, m): "fallbackFile": "index.html", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.create( + response = await self.sites.create( '', '', 'analog', @@ -85,40 +83,34 @@ def test_create(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_frameworks(self, m): + @respx.mock + async def test_list_frameworks(self): data = { "total": 5.0, "frameworks": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.list_frameworks() + response = await self.sites.list_frameworks() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_specifications(self, m): + @respx.mock + async def test_list_specifications(self): data = { "total": 5.0, "specifications": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.list_specifications() + response = await self.sites.list_specifications() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -158,19 +150,16 @@ def test_get(self, m): "fallbackFile": "index.html", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.get( + response = await self.sites.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -210,36 +199,30 @@ def test_update(self, m): "fallbackFile": "index.html", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.update( + response = await self.sites.update( '', '', 'analog', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.delete( + response = await self.sites.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_site_deployment(self, m): + @respx.mock + async def test_update_site_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -279,38 +262,32 @@ def test_update_site_deployment(self, m): "fallbackFile": "index.html", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.update_site_deployment( + response = await self.sites.update_site_deployment( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_deployments(self, m): + @respx.mock + async def test_list_deployments(self): data = { "total": 5.0, "deployments": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.list_deployments( + response = await self.sites.list_deployments( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_deployment(self, m): + @respx.mock + async def test_create_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -341,20 +318,17 @@ def test_create_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.create_deployment( + response = await self.sites.create_deployment( '', InputFile.from_bytes(bytearray(), "example.file"), ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_duplicate_deployment(self, m): + @respx.mock + async def test_create_duplicate_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -385,20 +359,17 @@ def test_create_duplicate_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.create_duplicate_deployment( + response = await self.sites.create_duplicate_deployment( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_template_deployment(self, m): + @respx.mock + async def test_create_template_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -429,13 +400,10 @@ def test_create_template_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.create_template_deployment( + response = await self.sites.create_template_deployment( '', '', '', @@ -445,8 +413,8 @@ def test_create_template_deployment(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_vcs_deployment(self, m): + @respx.mock + async def test_create_vcs_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -477,21 +445,18 @@ def test_create_vcs_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.create_vcs_deployment( + response = await self.sites.create_vcs_deployment( '', 'branch', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_deployment(self, m): + @respx.mock + async def test_get_deployment(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -522,52 +487,43 @@ def test_get_deployment(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.get_deployment( + response = await self.sites.get_deployment( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_deployment(self, m): + @respx.mock + async def test_delete_deployment(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.delete_deployment( + response = await self.sites.delete_deployment( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_deployment_download(self, m): + @respx.mock + async def test_get_deployment_download(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.sites.get_deployment_download( + response = await self.sites.get_deployment_download( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_deployment_status(self, m): + @respx.mock + async def test_update_deployment_status(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -598,38 +554,32 @@ def test_update_deployment_status(self, m): "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.update_deployment_status( + response = await self.sites.update_deployment_status( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_logs(self, m): + @respx.mock + async def test_list_logs(self): data = { "total": 5.0, "executions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.list_logs( + response = await self.sites.list_logs( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_log(self, m): + @respx.mock + async def test_get_log(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -651,54 +601,45 @@ def test_get_log(self, m): "duration": 1.23, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.get_log( + response = await self.sites.get_log( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_log(self, m): + @respx.mock + async def test_delete_log(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.delete_log( + response = await self.sites.delete_log( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_variables(self, m): + @respx.mock + async def test_list_variables(self): data = { "total": 5.0, "variables": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.list_variables( + response = await self.sites.list_variables( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_variable(self, m): + @respx.mock + async def test_create_variable(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -711,13 +652,10 @@ def test_create_variable(self, m): "resourceId": "myAwesomeFunction", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.create_variable( + response = await self.sites.create_variable( '', '', '', @@ -725,8 +663,8 @@ def test_create_variable(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_variable(self, m): + @respx.mock + async def test_get_variable(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -739,20 +677,17 @@ def test_get_variable(self, m): "resourceId": "myAwesomeFunction", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.get_variable( + response = await self.sites.get_variable( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_variable(self, m): + @respx.mock + async def test_update_variable(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -765,29 +700,23 @@ def test_update_variable(self, m): "resourceId": "myAwesomeFunction", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.update_variable( + response = await self.sites.update_variable( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_variable(self, m): + @respx.mock + async def test_delete_variable(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.sites.delete_variable( + response = await self.sites.delete_variable( '', '', ) diff --git a/test/services/test_storage.py b/test/services/test_storage.py index 15c0da0a..be64fe73 100644 --- a/test/services/test_storage.py +++ b/test/services/test_storage.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.storage import Storage -class StorageServiceTest(unittest.TestCase): +class StorageServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.storage = Storage(self.client) - @requests_mock.Mocker() - def test_list_buckets(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list_buckets(self): data = { "total": 5.0, "buckets": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.list_buckets() + response = await self.storage.list_buckets() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_bucket(self, m): + @respx.mock + async def test_create_bucket(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -51,20 +52,17 @@ def test_create_bucket(self, m): "totalSize": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.create_bucket( + response = await self.storage.create_bucket( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_bucket(self, m): + @respx.mock + async def test_get_bucket(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -84,19 +82,16 @@ def test_get_bucket(self, m): "totalSize": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.get_bucket( + response = await self.storage.get_bucket( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_bucket(self, m): + @respx.mock + async def test_update_bucket(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -116,53 +111,44 @@ def test_update_bucket(self, m): "totalSize": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.update_bucket( + response = await self.storage.update_bucket( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_bucket(self, m): + @respx.mock + async def test_delete_bucket(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.delete_bucket( + response = await self.storage.delete_bucket( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_files(self, m): + @respx.mock + async def test_list_files(self): data = { "total": 5.0, "files": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.list_files( + response = await self.storage.list_files( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_file(self, m): + @respx.mock + async def test_create_file(self): data = { "$id": "5e5ea5c16897e", "bucketId": "5e5ea5c16897e", @@ -182,21 +168,18 @@ def test_create_file(self, m): "compression": "gzip", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.create_file( + response = await self.storage.create_file( '', '', InputFile.from_bytes(bytearray(), "example.file"), ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_file(self, m): + @respx.mock + async def test_get_file(self): data = { "$id": "5e5ea5c16897e", "bucketId": "5e5ea5c16897e", @@ -216,20 +199,17 @@ def test_get_file(self, m): "compression": "gzip", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.get_file( + response = await self.storage.get_file( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_file(self, m): + @respx.mock + async def test_update_file(self): data = { "$id": "5e5ea5c16897e", "bucketId": "5e5ea5c16897e", @@ -249,77 +229,62 @@ def test_update_file(self, m): "compression": "gzip", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.update_file( + response = await self.storage.update_file( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_file(self, m): + @respx.mock + async def test_delete_file(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.storage.delete_file( + response = await self.storage.delete_file( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_file_download(self, m): + @respx.mock + async def test_get_file_download(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.storage.get_file_download( + response = await self.storage.get_file_download( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_file_preview(self, m): + @respx.mock + async def test_get_file_preview(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.storage.get_file_preview( + response = await self.storage.get_file_preview( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_file_view(self, m): + @respx.mock + async def test_get_file_view(self): data = bytearray() headers = {'Content-Type': 'application/octet-stream'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - body=data, - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, content=bytes(data), headers=headers), ) - response = self.storage.get_file_view( + response = await self.storage.get_file_view( '', '', ) diff --git a/test/services/test_tables_db.py b/test/services/test_tables_db.py index 31151822..a15d96be 100644 --- a/test/services/test_tables_db.py +++ b/test/services/test_tables_db.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.tables_db import TablesDB -class TablesDBServiceTest(unittest.TestCase): +class TablesDBServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.tables_db = TablesDB(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "databases": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.list() + response = await self.tables_db.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -42,52 +43,43 @@ def test_create(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create( + response = await self.tables_db.create( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_specifications(self, m): + @respx.mock + async def test_list_specifications(self): data = { "specifications": [], "total": 9.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.list_specifications() + response = await self.tables_db.list_specifications() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_transactions(self, m): + @respx.mock + async def test_list_transactions(self): data = { "total": 5.0, "transactions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.list_transactions() + response = await self.tables_db.list_transactions() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_transaction(self, m): + @respx.mock + async def test_create_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -97,17 +89,14 @@ def test_create_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_transaction() + response = await self.tables_db.create_transaction() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_transaction(self, m): + @respx.mock + async def test_get_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -117,19 +106,16 @@ def test_get_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.get_transaction( + response = await self.tables_db.get_transaction( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_transaction(self, m): + @respx.mock + async def test_update_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -139,34 +125,28 @@ def test_update_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_transaction( + response = await self.tables_db.update_transaction( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_transaction(self, m): + @respx.mock + async def test_delete_transaction(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.delete_transaction( + response = await self.tables_db.delete_transaction( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_operations(self, m): + @respx.mock + async def test_create_operations(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -176,19 +156,16 @@ def test_create_operations(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_operations( + response = await self.tables_db.create_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -199,19 +176,16 @@ def test_get(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.get( + response = await self.tables_db.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -222,34 +196,28 @@ def test_update(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update( + response = await self.tables_db.update( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.delete( + response = await self.tables_db.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_failover(self, m): + @respx.mock + async def test_create_failover(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -298,37 +266,31 @@ def test_create_failover(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_failover( + response = await self.tables_db.create_failover( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_migrations(self, m): + @respx.mock + async def test_list_migrations(self): data = { "total": 5.0, "migrations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.list_migrations( + response = await self.tables_db.list_migrations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_migration(self, m): + @respx.mock + async def test_create_migration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -349,20 +311,17 @@ def test_create_migration(self, m): "paused": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_migration( + response = await self.tables_db.create_migration( '', 's-1vcpu-1gb', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_migration(self, m): + @respx.mock + async def test_get_migration(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -383,36 +342,30 @@ def test_get_migration(self, m): "paused": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.get_migration( + response = await self.tables_db.get_migration( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_migration(self, m): + @respx.mock + async def test_delete_migration(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.delete_migration( + response = await self.tables_db.delete_migration( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_cutover(self, m): + @respx.mock + async def test_create_cutover(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -433,38 +386,32 @@ def test_create_cutover(self, m): "paused": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_cutover( + response = await self.tables_db.create_cutover( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_operations(self, m): + @respx.mock + async def test_list_operations(self): data = { "total": 5.0, "operations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.list_operations( + response = await self.tables_db.list_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_replicas(self, m): + @respx.mock + async def test_get_replicas(self): data = { "replicas": 2.0, "syncMode": "async", @@ -474,19 +421,16 @@ def test_get_replicas(self, m): "members": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.get_replicas( + response = await self.tables_db.get_replicas( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_status(self, m): + @respx.mock + async def test_get_status(self): data = { "health": "healthy", "ready": True, @@ -501,37 +445,31 @@ def test_get_status(self, m): "volumes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.get_status( + response = await self.tables_db.get_status( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_tables(self, m): + @respx.mock + async def test_list_tables(self): data = { "total": 5.0, "tables": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.list_tables( + response = await self.tables_db.list_tables( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_table(self, m): + @respx.mock + async def test_create_table(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -548,21 +486,18 @@ def test_create_table(self, m): "bytesUsed": 1500.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_table( + response = await self.tables_db.create_table( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_table(self, m): + @respx.mock + async def test_get_table(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -579,20 +514,17 @@ def test_get_table(self, m): "bytesUsed": 1500.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.get_table( + response = await self.tables_db.get_table( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_table(self, m): + @respx.mock + async def test_update_table(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -609,55 +541,46 @@ def test_update_table(self, m): "bytesUsed": 1500.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_table( + response = await self.tables_db.update_table( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_table(self, m): + @respx.mock + async def test_delete_table(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.delete_table( + response = await self.tables_db.delete_table( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_columns(self, m): + @respx.mock + async def test_list_columns(self): data = { "total": 5.0, "columns": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.list_columns( + response = await self.tables_db.list_columns( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_big_int_column(self, m): + @respx.mock + async def test_create_big_int_column(self): data = { "key": "count", "description": "Name shown on the public profile.", @@ -669,13 +592,10 @@ def test_create_big_int_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_big_int_column( + response = await self.tables_db.create_big_int_column( '', '', '', @@ -683,8 +603,8 @@ def test_create_big_int_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_big_int_column(self, m): + @respx.mock + async def test_update_big_int_column(self): data = { "key": "count", "description": "Name shown on the public profile.", @@ -696,13 +616,10 @@ def test_update_big_int_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_big_int_column( + response = await self.tables_db.update_big_int_column( '', '', '', @@ -711,8 +628,8 @@ def test_update_big_int_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_boolean_column(self, m): + @respx.mock + async def test_create_boolean_column(self): data = { "key": "isEnabled", "description": "Name shown on the public profile.", @@ -724,13 +641,10 @@ def test_create_boolean_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_boolean_column( + response = await self.tables_db.create_boolean_column( '', '', '', @@ -738,8 +652,8 @@ def test_create_boolean_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_boolean_column(self, m): + @respx.mock + async def test_update_boolean_column(self): data = { "key": "isEnabled", "description": "Name shown on the public profile.", @@ -751,13 +665,10 @@ def test_update_boolean_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_boolean_column( + response = await self.tables_db.update_boolean_column( '', '', '', @@ -766,8 +677,8 @@ def test_update_boolean_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_datetime_column(self, m): + @respx.mock + async def test_create_datetime_column(self): data = { "key": "birthDay", "description": "Name shown on the public profile.", @@ -780,13 +691,10 @@ def test_create_datetime_column(self, m): "format": "datetime", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_datetime_column( + response = await self.tables_db.create_datetime_column( '', '', '', @@ -794,8 +702,8 @@ def test_create_datetime_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_datetime_column(self, m): + @respx.mock + async def test_update_datetime_column(self): data = { "key": "birthDay", "description": "Name shown on the public profile.", @@ -808,13 +716,10 @@ def test_update_datetime_column(self, m): "format": "datetime", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_datetime_column( + response = await self.tables_db.update_datetime_column( '', '', '', @@ -823,8 +728,8 @@ def test_update_datetime_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_email_column(self, m): + @respx.mock + async def test_create_email_column(self): data = { "key": "userEmail", "description": "Name shown on the public profile.", @@ -837,13 +742,10 @@ def test_create_email_column(self, m): "format": "email", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_email_column( + response = await self.tables_db.create_email_column( '', '', '', @@ -851,8 +753,8 @@ def test_create_email_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_email_column(self, m): + @respx.mock + async def test_update_email_column(self): data = { "key": "userEmail", "description": "Name shown on the public profile.", @@ -865,13 +767,10 @@ def test_update_email_column(self, m): "format": "email", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_email_column( + response = await self.tables_db.update_email_column( '', '', '', @@ -880,8 +779,8 @@ def test_update_email_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_enum_column(self, m): + @respx.mock + async def test_create_enum_column(self): data = { "key": "status", "description": "Name shown on the public profile.", @@ -895,13 +794,10 @@ def test_create_enum_column(self, m): "format": "enum", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_enum_column( + response = await self.tables_db.create_enum_column( '', '', '', @@ -910,8 +806,8 @@ def test_create_enum_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_enum_column(self, m): + @respx.mock + async def test_update_enum_column(self): data = { "key": "status", "description": "Name shown on the public profile.", @@ -925,13 +821,10 @@ def test_update_enum_column(self, m): "format": "enum", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_enum_column( + response = await self.tables_db.update_enum_column( '', '', '', @@ -941,8 +834,8 @@ def test_update_enum_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_float_column(self, m): + @respx.mock + async def test_create_float_column(self): data = { "key": "percentageCompleted", "description": "Name shown on the public profile.", @@ -954,13 +847,10 @@ def test_create_float_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_float_column( + response = await self.tables_db.create_float_column( '', '', '', @@ -968,8 +858,8 @@ def test_create_float_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_float_column(self, m): + @respx.mock + async def test_update_float_column(self): data = { "key": "percentageCompleted", "description": "Name shown on the public profile.", @@ -981,13 +871,10 @@ def test_update_float_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_float_column( + response = await self.tables_db.update_float_column( '', '', '', @@ -996,8 +883,8 @@ def test_update_float_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_integer_column(self, m): + @respx.mock + async def test_create_integer_column(self): data = { "key": "count", "description": "Name shown on the public profile.", @@ -1009,13 +896,10 @@ def test_create_integer_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_integer_column( + response = await self.tables_db.create_integer_column( '', '', '', @@ -1023,8 +907,8 @@ def test_create_integer_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_integer_column(self, m): + @respx.mock + async def test_update_integer_column(self): data = { "key": "count", "description": "Name shown on the public profile.", @@ -1036,13 +920,10 @@ def test_update_integer_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_integer_column( + response = await self.tables_db.update_integer_column( '', '', '', @@ -1051,8 +932,8 @@ def test_update_integer_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_ip_column(self, m): + @respx.mock + async def test_create_ip_column(self): data = { "key": "ipAddress", "description": "Name shown on the public profile.", @@ -1065,13 +946,10 @@ def test_create_ip_column(self, m): "format": "ip", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_ip_column( + response = await self.tables_db.create_ip_column( '', '', '', @@ -1079,8 +957,8 @@ def test_create_ip_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_ip_column(self, m): + @respx.mock + async def test_update_ip_column(self): data = { "key": "ipAddress", "description": "Name shown on the public profile.", @@ -1093,13 +971,10 @@ def test_update_ip_column(self, m): "format": "ip", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_ip_column( + response = await self.tables_db.update_ip_column( '', '', '', @@ -1108,8 +983,8 @@ def test_update_ip_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_line_column(self, m): + @respx.mock + async def test_create_line_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1121,13 +996,10 @@ def test_create_line_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_line_column( + response = await self.tables_db.create_line_column( '', '', '', @@ -1135,8 +1007,8 @@ def test_create_line_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_line_column(self, m): + @respx.mock + async def test_update_line_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1148,13 +1020,10 @@ def test_update_line_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_line_column( + response = await self.tables_db.update_line_column( '', '', '', @@ -1162,8 +1031,8 @@ def test_update_line_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_longtext_column(self, m): + @respx.mock + async def test_create_longtext_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1175,13 +1044,10 @@ def test_create_longtext_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_longtext_column( + response = await self.tables_db.create_longtext_column( '', '', '', @@ -1189,8 +1055,8 @@ def test_create_longtext_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_longtext_column(self, m): + @respx.mock + async def test_update_longtext_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1202,13 +1068,10 @@ def test_update_longtext_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_longtext_column( + response = await self.tables_db.update_longtext_column( '', '', '', @@ -1217,8 +1080,8 @@ def test_update_longtext_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mediumtext_column(self, m): + @respx.mock + async def test_create_mediumtext_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1230,13 +1093,10 @@ def test_create_mediumtext_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_mediumtext_column( + response = await self.tables_db.create_mediumtext_column( '', '', '', @@ -1244,8 +1104,8 @@ def test_create_mediumtext_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mediumtext_column(self, m): + @respx.mock + async def test_update_mediumtext_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1257,13 +1117,10 @@ def test_update_mediumtext_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_mediumtext_column( + response = await self.tables_db.update_mediumtext_column( '', '', '', @@ -1272,8 +1129,8 @@ def test_update_mediumtext_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_point_column(self, m): + @respx.mock + async def test_create_point_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1285,13 +1142,10 @@ def test_create_point_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_point_column( + response = await self.tables_db.create_point_column( '', '', '', @@ -1299,8 +1153,8 @@ def test_create_point_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_point_column(self, m): + @respx.mock + async def test_update_point_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1312,13 +1166,10 @@ def test_update_point_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_point_column( + response = await self.tables_db.update_point_column( '', '', '', @@ -1326,8 +1177,8 @@ def test_update_point_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_polygon_column(self, m): + @respx.mock + async def test_create_polygon_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1339,13 +1190,10 @@ def test_create_polygon_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_polygon_column( + response = await self.tables_db.create_polygon_column( '', '', '', @@ -1353,8 +1201,8 @@ def test_create_polygon_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_polygon_column(self, m): + @respx.mock + async def test_update_polygon_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1366,13 +1214,10 @@ def test_update_polygon_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_polygon_column( + response = await self.tables_db.update_polygon_column( '', '', '', @@ -1380,8 +1225,8 @@ def test_update_polygon_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_relationship_column(self, m): + @respx.mock + async def test_create_relationship_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1399,13 +1244,10 @@ def test_create_relationship_column(self, m): "side": "parent|child", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_relationship_column( + response = await self.tables_db.create_relationship_column( '', '', '', @@ -1413,8 +1255,8 @@ def test_create_relationship_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_relationship_column(self, m): + @respx.mock + async def test_update_relationship_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1432,21 +1274,18 @@ def test_update_relationship_column(self, m): "side": "parent|child", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_relationship_column( + response = await self.tables_db.update_relationship_column( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_string_column(self, m): + @respx.mock + async def test_create_string_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1459,13 +1298,10 @@ def test_create_string_column(self, m): "size": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_string_column( + response = await self.tables_db.create_string_column( '', '', '', @@ -1474,8 +1310,8 @@ def test_create_string_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_string_column(self, m): + @respx.mock + async def test_update_string_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1488,13 +1324,10 @@ def test_update_string_column(self, m): "size": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_string_column( + response = await self.tables_db.update_string_column( '', '', '', @@ -1503,8 +1336,8 @@ def test_update_string_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_text_column(self, m): + @respx.mock + async def test_create_text_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1516,13 +1349,10 @@ def test_create_text_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_text_column( + response = await self.tables_db.create_text_column( '', '', '', @@ -1530,8 +1360,8 @@ def test_create_text_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_text_column(self, m): + @respx.mock + async def test_update_text_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1543,13 +1373,10 @@ def test_update_text_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_text_column( + response = await self.tables_db.update_text_column( '', '', '', @@ -1558,8 +1385,8 @@ def test_update_text_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_url_column(self, m): + @respx.mock + async def test_create_url_column(self): data = { "key": "githubUrl", "description": "Name shown on the public profile.", @@ -1572,13 +1399,10 @@ def test_create_url_column(self, m): "format": "url", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_url_column( + response = await self.tables_db.create_url_column( '', '', '', @@ -1586,8 +1410,8 @@ def test_create_url_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_url_column(self, m): + @respx.mock + async def test_update_url_column(self): data = { "key": "githubUrl", "description": "Name shown on the public profile.", @@ -1600,13 +1424,10 @@ def test_update_url_column(self, m): "format": "url", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_url_column( + response = await self.tables_db.update_url_column( '', '', '', @@ -1615,8 +1436,8 @@ def test_update_url_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_varchar_column(self, m): + @respx.mock + async def test_create_varchar_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1629,13 +1450,10 @@ def test_create_varchar_column(self, m): "size": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_varchar_column( + response = await self.tables_db.create_varchar_column( '', '', '', @@ -1644,8 +1462,8 @@ def test_create_varchar_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_varchar_column(self, m): + @respx.mock + async def test_update_varchar_column(self): data = { "key": "fullName", "description": "Name shown on the public profile.", @@ -1658,13 +1476,10 @@ def test_update_varchar_column(self, m): "size": 128.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_varchar_column( + response = await self.tables_db.update_varchar_column( '', '', '', @@ -1673,8 +1488,8 @@ def test_update_varchar_column(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_column(self, m): + @respx.mock + async def test_get_column(self): data = { "key": "isEnabled", "description": "Name shown on the public profile.", @@ -1686,57 +1501,48 @@ def test_get_column(self, m): "$updatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.get_column( + response = await self.tables_db.get_column( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_column(self, m): + @respx.mock + async def test_delete_column(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.delete_column( + response = await self.tables_db.delete_column( '', '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_indexes(self, m): + @respx.mock + async def test_list_indexes(self): data = { "total": 5.0, "indexes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.list_indexes( + response = await self.tables_db.list_indexes( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_index(self, m): + @respx.mock + async def test_create_index(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1750,13 +1556,10 @@ def test_create_index(self, m): "lengths": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_index( + response = await self.tables_db.create_index( '', '', '', @@ -1765,8 +1568,8 @@ def test_create_index(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_index(self, m): + @respx.mock + async def test_get_index(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1780,57 +1583,48 @@ def test_get_index(self, m): "lengths": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.get_index( + response = await self.tables_db.get_index( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_index(self, m): + @respx.mock + async def test_delete_index(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.delete_index( + response = await self.tables_db.delete_index( '', '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_rows(self, m): + @respx.mock + async def test_list_rows(self): data = { "total": 5.0, "rows": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.list_rows( + response = await self.tables_db.list_rows( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_row(self, m): + @respx.mock + async def test_create_row(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -1841,13 +1635,10 @@ def test_create_row(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_row( + response = await self.tables_db.create_row( '', '', '', @@ -1856,105 +1647,90 @@ def test_create_row(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_rows(self, m): + @respx.mock + async def test_create_rows(self): data = { "total": 5.0, "rows": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_rows( + response = await self.tables_db.create_rows( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_upsert_rows(self, m): + @respx.mock + async def test_upsert_rows(self): data = { "total": 5.0, "rows": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.upsert_rows( + response = await self.tables_db.upsert_rows( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_rows(self, m): + @respx.mock + async def test_update_rows(self): data = { "total": 5.0, "rows": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_rows( + response = await self.tables_db.update_rows( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_rows(self, m): + @respx.mock + async def test_delete_rows(self): data = { "total": 5.0, "rows": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.delete_rows( + response = await self.tables_db.delete_rows( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_query(self, m): + @respx.mock + async def test_create_query(self): data = { "total": 5.0, "rows": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.create_query( + response = await self.tables_db.create_query( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_row(self, m): + @respx.mock + async def test_get_row(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -1965,13 +1741,10 @@ def test_get_row(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.get_row( + response = await self.tables_db.get_row( '', '', '', @@ -1979,8 +1752,8 @@ def test_get_row(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_upsert_row(self, m): + @respx.mock + async def test_upsert_row(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -1991,13 +1764,10 @@ def test_upsert_row(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.upsert_row( + response = await self.tables_db.upsert_row( '', '', '', @@ -2005,8 +1775,8 @@ def test_upsert_row(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_row(self, m): + @respx.mock + async def test_update_row(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -2017,13 +1787,10 @@ def test_update_row(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.update_row( + response = await self.tables_db.update_row( '', '', '', @@ -2031,25 +1798,22 @@ def test_update_row(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_row(self, m): + @respx.mock + async def test_delete_row(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.delete_row( + response = await self.tables_db.delete_row( '', '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_decrement_row_column(self, m): + @respx.mock + async def test_decrement_row_column(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -2060,13 +1824,10 @@ def test_decrement_row_column(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.decrement_row_column( + response = await self.tables_db.decrement_row_column( '', '', '', @@ -2075,8 +1836,8 @@ def test_decrement_row_column(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_increment_row_column(self, m): + @respx.mock + async def test_increment_row_column(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -2087,13 +1848,10 @@ def test_increment_row_column(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tables_db.increment_row_column( + response = await self.tables_db.increment_row_column( '', '', '', diff --git a/test/services/test_teams.py b/test/services/test_teams.py index 24f7dbb5..660ee81e 100644 --- a/test/services/test_teams.py +++ b/test/services/test_teams.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.teams import Teams -class TeamsServiceTest(unittest.TestCase): +class TeamsServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.teams = Teams(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "teams": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.list() + response = await self.teams.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -41,20 +42,17 @@ def test_create(self, m): "prefs": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.create( + response = await self.teams.create( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -64,19 +62,16 @@ def test_get(self, m): "prefs": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.get( + response = await self.teams.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_name(self, m): + @respx.mock + async def test_update_name(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -86,53 +81,44 @@ def test_update_name(self, m): "prefs": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.update_name( + response = await self.teams.update_name( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.delete( + response = await self.teams.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_installations(self, m): + @respx.mock + async def test_list_installations(self): data = { "total": 5.0, "installations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.list_installations( + response = await self.teams.list_installations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_installation(self, m): + @respx.mock + async def test_create_installation(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -145,20 +131,17 @@ def test_create_installation(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.create_installation( + response = await self.teams.create_installation( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_installation(self, m): + @respx.mock + async def test_get_installation(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -171,20 +154,17 @@ def test_get_installation(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.get_installation( + response = await self.teams.get_installation( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_installation(self, m): + @respx.mock + async def test_update_installation(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -197,54 +177,45 @@ def test_update_installation(self, m): "createdByName": "Walter White", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.update_installation( + response = await self.teams.update_installation( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_installation(self, m): + @respx.mock + async def test_delete_installation(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.delete_installation( + response = await self.teams.delete_installation( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_memberships(self, m): + @respx.mock + async def test_list_memberships(self): data = { "total": 5.0, "memberships": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.list_memberships( + response = await self.teams.list_memberships( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_membership(self, m): + @respx.mock + async def test_create_membership(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -263,20 +234,17 @@ def test_create_membership(self, m): "roles": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.create_membership( + response = await self.teams.create_membership( '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_membership(self, m): + @respx.mock + async def test_get_membership(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -295,20 +263,17 @@ def test_get_membership(self, m): "roles": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.get_membership( + response = await self.teams.get_membership( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_membership(self, m): + @respx.mock + async def test_update_membership(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -327,37 +292,31 @@ def test_update_membership(self, m): "roles": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.update_membership( + response = await self.teams.update_membership( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_membership(self, m): + @respx.mock + async def test_delete_membership(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.delete_membership( + response = await self.teams.delete_membership( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_membership_status(self, m): + @respx.mock + async def test_update_membership_status(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -376,13 +335,10 @@ def test_update_membership_status(self, m): "roles": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.update_membership_status( + response = await self.teams.update_membership_status( '', '', '', @@ -390,32 +346,26 @@ def test_update_membership_status(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_prefs(self, m): + @respx.mock + async def test_get_prefs(self): data = {} headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.get_prefs( + response = await self.teams.get_prefs( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_prefs(self, m): + @respx.mock + async def test_update_prefs(self): data = {} headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.teams.update_prefs( + response = await self.teams.update_prefs( '', {}, ) diff --git a/test/services/test_tokens.py b/test/services/test_tokens.py index de5f3f87..786b2e2c 100644 --- a/test/services/test_tokens.py +++ b/test/services/test_tokens.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,33 +9,33 @@ from appwrite.services.tokens import Tokens -class TokensServiceTest(unittest.TestCase): +class TokensServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.tokens = Tokens(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "tokens": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tokens.list( + response = await self.tokens.list( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_file_token(self, m): + @respx.mock + async def test_create_file_token(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -45,20 +46,17 @@ def test_create_file_token(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tokens.create_file_token( + response = await self.tokens.create_file_token( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -69,19 +67,16 @@ def test_get(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tokens.get( + response = await self.tokens.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -92,28 +87,22 @@ def test_update(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tokens.update( + response = await self.tokens.update( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.tokens.delete( + response = await self.tokens.delete( '', ) self.assertEqual(response, data) diff --git a/test/services/test_users.py b/test/services/test_users.py index 4dad6e4c..1a8f108c 100644 --- a/test/services/test_users.py +++ b/test/services/test_users.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.users import Users -class UsersServiceTest(unittest.TestCase): +class UsersServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.users = Users(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "users": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.list() + response = await self.users.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -51,19 +52,16 @@ def test_create(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create( + response = await self.users.create( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_argon2_user(self, m): + @respx.mock + async def test_create_argon2_user(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -83,21 +81,18 @@ def test_create_argon2_user(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_argon2_user( + response = await self.users.create_argon2_user( '', 'email@example.com', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_bcrypt_user(self, m): + @respx.mock + async def test_create_bcrypt_user(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -117,52 +112,43 @@ def test_create_bcrypt_user(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_bcrypt_user( + response = await self.users.create_bcrypt_user( '', 'email@example.com', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_identities(self, m): + @respx.mock + async def test_list_identities(self): data = { "total": 5.0, "identities": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.list_identities() + response = await self.users.list_identities() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_identity(self, m): + @respx.mock + async def test_delete_identity(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.delete_identity( + response = await self.users.delete_identity( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_md5_user(self, m): + @respx.mock + async def test_create_md5_user(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -182,21 +168,18 @@ def test_create_md5_user(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_md5_user( + response = await self.users.create_md5_user( '', 'email@example.com', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_ph_pass_user(self, m): + @respx.mock + async def test_create_ph_pass_user(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -216,21 +199,18 @@ def test_create_ph_pass_user(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_ph_pass_user( + response = await self.users.create_ph_pass_user( '', 'email@example.com', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_scrypt_user(self, m): + @respx.mock + async def test_create_scrypt_user(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -250,13 +230,10 @@ def test_create_scrypt_user(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_scrypt_user( + response = await self.users.create_scrypt_user( '', 'email@example.com', 'password', @@ -268,8 +245,8 @@ def test_create_scrypt_user(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_scrypt_modified_user(self, m): + @respx.mock + async def test_create_scrypt_modified_user(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -289,13 +266,10 @@ def test_create_scrypt_modified_user(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_scrypt_modified_user( + response = await self.users.create_scrypt_modified_user( '', 'email@example.com', 'password', @@ -305,8 +279,8 @@ def test_create_scrypt_modified_user(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_sha_user(self, m): + @respx.mock + async def test_create_sha_user(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -326,21 +300,18 @@ def test_create_sha_user(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_sha_user( + response = await self.users.create_sha_user( '', 'email@example.com', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -360,34 +331,28 @@ def test_get(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.get( + response = await self.users.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.delete( + response = await self.users.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_email(self, m): + @respx.mock + async def test_update_email(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -407,20 +372,17 @@ def test_update_email(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_email( + response = await self.users.update_email( '', 'email@example.com', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_impersonator(self, m): + @respx.mock + async def test_update_impersonator(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -440,37 +402,31 @@ def test_update_impersonator(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_impersonator( + response = await self.users.update_impersonator( '', True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_jwt(self, m): + @respx.mock + async def test_create_jwt(self): data = { "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_jwt( + response = await self.users.create_jwt( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_labels(self, m): + @respx.mock + async def test_update_labels(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -490,38 +446,32 @@ def test_update_labels(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_labels( + response = await self.users.update_labels( '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_memberships(self, m): + @respx.mock + async def test_list_memberships(self): data = { "total": 5.0, "memberships": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.list_memberships( + response = await self.users.list_memberships( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa(self, m): + @respx.mock + async def test_update_mfa(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -541,20 +491,17 @@ def test_update_mfa(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_mfa( + response = await self.users.update_mfa( '', True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa(self, m): + @respx.mock + async def test_update_mfa(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -574,52 +521,43 @@ def test_update_mfa(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_mfa( + response = await self.users.update_mfa( '', True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_mfa_authenticator(self, m): + @respx.mock + async def test_delete_mfa_authenticator(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.delete_mfa_authenticator( + response = await self.users.delete_mfa_authenticator( '', 'totp', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_delete_mfa_authenticator(self, m): + @respx.mock + async def test_delete_mfa_authenticator(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.delete_mfa_authenticator( + response = await self.users.delete_mfa_authenticator( '', 'totp', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_get_mfa_challenge(self, m): + @respx.mock + async def test_get_mfa_challenge(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -628,20 +566,17 @@ def test_get_mfa_challenge(self, m): "code": "446372", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.get_mfa_challenge( + response = await self.users.get_mfa_challenge( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_mfa_factors(self, m): + @respx.mock + async def test_list_mfa_factors(self): data = { "totp": True, "phone": True, @@ -650,19 +585,16 @@ def test_list_mfa_factors(self, m): "custom": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.list_mfa_factors( + response = await self.users.list_mfa_factors( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_mfa_factors(self, m): + @respx.mock + async def test_list_mfa_factors(self): data = { "totp": True, "phone": True, @@ -671,121 +603,100 @@ def test_list_mfa_factors(self, m): "custom": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.list_mfa_factors( + response = await self.users.list_mfa_factors( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_mfa_recovery_codes(self, m): + @respx.mock + async def test_get_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.get_mfa_recovery_codes( + response = await self.users.get_mfa_recovery_codes( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_mfa_recovery_codes(self, m): + @respx.mock + async def test_get_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.get_mfa_recovery_codes( + response = await self.users.get_mfa_recovery_codes( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa_recovery_codes(self, m): + @respx.mock + async def test_update_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_mfa_recovery_codes( + response = await self.users.update_mfa_recovery_codes( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_mfa_recovery_codes(self, m): + @respx.mock + async def test_update_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_mfa_recovery_codes( + response = await self.users.update_mfa_recovery_codes( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mfa_recovery_codes(self, m): + @respx.mock + async def test_create_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_mfa_recovery_codes( + response = await self.users.create_mfa_recovery_codes( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_mfa_recovery_codes(self, m): + @respx.mock + async def test_create_mfa_recovery_codes(self): data = { "recoveryCodes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_mfa_recovery_codes( + response = await self.users.create_mfa_recovery_codes( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_name(self, m): + @respx.mock + async def test_update_name(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -805,38 +716,32 @@ def test_update_name(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_name( + response = await self.users.update_name( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_passkeys(self, m): + @respx.mock + async def test_list_passkeys(self): data = { "total": 5.0, "passkeys": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.list_passkeys( + response = await self.users.list_passkeys( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_passkey(self, m): + @respx.mock + async def test_get_passkey(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -845,20 +750,17 @@ def test_get_passkey(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.get_passkey( + response = await self.users.get_passkey( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_passkey(self, m): + @respx.mock + async def test_update_passkey(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -867,37 +769,31 @@ def test_update_passkey(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_passkey( + response = await self.users.update_passkey( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_passkey(self, m): + @respx.mock + async def test_delete_passkey(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.delete_passkey( + response = await self.users.delete_passkey( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_password(self, m): + @respx.mock + async def test_update_password(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -917,20 +813,17 @@ def test_update_password(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_password( + response = await self.users.update_password( '', 'password', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_phone(self, m): + @respx.mock + async def test_update_phone(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -950,69 +843,57 @@ def test_update_phone(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_phone( + response = await self.users.update_phone( '', '+12065550100', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_prefs(self, m): + @respx.mock + async def test_get_prefs(self): data = {} headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.get_prefs( + response = await self.users.get_prefs( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_prefs(self, m): + @respx.mock + async def test_update_prefs(self): data = {} headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_prefs( + response = await self.users.update_prefs( '', {}, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_sessions(self, m): + @respx.mock + async def test_list_sessions(self): data = { "total": 5.0, "sessions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.list_sessions( + response = await self.users.list_sessions( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_session(self, m): + @respx.mock + async def test_create_session(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1045,50 +926,41 @@ def test_create_session(self, m): "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_session( + response = await self.users.create_session( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_sessions(self, m): + @respx.mock + async def test_delete_sessions(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.delete_sessions( + response = await self.users.delete_sessions( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_delete_session(self, m): + @respx.mock + async def test_delete_session(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.delete_session( + response = await self.users.delete_session( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_status(self, m): + @respx.mock + async def test_update_status(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1108,38 +980,32 @@ def test_update_status(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_status( + response = await self.users.update_status( '', True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_targets(self, m): + @respx.mock + async def test_list_targets(self): data = { "total": 5.0, "targets": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.list_targets( + response = await self.users.list_targets( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_target(self, m): + @respx.mock + async def test_create_target(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1151,13 +1017,10 @@ def test_create_target(self, m): "expired": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_target( + response = await self.users.create_target( '', '', 'email', @@ -1165,8 +1028,8 @@ def test_create_target(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_target(self, m): + @respx.mock + async def test_get_target(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1178,20 +1041,17 @@ def test_get_target(self, m): "expired": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.get_target( + response = await self.users.get_target( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_target(self, m): + @respx.mock + async def test_update_target(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1203,36 +1063,30 @@ def test_update_target(self, m): "expired": True, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_target( + response = await self.users.update_target( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_target(self, m): + @respx.mock + async def test_delete_target(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.delete_target( + response = await self.users.delete_target( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_token(self, m): + @respx.mock + async def test_create_token(self): data = { "$id": "bb8ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1242,19 +1096,16 @@ def test_create_token(self, m): "phrase": "Golden Fox", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.create_token( + response = await self.users.create_token( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_email_verification(self, m): + @respx.mock + async def test_update_email_verification(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1274,20 +1125,17 @@ def test_update_email_verification(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_email_verification( + response = await self.users.update_email_verification( '', True, ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_phone_verification(self, m): + @respx.mock + async def test_update_phone_verification(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -1307,13 +1155,10 @@ def test_update_phone_verification(self, m): "accessedAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.users.update_phone_verification( + response = await self.users.update_phone_verification( '', True, ) diff --git a/test/services/test_vectors_db.py b/test/services/test_vectors_db.py index 2c6f2240..a927ccc1 100644 --- a/test/services/test_vectors_db.py +++ b/test/services/test_vectors_db.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.vectors_db import VectorsDB -class VectorsDBServiceTest(unittest.TestCase): +class VectorsDBServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.vectors_db = VectorsDB(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "databases": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.list() + response = await self.vectors_db.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -42,52 +43,43 @@ def test_create(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.create( + response = await self.vectors_db.create( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_specifications(self, m): + @respx.mock + async def test_list_specifications(self): data = { "specifications": [], "total": 9.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.list_specifications() + response = await self.vectors_db.list_specifications() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_transactions(self, m): + @respx.mock + async def test_list_transactions(self): data = { "total": 5.0, "transactions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.list_transactions() + response = await self.vectors_db.list_transactions() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_transaction(self, m): + @respx.mock + async def test_create_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -97,17 +89,14 @@ def test_create_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.create_transaction() + response = await self.vectors_db.create_transaction() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_transaction(self, m): + @respx.mock + async def test_get_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -117,19 +106,16 @@ def test_get_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.get_transaction( + response = await self.vectors_db.get_transaction( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_transaction(self, m): + @respx.mock + async def test_update_transaction(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -139,34 +125,28 @@ def test_update_transaction(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.update_transaction( + response = await self.vectors_db.update_transaction( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_transaction(self, m): + @respx.mock + async def test_delete_transaction(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.delete_transaction( + response = await self.vectors_db.delete_transaction( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_operations(self, m): + @respx.mock + async def test_create_operations(self): data = { "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -176,19 +156,16 @@ def test_create_operations(self, m): "expiresAt": "2020-10-15T06:38:00.000+00:00", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.create_operations( + response = await self.vectors_db.create_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -199,19 +176,16 @@ def test_get(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.get( + response = await self.vectors_db.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "name": "My Database", @@ -222,53 +196,44 @@ def test_update(self, m): "type": "legacy", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.update( + response = await self.vectors_db.update( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.delete( + response = await self.vectors_db.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_collections(self, m): + @respx.mock + async def test_list_collections(self): data = { "total": 5.0, "collections": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.list_collections( + response = await self.vectors_db.list_collections( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_collection(self, m): + @respx.mock + async def test_create_collection(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -286,13 +251,10 @@ def test_create_collection(self, m): "dimension": 1536.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.create_collection( + response = await self.vectors_db.create_collection( '', '', '', @@ -300,8 +262,8 @@ def test_create_collection(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_collection(self, m): + @respx.mock + async def test_get_collection(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -319,20 +281,17 @@ def test_get_collection(self, m): "dimension": 1536.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.get_collection( + response = await self.vectors_db.get_collection( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_collection(self, m): + @respx.mock + async def test_update_collection(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -350,56 +309,47 @@ def test_update_collection(self, m): "dimension": 1536.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.update_collection( + response = await self.vectors_db.update_collection( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_collection(self, m): + @respx.mock + async def test_delete_collection(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.delete_collection( + response = await self.vectors_db.delete_collection( '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_documents(self, m): + @respx.mock + async def test_list_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.list_documents( + response = await self.vectors_db.list_documents( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_document(self, m): + @respx.mock + async def test_create_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -410,13 +360,10 @@ def test_create_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.create_document( + response = await self.vectors_db.create_document( '', '', '', @@ -425,105 +372,90 @@ def test_create_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_documents(self, m): + @respx.mock + async def test_create_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.create_documents( + response = await self.vectors_db.create_documents( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_upsert_documents(self, m): + @respx.mock + async def test_upsert_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.upsert_documents( + response = await self.vectors_db.upsert_documents( '', '', [], ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_documents(self, m): + @respx.mock + async def test_update_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.update_documents( + response = await self.vectors_db.update_documents( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_documents(self, m): + @respx.mock + async def test_delete_documents(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.delete_documents( + response = await self.vectors_db.delete_documents( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_query(self, m): + @respx.mock + async def test_create_query(self): data = { "total": 5.0, "documents": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.create_query( + response = await self.vectors_db.create_query( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_document(self, m): + @respx.mock + async def test_get_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -534,13 +466,10 @@ def test_get_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.get_document( + response = await self.vectors_db.get_document( '', '', '', @@ -548,8 +477,8 @@ def test_get_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_upsert_document(self, m): + @respx.mock + async def test_upsert_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -560,13 +489,10 @@ def test_upsert_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.upsert_document( + response = await self.vectors_db.upsert_document( '', '', '', @@ -574,8 +500,8 @@ def test_upsert_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_document(self, m): + @respx.mock + async def test_update_document(self): data = { "$id": "5e5ea5c16897e", "$sequence": "1", @@ -586,13 +512,10 @@ def test_update_document(self, m): "$permissions": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.update_document( + response = await self.vectors_db.update_document( '', '', '', @@ -600,44 +523,38 @@ def test_update_document(self, m): data['data'] = {} self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_document(self, m): + @respx.mock + async def test_delete_document(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.delete_document( + response = await self.vectors_db.delete_document( '', '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_list_indexes(self, m): + @respx.mock + async def test_list_indexes(self): data = { "total": 5.0, "indexes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.list_indexes( + response = await self.vectors_db.list_indexes( '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_index(self, m): + @respx.mock + async def test_create_index(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -651,13 +568,10 @@ def test_create_index(self, m): "lengths": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.create_index( + response = await self.vectors_db.create_index( '', '', '', @@ -666,8 +580,8 @@ def test_create_index(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_index(self, m): + @respx.mock + async def test_get_index(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -681,38 +595,32 @@ def test_get_index(self, m): "lengths": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.get_index( + response = await self.vectors_db.get_index( '', '', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_index(self, m): + @respx.mock + async def test_delete_index(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.delete_index( + response = await self.vectors_db.delete_index( '', '', '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_create_failover(self, m): + @respx.mock + async def test_create_failover(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -761,37 +669,31 @@ def test_create_failover(self, m): "error": "", } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.create_failover( + response = await self.vectors_db.create_failover( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_list_operations(self, m): + @respx.mock + async def test_list_operations(self): data = { "total": 5.0, "operations": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.list_operations( + response = await self.vectors_db.list_operations( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_replicas(self, m): + @respx.mock + async def test_get_replicas(self): data = { "replicas": 2.0, "syncMode": "async", @@ -801,19 +703,16 @@ def test_get_replicas(self, m): "members": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.get_replicas( + response = await self.vectors_db.get_replicas( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_status(self, m): + @respx.mock + async def test_get_status(self): data = { "health": "healthy", "ready": True, @@ -828,13 +727,10 @@ def test_get_status(self, m): "volumes": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.vectors_db.get_status( + response = await self.vectors_db.get_status( '', ) self.assertEqual(response.to_dict(), data) diff --git a/test/services/test_waf.py b/test/services/test_waf.py index 8c9e8bec..f827aa68 100644 --- a/test/services/test_waf.py +++ b/test/services/test_waf.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.waf import Waf -class WafServiceTest(unittest.TestCase): +class WafServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.waf = Waf(self.client) - @requests_mock.Mocker() - def test_list_rules(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list_rules(self): data = { "total": 5.0, "rules": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.list_rules() + response = await self.waf.list_rules() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_bypass_rule(self, m): + @respx.mock + async def test_create_bypass_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -49,21 +50,18 @@ def test_create_bypass_rule(self, m): "config": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.create_bypass_rule( + response = await self.waf.create_bypass_rule( '', 'api', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_bypass_rule(self, m): + @respx.mock + async def test_update_bypass_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -81,19 +79,16 @@ def test_update_bypass_rule(self, m): "config": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.update_bypass_rule( + response = await self.waf.update_bypass_rule( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_challenge_rule(self, m): + @respx.mock + async def test_create_challenge_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -114,21 +109,18 @@ def test_create_challenge_rule(self, m): "ttl": 1800.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.create_challenge_rule( + response = await self.waf.create_challenge_rule( '', 'api', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_challenge_rule(self, m): + @respx.mock + async def test_update_challenge_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -149,19 +141,16 @@ def test_update_challenge_rule(self, m): "ttl": 1800.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.update_challenge_rule( + response = await self.waf.update_challenge_rule( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_deny_rule(self, m): + @respx.mock + async def test_create_deny_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -179,21 +168,18 @@ def test_create_deny_rule(self, m): "config": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.create_deny_rule( + response = await self.waf.create_deny_rule( '', 'api', '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_deny_rule(self, m): + @respx.mock + async def test_update_deny_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -211,19 +197,16 @@ def test_update_deny_rule(self, m): "config": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.update_deny_rule( + response = await self.waf.update_deny_rule( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_rate_limit_rule(self, m): + @respx.mock + async def test_create_rate_limit_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -246,13 +229,10 @@ def test_create_rate_limit_rule(self, m): "maxBucketSize": 200.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.create_rate_limit_rule( + response = await self.waf.create_rate_limit_rule( '', 'api', '', @@ -261,8 +241,8 @@ def test_create_rate_limit_rule(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_rate_limit_rule(self, m): + @respx.mock + async def test_update_rate_limit_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -285,19 +265,16 @@ def test_update_rate_limit_rule(self, m): "maxBucketSize": 200.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.update_rate_limit_rule( + response = await self.waf.update_rate_limit_rule( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create_redirect_rule(self, m): + @respx.mock + async def test_create_redirect_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -317,13 +294,10 @@ def test_create_redirect_rule(self, m): "statusCode": 301.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.create_redirect_rule( + response = await self.waf.create_redirect_rule( '', 'api', '', @@ -332,8 +306,8 @@ def test_create_redirect_rule(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update_redirect_rule(self, m): + @respx.mock + async def test_update_redirect_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -353,19 +327,16 @@ def test_update_redirect_rule(self, m): "statusCode": 301.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.update_redirect_rule( + response = await self.waf.update_redirect_rule( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get_rule(self, m): + @respx.mock + async def test_get_rule(self): data = { "$id": "wafRule1", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -383,28 +354,22 @@ def test_get_rule(self, m): "config": {}, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.get_rule( + response = await self.waf.get_rule( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete_rule(self, m): + @respx.mock + async def test_delete_rule(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.waf.delete_rule( + response = await self.waf.delete_rule( '', ) self.assertEqual(response, data) diff --git a/test/services/test_webhooks.py b/test/services/test_webhooks.py index 0f65c6b2..d1f059bf 100644 --- a/test/services/test_webhooks.py +++ b/test/services/test_webhooks.py @@ -1,5 +1,6 @@ import json -import requests_mock +import httpx2 +import respx import unittest from appwrite.client import Client @@ -8,30 +9,30 @@ from appwrite.services.webhooks import Webhooks -class WebhooksServiceTest(unittest.TestCase): +class WebhooksServiceTest(unittest.IsolatedAsyncioTestCase): - def setUp(self): + async def asyncSetUp(self): self.client = Client() self.webhooks = Webhooks(self.client) - @requests_mock.Mocker() - def test_list(self, m): + async def asyncTearDown(self): + await self.client.aclose() + + @respx.mock + async def test_list(self): data = { "total": 5.0, "webhooks": [], } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.webhooks.list() + response = await self.webhooks.list() self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_create(self, m): + @respx.mock + async def test_create(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -49,13 +50,10 @@ def test_create(self, m): "attempts": 10.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.webhooks.create( + response = await self.webhooks.create( '', 'https://example.com/webhook', '', @@ -63,8 +61,8 @@ def test_create(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_get(self, m): + @respx.mock + async def test_get(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -82,19 +80,16 @@ def test_get(self, m): "attempts": 10.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.webhooks.get( + response = await self.webhooks.get( '', ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_update(self, m): + @respx.mock + async def test_update(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -112,13 +107,10 @@ def test_update(self, m): "attempts": 10.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.webhooks.update( + response = await self.webhooks.update( '', '', 'https://example.com/webhook', @@ -126,23 +118,20 @@ def test_update(self, m): ) self.assertEqual(response.to_dict(), data) - @requests_mock.Mocker() - def test_delete(self, m): + @respx.mock + async def test_delete(self): data = '' headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.webhooks.delete( + response = await self.webhooks.delete( '', ) self.assertEqual(response, data) - @requests_mock.Mocker() - def test_update_secret(self, m): + @respx.mock + async def test_update_secret(self): data = { "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", @@ -160,13 +149,10 @@ def test_update_secret(self, m): "attempts": 10.0, } headers = {'Content-Type': 'application/json'} - m.request( - requests_mock.ANY, - requests_mock.ANY, - text=json.dumps(data), - headers=headers, + respx.route().mock( + return_value=httpx2.Response(200, text=json.dumps(data), headers=headers), ) - response = self.webhooks.update_secret( + response = await self.webhooks.update_secret( '', ) self.assertEqual(response.to_dict(), data) diff --git a/test/test_async_client.py b/test/test_async_client.py new file mode 100644 index 00000000..b592d132 --- /dev/null +++ b/test/test_async_client.py @@ -0,0 +1,114 @@ +import asyncio +import unittest + +import httpx2 +import respx + +from appwrite.client import Client +from appwrite.exception import AppwriteException +from appwrite.input_file import InputFile +from appwrite.services.storage import Storage + + +class AsyncClientTest(unittest.IsolatedAsyncioTestCase): + + @respx.mock + async def test_requests_are_served_concurrently(self): + in_flight = 0 + peak = 0 + + async def handler(request): + nonlocal in_flight, peak + in_flight += 1 + peak = max(peak, in_flight) + await asyncio.sleep(0.05) + in_flight -= 1 + return httpx2.Response(200, json={'$id': 'user-1'}, headers={'Content-Type': 'application/json'}) + + respx.route().mock(side_effect=handler) + + async with Client() as client: + responses = await asyncio.gather( + *[client.call('get', f'/users/{index}', {'accept': 'application/json'}) for index in range(5)] + ) + + self.assertEqual(len(responses), 5) + self.assertEqual(peak, 5) + + @respx.mock + async def test_error_response_raises_appwrite_exception(self): + respx.route().mock( + return_value=httpx2.Response( + 404, + json={'message': 'User not found', 'type': 'user_not_found'}, + headers={'Content-Type': 'application/json'}, + ) + ) + + async with Client() as client: + with self.assertRaises(AppwriteException) as context: + await client.call('get', '/users/missing', {'accept': 'application/json'}) + + self.assertEqual(context.exception.message, 'User not found') + self.assertEqual(context.exception.code, 404) + self.assertEqual(context.exception.type, 'user_not_found') + + @respx.mock + async def test_context_manager_closes_the_connection_pool(self): + async with Client() as client: + http = client._http + self.assertFalse(http.is_closed) + + self.assertTrue(http.is_closed) + + @respx.mock + async def test_chunked_upload_reports_progress(self): + total_chunks = 4 + received = 0 + ranges = [] + upload_ids = [] + + async def handler(request): + nonlocal received + if request.method == 'GET': + # Resume probe: the SDK asks whether an upload is already in progress. + return httpx2.Response( + 200, + json={'$id': 'file-1', 'chunksTotal': total_chunks, 'chunksUploaded': 0}, + headers={'Content-Type': 'application/json'}, + ) + received += 1 + ranges.append(request.headers.get('content-range')) + upload_ids.append(request.headers.get('x-appwrite-id')) + return httpx2.Response( + 200, + json={'$id': 'file-1', 'chunksTotal': total_chunks, 'chunksUploaded': received}, + headers={'Content-Type': 'application/json'}, + ) + + respx.route().mock(side_effect=handler) + + progress = [] + + async def on_progress(payload): + progress.append(payload) + + async with Client() as client: + client._chunk_size = 10 + storage = Storage(client) + await storage.create_file( + bucket_id='bucket-1', + file_id='file-1', + file=InputFile.from_bytes(b'x' * 40, 'test.txt'), + on_progress=on_progress, + ) + + self.assertEqual(received, total_chunks) + self.assertEqual( + sorted(ranges), + ['bytes 0-9/40', 'bytes 10-19/40', 'bytes 20-29/40', 'bytes 30-39/40'], + ) + self.assertEqual(upload_ids, ['file-1'] * total_chunks) + self.assertEqual(sorted(item['chunksUploaded'] for item in progress), [1, 2, 3, 4]) + self.assertEqual(max(item['progress'] for item in progress), 100.0) + self.assertEqual(max(item['sizeUploaded'] for item in progress), 40) diff --git a/test/test_integration.py b/test/test_integration.py new file mode 100644 index 00000000..5a96ad3a --- /dev/null +++ b/test/test_integration.py @@ -0,0 +1,487 @@ +"""End-to-end checks against a real local server over real sockets. + +The unit suite mocks at the transport layer, so it never exercises TCP, TLS, +keep-alive or real concurrency. These tests drive the SDK against a real +HTTP(S) server bound to 127.0.0.1 and assert on what actually went over the wire. +""" + +import asyncio +import hashlib +import json +import shutil +import ssl +import subprocess +import tempfile +import threading +import time +import unittest +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer +from urllib.parse import parse_qs, urlparse + +from appwrite.client import Client +from appwrite.exception import AppwriteException +from appwrite.input_file import InputFile +from appwrite.services.storage import Storage + + +class _State: + """Thread-safe counters describing what the server actually observed.""" + + def __init__(self): + self.lock = threading.Lock() + self.reset() + + def reset(self): + self.connections = 0 + self.requests = 0 + self.in_flight = 0 + self.peak_in_flight = 0 + self.chunks = [] + self.chunk_size = 0 + self.expected_total = 0 + self.file_id = 'file-1' + + def enter(self): + with self.lock: + self.in_flight += 1 + self.requests += 1 + self.peak_in_flight = max(self.peak_in_flight, self.in_flight) + + def leave(self): + with self.lock: + self.in_flight -= 1 + + def record_chunk(self, index, payload, content_range, upload_id): + with self.lock: + self.chunks.append( + { + 'index': index, + 'payload': payload, + 'content_range': content_range, + 'upload_id': upload_id, + } + ) + + +def _multipart_parts(body, content_type): + """Split a raw multipart body into (headers, payload) pairs.""" + boundary = None + for piece in content_type.split(';')[1:]: + key, _, value = piece.strip().partition('=') + if key.lower() == 'boundary': + boundary = value.strip('"') + if not boundary: + return [] + + marker = ('--' + boundary).encode() + parts = [] + for raw in body.split(marker)[1:]: + if raw.startswith(b'--'): + break + if raw.startswith(b'\r\n'): + raw = raw[2:] + head, _, payload = raw.partition(b'\r\n\r\n') + if payload.endswith(b'\r\n'): + payload = payload[:-2] + parts.append((head, payload)) + return parts + + +def _build_handler(state): + class Handler(BaseHTTPRequestHandler): + protocol_version = 'HTTP/1.1' + + def setup(self): + super().setup() + with state.lock: + state.connections += 1 + self.connection_id = state.connections + + def log_message(self, *args): + pass + + def _read_body(self): + length = int(self.headers.get('Content-Length') or 0) + return self.rfile.read(length) if length else b'' + + def _send(self, status, body=b'', content_type='application/json', extra=None): + if isinstance(body, str): + body = body.encode('utf-8') + self.send_response(status) + self.send_header('Content-Type', content_type) + self.send_header('Content-Length', str(len(body))) + for key, value in (extra or {}).items(): + self.send_header(key, value) + self.end_headers() + if body: + self.wfile.write(body) + + def _send_json(self, status, payload, extra=None): + self._send(status, json.dumps(payload), 'application/json', extra) + + def _route(self, path, query, body): + if path == '/slow': + time.sleep(float(query.get('delay', ['0.25'])[0])) + self._send_json(200, {'ok': True, 'connection': self.connection_id}) + return + + if path == '/echo': + parts = _multipart_parts(body, self.headers.get('Content-Type', '')) + file_parts = [payload for head, payload in parts if b'filename=' in head] + self._send_json( + 200, + { + 'method': self.command, + 'path': path, + 'query': query, + 'body_len': len(body), + 'body_text': body.decode('utf-8', 'replace'), + 'body_sha256': hashlib.sha256(body).hexdigest(), + 'content_range': self.headers.get('content-range'), + 'x_appwrite_id': self.headers.get('x-appwrite-id'), + 'file_sha256': hashlib.sha256(file_parts[0]).hexdigest() if file_parts else None, + 'file_len': len(file_parts[0]) if file_parts else 0, + }, + ) + return + + if path == '/error': + self._send_json(404, {'message': 'Resource not found', 'type': 'not_found', 'code': 404}) + return + + if path == '/text': + self._send(200, 'plain text body', 'text/plain') + return + + if path == '/binary': + self._send(200, bytes(range(256)), 'application/octet-stream') + return + + if path == '/location': + self._send_json(200, {'ok': True}, {'Location': 'https://example.com/redirected'}) + return + + if path == '/redirect': + self._send(302, b'', 'text/plain', {'Location': '/echo'}) + return + + if self.command == 'GET': + # Resume probe for a chunked upload. + total = (state.expected_total + state.chunk_size - 1) // max(state.chunk_size, 1) + self._send_json(200, {'$id': state.file_id, 'chunksTotal': total, 'chunksUploaded': 0}) + return + + # Chunk upload. + content_range = self.headers.get('content-range') + start = int(content_range.split(' ')[1].split('-')[0]) if content_range else 0 + index = start // state.chunk_size if state.chunk_size else 0 + parts = _multipart_parts(body, self.headers.get('Content-Type', '')) + file_parts = [payload for head, payload in parts if b'filename=' in head] + state.record_chunk( + index, + file_parts[0] if file_parts else b'', + content_range, + self.headers.get('x-appwrite-id'), + ) + + total_chunks = (state.expected_total + state.chunk_size - 1) // max(state.chunk_size, 1) + self._send_json( + 200, + { + '$id': state.file_id, + 'chunksTotal': total_chunks, + 'chunksUploaded': len({chunk['index'] for chunk in state.chunks}), + }, + ) + + def _handle(self): + parsed = urlparse(self.path) + body = self._read_body() + state.enter() + try: + self._route(parsed.path, parse_qs(parsed.query), body) + finally: + state.leave() + + do_GET = _handle + do_POST = _handle + do_PUT = _handle + do_DELETE = _handle + do_PATCH = _handle + + return Handler + + +class _Server: + def __init__(self, tls=False): + self.state = _State() + self.httpd = ThreadingHTTPServer(('127.0.0.1', 0), _build_handler(self.state)) + self.httpd.daemon_threads = True + self.certdir = None + if tls: + self.certdir = tempfile.mkdtemp(prefix='appwrite-tls-') + self._make_cert() + context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + context.load_cert_chain(self.certdir + '/cert.pem', self.certdir + '/key.pem') + self.httpd.socket = context.wrap_socket(self.httpd.socket, server_side=True) + self.port = self.httpd.server_address[1] + self.scheme = 'https' if tls else 'http' + self.thread = threading.Thread(target=self.httpd.serve_forever, daemon=True) + self.thread.start() + + def _make_cert(self): + subprocess.run( + [ + 'openssl', + 'req', + '-x509', + '-newkey', + 'rsa:2048', + '-keyout', + self.certdir + '/key.pem', + '-out', + self.certdir + '/cert.pem', + '-days', + '1', + '-nodes', + '-subj', + '/CN=localhost', + ], + check=True, + capture_output=True, + ) + + @property + def endpoint(self): + return f'{self.scheme}://localhost:{self.port}' + + def close(self): + self.httpd.shutdown() + self.httpd.server_close() + if self.certdir: + shutil.rmtree(self.certdir, ignore_errors=True) + + +class _LiveServerTest(unittest.IsolatedAsyncioTestCase): + server = None + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.server = _Server() + + @classmethod + def tearDownClass(cls): + super().tearDownClass() + cls.server.close() + + async def asyncSetUp(self): + self.client = Client() + self.client.set_endpoint(self.server.endpoint) + self.state = self.server.state + + async def asyncTearDown(self): + await self.client.aclose() + + +class TestRealRequests(_LiveServerTest): + async def test_request_round_trips_over_a_real_socket(self): + response = await self.client.call('get', '/echo', {}, {'probe': 'yes'}) + + self.assertEqual(response['method'], 'GET') + self.assertEqual(response['path'], '/echo') + self.assertEqual(response['query'], {'probe': ['yes']}) + self.assertGreater(self.state.connections, 0) + + async def test_json_body_is_sent_and_parsed(self): + body = {'name': 'Walter', 'active': True} + response = await self.client.call('post', '/echo', {'content-type': 'application/json'}, body) + + self.assertEqual(response['method'], 'POST') + self.assertEqual(response['body_text'], json.dumps(body)) + + async def test_multipart_file_bytes_reach_the_server_intact(self): + payload = b'\x00\x01\x02binary\xff' * 100 + response = await self.client.call( + 'post', + '/echo', + {'content-type': 'multipart/form-data'}, + {'file': InputFile.from_bytes(payload, 'blob.bin'), 'name': 'blob'}, + ) + + self.assertEqual(response['file_len'], len(payload)) + self.assertEqual(response['file_sha256'], hashlib.sha256(payload).hexdigest()) + + async def test_binary_response_is_returned_as_bytes(self): + response = await self.client.call('get', '/binary') + + self.assertIsInstance(response, bytes) + self.assertEqual(response, bytes(range(256))) + + async def test_text_response_is_decoded(self): + response = await self.client.call('get', '/text', response_type='text') + + self.assertEqual(response, 'plain text body') + + async def test_location_response_type_returns_the_header(self): + response = await self.client.call('get', '/location', response_type='location') + + self.assertEqual(response, 'https://example.com/redirected') + + async def test_error_response_raises_appwrite_exception(self): + with self.assertRaises(AppwriteException) as context: + await self.client.call('get', '/error') + + self.assertEqual(context.exception.code, 404) + self.assertEqual(context.exception.message, 'Resource not found') + self.assertEqual(context.exception.type, 'not_found') + + async def test_connection_refused_is_wrapped_in_appwrite_exception(self): + client = Client() + client.set_endpoint('http://127.0.0.1:1/v1') + try: + with self.assertRaises(AppwriteException): + await client.call('get', '/echo') + finally: + await client.aclose() + + +class TestRealConcurrency(_LiveServerTest): + async def test_requests_overlap_on_the_wire(self): + """Sequential calls pay the delay every time; concurrent calls overlap.""" + count = 8 + delay = 0.25 + + self.state.reset() + started = time.perf_counter() + for _ in range(count): + await self.client.call('get', '/slow', {}, {'delay': str(delay)}) + sequential = time.perf_counter() - started + + self.state.reset() + started = time.perf_counter() + await asyncio.gather(*[self.client.call('get', '/slow', {}, {'delay': str(delay)}) for _ in range(count)]) + concurrent = time.perf_counter() - started + + self.assertGreater(sequential, delay * count * 0.9, 'sequential baseline should pay the delay every time') + self.assertLess(concurrent, sequential / 3, 'concurrent calls should overlap instead of queueing') + self.assertGreater(self.state.peak_in_flight, 1, 'the server never handled two requests at once') + + async def test_each_concurrent_request_gets_its_own_connection(self): + count = 6 + self.state.reset() + + await asyncio.gather(*[self.client.call('get', '/slow', {}, {'delay': '0.2'}) for _ in range(count)]) + + self.assertEqual(self.state.requests, count) + self.assertEqual(self.state.connections, count, 'requests were serialised onto a single connection') + + async def test_connection_pool_is_reused_for_sequential_calls(self): + self.state.reset() + + for _ in range(5): + await self.client.call('get', '/echo') + + self.assertEqual(self.state.requests, 5) + self.assertEqual(self.state.connections, 1, 'keep-alive should reuse a single connection') + + +class TestRealChunkedUpload(_LiveServerTest): + async def test_chunks_arrive_intact_over_real_multipart(self): + payload = bytes(range(256)) * 800 # 204800 bytes + chunk_size = 51_200 # exactly 4 chunks + self.state.reset() + self.state.chunk_size = chunk_size + self.state.expected_total = len(payload) + self.state.file_id = 'file-1' + + self.client._chunk_size = chunk_size + progress = [] + + async def on_progress(update): + progress.append(update) + + storage = Storage(self.client) + result = await storage.create_file( + bucket_id='bucket-1', + file_id='file-1', + file=InputFile.from_bytes(payload, 'blob.bin'), + on_progress=on_progress, + ) + + self.assertEqual(result.id, 'file-1') + + chunks = sorted(self.state.chunks, key=lambda chunk: chunk['index']) + self.assertEqual(len(chunks), 4) + self.assertEqual( + hashlib.sha256(b''.join(chunk['payload'] for chunk in chunks)).hexdigest(), + hashlib.sha256(payload).hexdigest(), + 'the bytes that arrived on the wire differ from the bytes we sent', + ) + self.assertEqual( + sorted(chunk['content_range'] for chunk in chunks), + [ + 'bytes 0-51199/204800', + 'bytes 102400-153599/204800', + 'bytes 153600-204799/204800', + 'bytes 51200-102399/204800', + ], + ) + self.assertEqual([chunk['upload_id'] for chunk in chunks], ['file-1'] * 4) + + self.assertEqual(max(item['progress'] for item in progress), 100.0) + self.assertEqual(sorted(item['chunksUploaded'] for item in progress), [1, 2, 3, 4]) + + +class TestRealTls(unittest.IsolatedAsyncioTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + if shutil.which('openssl') is None: + raise unittest.SkipTest('openssl is required to generate a self-signed certificate') + cls.server = _Server(tls=True) + + @classmethod + def tearDownClass(cls): + super().tearDownClass() + cls.server.close() + + async def test_self_signed_certificate_is_rejected_by_default(self): + client = Client() + client.set_endpoint(self.server.endpoint) + try: + with self.assertRaises(AppwriteException): + await client.call('get', '/echo') + finally: + await client.aclose() + + async def test_self_signed_certificate_is_accepted_after_opt_in(self): + async with Client() as client: + client.set_endpoint(self.server.endpoint) + client.set_self_signed() + response = await client.call('get', '/echo') + + self.assertEqual(response['method'], 'GET') + + +class TestRealAppwriteCloud(unittest.IsolatedAsyncioTestCase): + """Talks to the real Appwrite Cloud endpoint over real TLS.""" + + async def test_cloud_endpoint_rejects_unauthenticated_call(self): + async with Client() as client: + client.set_endpoint('https://cloud.appwrite.io/v1') + try: + with self.assertRaises(AppwriteException) as context: + await asyncio.wait_for(client.call('get', '/health'), timeout=20) + except TimeoutError: + self.skipTest('Appwrite Cloud did not answer within 20s') + + if context.exception.code is None: + self.skipTest(f'Appwrite Cloud is unreachable from this machine: {context.exception.message}') + + self.assertEqual(context.exception.code, 401) + self.assertIn('missing scopes', context.exception.message) + + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_query.py b/test/test_query.py index ae47a4b1..77896e16 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -3,7 +3,8 @@ from urllib.parse import parse_qsl from urllib.parse import urlsplit -import requests_mock +import httpx2 +import respx from appwrite.client import Client from appwrite.query import Query @@ -30,7 +31,7 @@ def __init__(self, description: str, value, expected_values): ] -class TestQueryMethods(unittest.TestCase): +class TestQueryMethods(unittest.IsolatedAsyncioTestCase): def test_equal(self): for t in tests: @@ -352,39 +353,40 @@ def test_flatten_splices_builders_beside_nested_string_arrays(self): Query._flatten([builder, ['a', 'b']]), ) - @requests_mock.Mocker() - def test_client_sends_flattened_params(self, m): - m.register_uri( - requests_mock.ANY, - requests_mock.ANY, - json={}, - headers={'Content-Type': 'application/json'}, + @respx.mock + async def test_client_sends_flattened_params(self): + respx.route().mock( + return_value=httpx2.Response(200, json={}, headers={'Content-Type': 'application/json'}), ) - client = Client().set_endpoint('https://example.com/v1') queries = [Query.limit(1), Query.offset(2)] def params(): return {'queries': Query.builder().limit(1).offset(2), 'tags': [['a', 'b']]} - client.call('post', '/items', {'content-type': 'application/json'}, params()) - client.call('get', '/items', {'content-type': 'application/json'}, params()) - client.call('post', '/items', {'content-type': 'multipart/form-data'}, params()) + async with Client().set_endpoint('https://example.com/v1') as client: + await client.call('post', '/items', {'content-type': 'application/json'}, params()) + await client.call('get', '/items', {'content-type': 'application/json'}, params()) + await client.call('post', '/items', {'content-type': 'multipart/form-data'}, params()) - json_request, get_request, multipart_request = m.request_history - self.assertEqual( - {'queries': queries, 'tags': [['a', 'b']]}, - json.loads(json_request.body), - ) - self.assertEqual( - [ - ('queries[0]', queries[0]), - ('queries[1]', queries[1]), - ('tags[0][0]', 'a'), - ('tags[0][1]', 'b'), - ], - parse_qsl(urlsplit(get_request.url).query), - ) - multipart_body = multipart_request.body.decode() - self.assertIn('name="tags[0][0]"\r\n\r\na\r\n', multipart_body) - self.assertIn('name="tags[0][1]"\r\n\r\nb\r\n', multipart_body) - self.assertIn(f'name="queries[1]"\r\n\r\n{queries[1]}\r\n', multipart_body) + json_request, get_request, multipart_request = [call.request for call in respx.calls] + + await json_request.aread() + await multipart_request.aread() + + self.assertEqual( + {'queries': queries, 'tags': [['a', 'b']]}, + json.loads(json_request.content), + ) + self.assertEqual( + [ + ('queries[0]', queries[0]), + ('queries[1]', queries[1]), + ('tags[0][0]', 'a'), + ('tags[0][1]', 'b'), + ], + parse_qsl(urlsplit(str(get_request.url)).query), + ) + multipart_body = multipart_request.content.decode() + self.assertIn('name="tags[0][0]"\r\n\r\na\r\n', multipart_body) + self.assertIn('name="tags[0][1]"\r\n\r\nb\r\n', multipart_body) + self.assertIn(f'name="queries[1]"\r\n\r\n{queries[1]}\r\n', multipart_body) From 3d856742cfcc51801cb68b170edd841517e08e8e Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 12:13:43 +0530 Subject: [PATCH 03/15] Wait for all sibling chunks on upload failure Use return_exceptions with asyncio.gather so a failed chunk's error is not raised while other chunk uploads are still in flight. --- appwrite/client.py | 10 +++++++- test/test_async_client.py | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/appwrite/client.py b/appwrite/client.py index 075a75aa..065270ca 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -403,7 +403,15 @@ async def upload_remaining_chunk(chunk): }, ) - await asyncio.gather(*(upload_remaining_chunk(chunk) for chunk in chunks[1:])) + # Wait for every sibling chunk to settle before surfacing a failure, so the + # caller never observes an error while other chunks are still being written. + outcomes = await asyncio.gather( + *(upload_remaining_chunk(chunk) for chunk in chunks[1:]), + return_exceptions=True, + ) + for outcome in outcomes: + if isinstance(outcome, BaseException): + raise outcome return final_result or last_result diff --git a/test/test_async_client.py b/test/test_async_client.py index b592d132..cef1a50f 100644 --- a/test/test_async_client.py +++ b/test/test_async_client.py @@ -112,3 +112,51 @@ async def on_progress(payload): self.assertEqual(sorted(item['chunksUploaded'] for item in progress), [1, 2, 3, 4]) self.assertEqual(max(item['progress'] for item in progress), 100.0) self.assertEqual(max(item['sizeUploaded'] for item in progress), 40) + + @respx.mock + async def test_chunked_upload_waits_for_sibling_chunks_after_a_failure(self): + total_chunks = 4 + in_flight = 0 + completed = 0 + + async def handler(request): + nonlocal in_flight, completed + if request.method == 'GET': + # Resume probe: the SDK asks whether an upload is already in progress. + return httpx2.Response( + 200, + json={'$id': 'file-1', 'chunksTotal': total_chunks, 'chunksUploaded': 0}, + headers={'Content-Type': 'application/json'}, + ) + if request.headers.get('content-range', '').startswith('bytes 10-19'): + # Reject one chunk straight away, while its siblings are still uploading. + return httpx2.Response( + 400, + json={'message': 'Chunk rejected', 'type': 'general_bad_request'}, + headers={'Content-Type': 'application/json'}, + ) + in_flight += 1 + await asyncio.sleep(0.2) + in_flight -= 1 + completed += 1 + return httpx2.Response( + 200, + json={'$id': 'file-1', 'chunksTotal': total_chunks, 'chunksUploaded': 1}, + headers={'Content-Type': 'application/json'}, + ) + + respx.route().mock(side_effect=handler) + + async with Client() as client: + client._chunk_size = 10 + storage = Storage(client) + with self.assertRaises(AppwriteException) as context: + await storage.create_file( + bucket_id='bucket-1', + file_id='file-1', + file=InputFile.from_bytes(b'x' * 40, 'test.txt'), + ) + + self.assertEqual(context.exception.message, 'Chunk rejected') + self.assertEqual(in_flight, 0, 'sibling chunk uploads were still running when the error surfaced') + self.assertEqual(completed, 3, 'sibling chunk uploads did not run to completion') From 108859ff512014ccdd571c172e182ae60371c97a Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 12:30:58 +0530 Subject: [PATCH 04/15] Replace asyncio with anyio Replaces asyncio.gather/to_thread with anyio task groups and to_thread.run_sync. Retired HTTP clients are now closed in aclose() since anyio has no fire-and-forget tasks. Adds anyio dependency. --- appwrite/client.py | 47 +++++++++++++++++++++++++--------------------- pyproject.toml | 1 + 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/appwrite/client.py b/appwrite/client.py index 065270ca..bf4c15ec 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -1,4 +1,4 @@ -import asyncio +import anyio import inspect import json import os @@ -37,6 +37,7 @@ def __init__(self): } self._config = {} self._http = self._new_http_client(verify=True) + self._retired_http = [] def _new_http_client(self, verify): context = _default_ssl_context() if verify else False @@ -50,6 +51,9 @@ async def __aexit__(self, exc_type, exc_value, traceback): async def aclose(self): """Close the underlying HTTP connection pool.""" + for client in self._retired_http: + await client.aclose() + self._retired_http = [] await self._http.aclose() def set_self_signed(self, status=True): @@ -57,17 +61,11 @@ def set_self_signed(self, status=True): self._self_signed = status previous = self._http self._http = self._new_http_client(verify=not status) - self._dispose(previous) + # anyio has no fire-and-forget tasks, so the replaced client is parked here + # and closed together with the active one once aclose() runs. + self._retired_http.append(previous) return self - @staticmethod - def _dispose(client): - try: - loop = asyncio.get_running_loop() - except RuntimeError: - return - loop.create_task(client.aclose()) - def set_endpoint(self, endpoint): if not endpoint.startswith('http://') and not endpoint.startswith('https://'): raise AppwriteException('Invalid endpoint URL: ' + endpoint) @@ -344,7 +342,7 @@ def is_upload_complete(chunk_result): async def upload_chunk(chunk, current_upload_id): chunk_input = InputFile.from_bytes( - await asyncio.to_thread(read_chunk, chunk['start'], chunk['end']), + await anyio.to_thread.run_sync(read_chunk, chunk['start'], chunk['end']), input_file.filename, getattr(input_file, 'mime_type', None), ) @@ -381,12 +379,20 @@ async def upload_chunk(chunk, current_upload_id): }, ) - semaphore = asyncio.Semaphore(8) + semaphore = anyio.Semaphore(8) + + failures = [] async def upload_remaining_chunk(chunk): nonlocal completed_count, uploaded_size, last_result, final_result - async with semaphore: - chunk_result = await upload_chunk(chunk, upload_id_header) + # a task group cancels siblings on the first raise, so failures are + # captured here to keep gather(return_exceptions=True) semantics. + try: + async with semaphore: + chunk_result = await upload_chunk(chunk, upload_id_header) + except BaseException as exc: + failures.append(exc) + return completed_count = completed_count + 1 uploaded_size = uploaded_size + (chunk['end'] - chunk['start']) last_result = chunk_result @@ -405,13 +411,12 @@ async def upload_remaining_chunk(chunk): # Wait for every sibling chunk to settle before surfacing a failure, so the # caller never observes an error while other chunks are still being written. - outcomes = await asyncio.gather( - *(upload_remaining_chunk(chunk) for chunk in chunks[1:]), - return_exceptions=True, - ) - for outcome in outcomes: - if isinstance(outcome, BaseException): - raise outcome + async with anyio.create_task_group() as tg: + for chunk in chunks[1:]: + tg.start_soon(upload_remaining_chunk, chunk) + + if failures: + raise failures[0] return final_result or last_result diff --git a/pyproject.toml b/pyproject.toml index f453ce99..0da1053c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ maintainers = [ dependencies = [ "httpx2>=2.0,<3", "pydantic>=2,<3", + "anyio>=4,<5", ] classifiers = [ "Development Status :: 5 - Production/Stable", From 628688206a45a96d5c480f83ad335584e203531b Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 14:08:58 +0530 Subject: [PATCH 05/15] Allow redirects for location responses --- appwrite/client.py | 5 +++- test/test_async_client.py | 62 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/appwrite/client.py b/appwrite/client.py index bf4c15ec..6e2d748e 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -225,7 +225,10 @@ async def call(self, method, path='', headers=None, params=None, response_type=' follow_redirects=False if response_type == 'location' else True, ) - response.raise_for_status() + # httpx raises on 3xx, unlike requests; a redirect is the expected + # outcome for response_type='location', so only 4xx/5xx are errors. + if response.status_code >= 400: + response.raise_for_status() warnings = response.headers.get('x-appwrite-warning') if warnings: diff --git a/test/test_async_client.py b/test/test_async_client.py index cef1a50f..d9172d5b 100644 --- a/test/test_async_client.py +++ b/test/test_async_client.py @@ -7,6 +7,7 @@ from appwrite.client import Client from appwrite.exception import AppwriteException from appwrite.input_file import InputFile +from appwrite.services.account import Account from appwrite.services.storage import Storage @@ -160,3 +161,64 @@ async def handler(request): self.assertEqual(context.exception.message, 'Chunk rejected') self.assertEqual(in_flight, 0, 'sibling chunk uploads were still running when the error surfaced') self.assertEqual(completed, 3, 'sibling chunk uploads did not run to completion') + + @respx.mock + async def test_location_response_returns_the_redirect_url(self): + # httpx raises on 3xx, so a redirect is only a success when the client + # treats it as one; OAuth login depends on the Location header. + respx.route().mock( + return_value=httpx2.Response( + 302, + headers={'Location': 'https://appwrite.io/oauth/callback?userId=1&secret=2'}, + ) + ) + + async with Client() as client: + location = await client.call( + 'get', + '/account/tokens/oauth2/github', + {'accept': 'text/html'}, + {}, + response_type='location', + ) + + self.assertEqual(location, 'https://appwrite.io/oauth/callback?userId=1&secret=2') + + @respx.mock + async def test_location_response_still_raises_on_client_errors(self): + respx.route().mock( + return_value=httpx2.Response( + 400, + json={'message': 'Invalid provider', 'type': 'general_bad_request'}, + headers={'Content-Type': 'application/json'}, + ) + ) + + async with Client() as client: + with self.assertRaises(AppwriteException) as context: + await client.call( + 'get', + '/account/tokens/oauth2/github', + {'accept': 'text/html'}, + {}, + response_type='location', + ) + + self.assertEqual(context.exception.message, 'Invalid provider') + self.assertEqual(context.exception.code, 400) + self.assertEqual(context.exception.type, 'general_bad_request') + + @respx.mock + async def test_create_o_auth2_token_returns_the_redirect_url(self): + respx.route().mock( + return_value=httpx2.Response( + 302, + headers={'Location': 'https://appwrite.io/oauth/callback?userId=1&secret=2'}, + ) + ) + + async with Client() as client: + account = Account(client) + response = await account.create_o_auth2_token('github') + + self.assertEqual(response, 'https://appwrite.io/oauth/callback?userId=1&secret=2') From cf3053716e32419f3d07f14c5aec88a64cf12cd9 Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 14:59:56 +0530 Subject: [PATCH 06/15] Make deprecation warning filters thread-safe Emit warnings in a scoped context so caller filters are preserved. Add tests for sync and async decorators, warning attribution, and filter restoration. --- appwrite/utils/deprecated.py | 41 ++++++++---- test/test_deprecated.py | 125 +++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 12 deletions(-) create mode 100644 test/test_deprecated.py diff --git a/appwrite/utils/deprecated.py b/appwrite/utils/deprecated.py index cadbc813..61d1cdef 100644 --- a/appwrite/utils/deprecated.py +++ b/appwrite/utils/deprecated.py @@ -7,8 +7,33 @@ import functools import inspect +import threading import warnings +# `warnings.filters` is process global, so the temporary filter used to show the +# deprecation warning on every call is guarded by a lock. Without it, two +# threads calling a deprecated function at the same time could restore each +# other's filters and leak the `always` filter into the process. +_filter_lock = threading.RLock() + + +def _warn_deprecated(message, stacklevel=3): + """ + Emit a deprecation warning that is shown on every call. + + The `always` filter is only installed while the warning is emitted and the + filters configured by the caller are restored right after, so concurrent + tasks and threads are never affected by it. + + Args: + message (str): The warning message. + stacklevel (int): Stack level of the frame to blame for the warning. + """ + with _filter_lock: + with warnings.catch_warnings(): + warnings.simplefilter('always', DeprecationWarning) # show warning every time + warnings.warn(message, category=DeprecationWarning, stacklevel=stacklevel) + def deprecated(reason=None): """ @@ -31,23 +56,15 @@ def decorator(func): @functools.wraps(func) async def wrapped(*args, **kwargs): - warnings.simplefilter('always', DeprecationWarning) # show warning every time - try: - warnings.warn(message, category=DeprecationWarning, stacklevel=2) - return await func(*args, **kwargs) - finally: - warnings.simplefilter('default', DeprecationWarning) # reset filter + _warn_deprecated(message) + return await func(*args, **kwargs) return wrapped @functools.wraps(func) def wrapped(*args, **kwargs): - warnings.simplefilter('always', DeprecationWarning) # show warning every time - try: - warnings.warn(message, category=DeprecationWarning, stacklevel=2) - return func(*args, **kwargs) - finally: - warnings.simplefilter('default', DeprecationWarning) # reset filter + _warn_deprecated(message) + return func(*args, **kwargs) return wrapped diff --git a/test/test_deprecated.py b/test/test_deprecated.py new file mode 100644 index 00000000..f7f56093 --- /dev/null +++ b/test/test_deprecated.py @@ -0,0 +1,125 @@ +import asyncio +import unittest +import warnings + +from appwrite.utils.deprecated import deprecated + + +class TestDeprecatedDecorator(unittest.IsolatedAsyncioTestCase): + + def test_warns_on_every_call(self): + @deprecated("use new_api instead") + def old_api(): + return 'ok' + + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter('always', DeprecationWarning) + self.assertEqual('ok', old_api()) + self.assertEqual('ok', old_api()) + + self.assertEqual( + [ + "Call to deprecated function 'old_api'. use new_api instead", + "Call to deprecated function 'old_api'. use new_api instead", + ], + [str(warning.message) for warning in caught], + ) + + def test_warning_is_attributed_to_the_caller(self): + @deprecated("use new_api instead") + def old_api(): + return 'ok' + + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter('always', DeprecationWarning) + old_api() + + self.assertEqual(__file__, caught[0].filename) + + def test_caller_filters_are_restored(self): + @deprecated("use new_api instead") + def old_api(): + return 'ok' + + with warnings.catch_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + before = warnings.filters[:] + old_api() + after = warnings.filters[:] + + self.assertEqual(before, after) + + def test_caller_filters_still_apply_after_the_call(self): + @deprecated("use new_api instead") + def old_api(): + return 'ok' + + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter('ignore', DeprecationWarning) + old_api() + warnings.warn('unrelated', DeprecationWarning) + + self.assertEqual( + ["Call to deprecated function 'old_api'. use new_api instead"], + [str(warning.message) for warning in caught], + ) + + async def test_async_warning_is_attributed_to_the_caller(self): + @deprecated("use new_api instead") + async def old_api(): + return 'ok' + + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter('always', DeprecationWarning) + await old_api() + + self.assertEqual(__file__, caught[0].filename) + + async def test_awaited_call_is_not_affected_by_the_temporary_filter(self): + @deprecated("use new_api instead") + async def old_api(): + warnings.warn('unrelated', DeprecationWarning) + await asyncio.sleep(0) + warnings.warn('unrelated after await', DeprecationWarning) + return 'ok' + + with warnings.catch_warnings(record=True) as caught: + warnings.simplefilter('ignore', DeprecationWarning) + result = await old_api() + + self.assertEqual('ok', result) + self.assertEqual( + ["Call to deprecated function 'old_api'. use new_api instead"], + [str(warning.message) for warning in caught], + ) + + async def test_awaited_call_runs_without_the_always_filter(self): + observed = [] + + @deprecated("use new_api instead") + async def old_api(): + observed.extend( + (action, category) + for action, message, category, module, lineno in warnings.filters + if category is DeprecationWarning + ) + return 'ok' + + with warnings.catch_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + await old_api() + + self.assertNotIn(('always', DeprecationWarning), observed) + + async def test_async_caller_filters_are_restored(self): + @deprecated("use new_api instead") + async def old_api(): + return 'ok' + + with warnings.catch_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + before = warnings.filters[:] + await old_api() + after = warnings.filters[:] + + self.assertEqual(before, after) From 126ca1b51c4c9a9790c6f1b291657e5368198083 Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 15:06:20 +0530 Subject: [PATCH 07/15] Make TablesDB example runnable --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 47cb3509..4ab041c5 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ See the [API reference](https://appwrite.io/docs/references/cloud/server-python/ Use `TablesDB` to read and write rows. Pass a Pydantic model as `model_type` to get typed row data back; without it, `row.data` is a `dict`. ```python +import asyncio from typing import Optional from pydantic import BaseModel @@ -118,6 +119,9 @@ async def main(): for row in result.rows: print(row.data.title) + + +asyncio.run(main()) ``` ### Handle errors From f0c0ace790952fd62f88c97f9db08587ed6ca00f Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 19:46:54 +0530 Subject: [PATCH 08/15] Document breaking SDK async changes Require all service methods, Client.call, and Client.chunked_upload to be awaited. Coroutine on_progress callbacks are also awaited. The SDK now requires Python 3.11 and uses httpx2 instead of requests. Client.aclose() and async context manager support are also documented. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f0982d9..94de54cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,13 @@ * Breaking: `tables_db`, `documents_db` and `vectors_db` `create` and `update` take `description` before `specification` * Breaking: `functions.update` takes `description` before `email_enabled` +* Breaking: every service method is now a coroutine and must be awaited; `Client.call` and `Client.chunked_upload` are async as well +* Breaking: the SDK now requires Python 3.11 or later +* Breaking: `requests` was replaced by `httpx2`, changing the transport and connection pooling behaviour +* Breaking: `on_progress` callbacks may now be coroutine functions and are awaited when they are * Added: `create_query` on `databases`, `documents_db` and `tables_db` to send list queries in the request body * Added: `account.list_memberships` +* Added: `Client.aclose()` and async context manager support for `Client` * Added: optional `description` on create and update for databases, collections, tables, attributes, columns, indexes, buckets, functions, sites, variables, topics, webhooks and keys * Added: `description` on the matching models * Added: `total` on list methods in `activities`, `backups`, `domains`, `mongo`, `mysql` and `postgresql` From b37a597fa42623bf1de48bf0789ff5191e156d56 Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 19:52:58 +0530 Subject: [PATCH 09/15] Update README async usage examples --- README.md | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4ab041c5..3acb9334 100644 --- a/README.md +++ b/README.md @@ -129,12 +129,19 @@ asyncio.run(main()) Failed requests raise `AppwriteException`, which carries `message`, `code`, `type` and `response`. ```python +import asyncio + from appwrite.exception import AppwriteException -try: - user = await users.get(user_id='') -except AppwriteException as error: - print(error.code, error.type, error.message) + +async def main(): + try: + user = await users.get(user_id='') + except AppwriteException as error: + print(error.code, error.type, error.message) + + +asyncio.run(main()) ``` ### Close the client @@ -142,12 +149,23 @@ except AppwriteException as error: The client keeps a pooled HTTP connection open. Close it when you are done, or use it as an async context manager. ```python -await client.aclose() +async def main(): + await client.aclose() + + +asyncio.run(main()) ``` ```python -async with Client() as client: - ... +from appwrite.client import Client + + +async def main(): + async with Client() as client: + ... + + +asyncio.run(main()) ``` ### Self-hosted Appwrite From c2ddacb3d1b4e1ebd4cfbb932a50291a3fb64e32 Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 20:10:15 +0530 Subject: [PATCH 10/15] Fix respx transport mocking in tests Alias httpx to httpx2 before importing respx for root, service, and standalone test discovery. Treat falsey Appwrite Cloud error codes as unreachable responses. --- test/__init__.py | 9 ++++++++- test/services/__init__.py | 7 +++++++ test/test_async_client.py | 6 ++++++ test/test_integration.py | 2 +- test/test_query.py | 6 ++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/test/__init__.py b/test/__init__.py index e4a4d0f4..b956009c 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1,4 +1,11 @@ import httpx2 -# Point `import httpx` at httpx2 so respx patches the transport the SDK actually uses. +# The SDK talks HTTP through httpx2, while respx patches `httpx`. Point `import +# httpx` at httpx2 so respx mocks the transport the SDK actually uses, and so +# `httpx2.Response` satisfies respx's `httpx.Response` check. +# +# This has to run before respx is imported, and it is idempotent, so every +# package that pulls respx in repeats it: this module covers discovery from the +# repository root (and pytest), `test/services/__init__.py` covers discovery +# from inside the test directory. httpx2.alias_httpx() diff --git a/test/services/__init__.py b/test/services/__init__.py index e69de29b..1b7f1b82 100644 --- a/test/services/__init__.py +++ b/test/services/__init__.py @@ -0,0 +1,7 @@ +import httpx2 + +# See `test/__init__.py`: respx patches `httpx` while the SDK talks HTTP +# through httpx2. Repeating the alias here keeps the service tests mocked when +# the suite is discovered from inside the test directory, where the `test` +# package itself is never imported. +httpx2.alias_httpx() diff --git a/test/test_async_client.py b/test/test_async_client.py index d9172d5b..f986b422 100644 --- a/test/test_async_client.py +++ b/test/test_async_client.py @@ -2,6 +2,12 @@ import unittest import httpx2 + +# respx patches `httpx` while the SDK talks HTTP through `httpx2`. Point +# `import httpx` at `httpx2` before respx is imported, so the mocks cover the +# transport the SDK actually uses. See `test/__init__.py`. +httpx2.alias_httpx() + import respx from appwrite.client import Client diff --git a/test/test_integration.py b/test/test_integration.py index 5a96ad3a..f82db599 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -476,7 +476,7 @@ async def test_cloud_endpoint_rejects_unauthenticated_call(self): except TimeoutError: self.skipTest('Appwrite Cloud did not answer within 20s') - if context.exception.code is None: + if not context.exception.code: self.skipTest(f'Appwrite Cloud is unreachable from this machine: {context.exception.message}') self.assertEqual(context.exception.code, 401) diff --git a/test/test_query.py b/test/test_query.py index 77896e16..ce4f4be4 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -4,6 +4,12 @@ from urllib.parse import urlsplit import httpx2 + +# respx patches `httpx` while the SDK talks HTTP through `httpx2`. Point +# `import httpx` at `httpx2` before respx is imported, so the mocks cover the +# transport the SDK actually uses. See `test/__init__.py`. +httpx2.alias_httpx() + import respx from appwrite.client import Client From 5d32742f0652abe8b5c468cf419048b9535afc40 Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 20:20:32 +0530 Subject: [PATCH 11/15] Convert deprecation warning docstring to comments --- appwrite/utils/deprecated.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/appwrite/utils/deprecated.py b/appwrite/utils/deprecated.py index 61d1cdef..afc814f4 100644 --- a/appwrite/utils/deprecated.py +++ b/appwrite/utils/deprecated.py @@ -18,17 +18,11 @@ def _warn_deprecated(message, stacklevel=3): - """ - Emit a deprecation warning that is shown on every call. - - The `always` filter is only installed while the warning is emitted and the - filters configured by the caller are restored right after, so concurrent - tasks and threads are never affected by it. - - Args: - message (str): The warning message. - stacklevel (int): Stack level of the frame to blame for the warning. - """ + # Emit a deprecation warning that is shown on every call. The `always` filter + # is only installed while the warning is emitted and the filters configured + # by the caller are restored right after, so concurrent tasks and threads are + # never affected by it. `stacklevel` blames the frame that called the + # deprecated function, which is two frames above this one. with _filter_lock: with warnings.catch_warnings(): warnings.simplefilter('always', DeprecationWarning) # show warning every time From 2300939ae34f7e65e0ee57ae64991b7e8aac6745 Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 21:54:46 +0530 Subject: [PATCH 12/15] Add anyio to the package dependencies The async client imports anyio, so an install without it fails at import time. --- requirements.txt | 1 + setup.py | 1 + 2 files changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index eb7b2075..3edefc0c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ httpx2>=2.0,<3 +anyio>=4,<5 respx>=0.21,<1 pydantic>=2,<3 diff --git a/setup.py b/setup.py index 741345aa..8300c967 100644 --- a/setup.py +++ b/setup.py @@ -22,6 +22,7 @@ install_requires=[ 'httpx2>=2.0,<3', 'pydantic>=2,<3', + 'anyio>=4,<5', ], python_requires='>=3.11', classifiers=[ From 82716843da887947ed4b5a2207ba02208ed3acaf Mon Sep 17 00:00:00 2001 From: Xharry01X Date: Mon, 26 Oct 2026 21:54:58 +0530 Subject: [PATCH 13/15] Regenerate the docs examples as async Every service method is a coroutine now, so the snippets await the call and run their main function. --- .../account/create-anonymous-session.md | 21 +++-- .../account/create-email-password-session.md | 29 ++++--- docs/examples/account/create-email-token.md | 29 ++++--- .../account/create-email-verification-otp.md | 25 +++--- .../account/create-email-verification.md | 25 +++--- .../account/create-id-token-session.md | 35 ++++---- .../account/create-magic-url-token.md | 31 +++++--- .../account/create-mfa-authenticator.md | 25 +++--- docs/examples/account/create-mfa-challenge.md | 25 +++--- .../account/create-mfa-recovery-codes.md | 21 +++-- .../examples/account/create-o-auth-2-token.md | 31 +++++--- docs/examples/account/create-passkey-token.md | 21 +++-- docs/examples/account/create-passkey.md | 27 ++++--- docs/examples/account/create-phone-token.md | 27 ++++--- .../account/create-phone-verification.md | 21 +++-- docs/examples/account/create-recovery-otp.md | 27 ++++--- docs/examples/account/create-recovery.md | 27 ++++--- docs/examples/account/create-session.md | 27 ++++--- docs/examples/account/create-verification.md | 25 +++--- docs/examples/account/create.md | 31 +++++--- docs/examples/account/delete-consent-token.md | 25 +++--- docs/examples/account/delete-consent.md | 23 ++++-- docs/examples/account/delete-identity.md | 23 ++++-- .../account/delete-mfa-authenticator.md | 23 ++++-- docs/examples/account/delete-passkey.md | 23 ++++-- docs/examples/account/delete-session.md | 23 ++++-- docs/examples/account/delete-sessions.md | 23 ++++-- docs/examples/account/get-consent-token.md | 27 ++++--- docs/examples/account/get-consent.md | 25 +++--- .../account/get-mfa-recovery-codes.md | 21 +++-- docs/examples/account/get-passkey.md | 25 +++--- docs/examples/account/get-prefs.md | 21 +++-- docs/examples/account/get-session.md | 25 +++--- docs/examples/account/get.md | 21 +++-- docs/examples/account/list-consent-tokens.md | 29 ++++--- docs/examples/account/list-consents.md | 27 ++++--- docs/examples/account/list-identities.md | 27 ++++--- docs/examples/account/list-memberships.md | 27 ++++--- docs/examples/account/list-mfa-factors.md | 21 +++-- docs/examples/account/list-passkeys.md | 27 ++++--- docs/examples/account/list-sessions.md | 25 +++--- .../account/update-email-verification-otp.md | 27 ++++--- .../account/update-email-verification.md | 27 ++++--- docs/examples/account/update-email.md | 27 ++++--- .../account/update-magic-url-session.md | 27 ++++--- .../account/update-mfa-authenticator.md | 27 ++++--- docs/examples/account/update-mfa-challenge.md | 27 ++++--- .../account/update-mfa-recovery-codes.md | 21 +++-- docs/examples/account/update-mfa.md | 25 +++--- docs/examples/account/update-name.md | 25 +++--- docs/examples/account/update-passkey-token.md | 27 ++++--- .../account/update-passkey-verification.md | 27 ++++--- docs/examples/account/update-passkey.md | 27 ++++--- docs/examples/account/update-password.md | 27 ++++--- docs/examples/account/update-phone-session.md | 27 ++++--- .../account/update-phone-verification.md | 27 ++++--- docs/examples/account/update-phone.md | 27 ++++--- docs/examples/account/update-prefs.md | 25 +++--- docs/examples/account/update-recovery-otp.md | 29 ++++--- docs/examples/account/update-recovery.md | 29 ++++--- docs/examples/account/update-session.md | 25 +++--- docs/examples/account/update-status.md | 21 +++-- docs/examples/account/update-verification.md | 27 ++++--- docs/examples/activities/get-event.md | 25 +++--- docs/examples/activities/list-events.md | 27 ++++--- docs/examples/advisor/delete-report.md | 23 ++++-- docs/examples/advisor/get-insight.md | 27 ++++--- docs/examples/advisor/get-report.md | 25 +++--- docs/examples/advisor/list-insights.md | 29 ++++--- docs/examples/advisor/list-reports.md | 27 ++++--- .../apps/create-installation-token.md | 27 ++++--- docs/examples/apps/create-key.md | 25 +++--- docs/examples/apps/create-secret.md | 25 +++--- docs/examples/apps/create.md | 67 +++++++++------- docs/examples/apps/delete-installation.md | 25 +++--- docs/examples/apps/delete-key.md | 25 +++--- docs/examples/apps/delete-secret.md | 25 +++--- docs/examples/apps/delete-tokens.md | 23 ++++-- docs/examples/apps/delete.md | 23 ++++-- docs/examples/apps/get-installation.md | 27 ++++--- docs/examples/apps/get-key.md | 27 ++++--- docs/examples/apps/get-secret.md | 27 ++++--- docs/examples/apps/get.md | 25 +++--- .../examples/apps/list-installation-scopes.md | 21 +++-- docs/examples/apps/list-installations.md | 29 ++++--- docs/examples/apps/list-keys.md | 29 ++++--- docs/examples/apps/list-o-auth-2-scopes.md | 21 +++-- docs/examples/apps/list-secrets.md | 29 ++++--- docs/examples/apps/list.md | 27 ++++--- docs/examples/apps/update-labels.md | 27 ++++--- docs/examples/apps/update-team.md | 27 ++++--- docs/examples/apps/update.md | 69 ++++++++-------- docs/examples/avatars/delete-photo.md | 19 +++-- docs/examples/avatars/get-browser.md | 29 ++++--- docs/examples/avatars/get-credit-card.md | 29 ++++--- docs/examples/avatars/get-favicon.md | 23 ++++-- docs/examples/avatars/get-flag.md | 29 ++++--- docs/examples/avatars/get-image.md | 27 ++++--- docs/examples/avatars/get-initials.md | 29 ++++--- docs/examples/avatars/get-photo.md | 37 +++++---- docs/examples/avatars/get-qr.md | 29 ++++--- docs/examples/avatars/get-screenshot.md | 61 +++++++------- docs/examples/avatars/update-photo.md | 25 +++--- docs/examples/backups/create-archive.md | 27 ++++--- docs/examples/backups/create-policy.md | 37 +++++---- docs/examples/backups/create-restoration.md | 31 +++++--- docs/examples/backups/delete-archive.md | 23 ++++-- docs/examples/backups/delete-policy.md | 23 ++++-- docs/examples/backups/get-archive.md | 25 +++--- docs/examples/backups/get-policy.md | 25 +++--- docs/examples/backups/get-restoration.md | 25 +++--- docs/examples/backups/list-archives.md | 27 ++++--- docs/examples/backups/list-policies.md | 27 ++++--- docs/examples/backups/list-restorations.md | 27 ++++--- docs/examples/backups/update-policy.md | 33 +++++--- .../databases/create-big-int-attribute.md | 47 ++++++----- .../databases/create-boolean-attribute.md | 37 +++++---- docs/examples/databases/create-collection.md | 47 ++++++----- .../databases/create-datetime-attribute.md | 37 +++++---- docs/examples/databases/create-document.md | 35 ++++---- docs/examples/databases/create-documents.md | 31 +++++--- .../databases/create-email-attribute.md | 37 +++++---- .../databases/create-enum-attribute.md | 45 ++++++----- .../databases/create-float-attribute.md | 47 ++++++----- docs/examples/databases/create-index.md | 45 ++++++----- .../databases/create-integer-attribute.md | 47 ++++++----- .../examples/databases/create-ip-attribute.md | 37 +++++---- .../databases/create-line-attribute.md | 35 ++++---- .../databases/create-longtext-attribute.md | 45 ++++++----- .../databases/create-mediumtext-attribute.md | 45 ++++++----- docs/examples/databases/create-operations.md | 27 ++++--- .../databases/create-point-attribute.md | 35 ++++---- .../databases/create-polygon-attribute.md | 35 ++++---- docs/examples/databases/create-query.md | 35 ++++---- .../create-relationship-attribute.md | 47 ++++++----- .../databases/create-string-attribute.md | 47 ++++++----- .../databases/create-text-attribute.md | 45 ++++++----- docs/examples/databases/create-transaction.md | 25 +++--- .../databases/create-url-attribute.md | 37 +++++---- .../databases/create-varchar-attribute.md | 47 ++++++----- docs/examples/databases/create.md | 31 +++++--- .../databases/decrement-document-attribute.md | 37 +++++---- docs/examples/databases/delete-attribute.md | 27 ++++--- docs/examples/databases/delete-collection.md | 25 +++--- docs/examples/databases/delete-document.md | 29 ++++--- docs/examples/databases/delete-documents.md | 31 +++++--- docs/examples/databases/delete-index.md | 27 ++++--- docs/examples/databases/delete-transaction.md | 23 ++++-- docs/examples/databases/delete.md | 23 ++++-- docs/examples/databases/get-attribute.md | 29 ++++--- docs/examples/databases/get-collection.md | 27 ++++--- docs/examples/databases/get-document.md | 33 +++++--- docs/examples/databases/get-index.md | 29 ++++--- docs/examples/databases/get-transaction.md | 25 +++--- docs/examples/databases/get.md | 25 +++--- .../databases/increment-document-attribute.md | 37 +++++---- docs/examples/databases/list-attributes.md | 31 +++++--- docs/examples/databases/list-collections.md | 31 +++++--- docs/examples/databases/list-documents.md | 35 ++++---- docs/examples/databases/list-indexes.md | 31 +++++--- docs/examples/databases/list-transactions.md | 27 ++++--- docs/examples/databases/list.md | 29 ++++--- .../databases/update-big-int-attribute.md | 47 ++++++----- .../databases/update-boolean-attribute.md | 37 +++++---- docs/examples/databases/update-collection.md | 45 ++++++----- .../databases/update-datetime-attribute.md | 37 +++++---- docs/examples/databases/update-document.md | 35 ++++---- docs/examples/databases/update-documents.md | 33 +++++--- .../databases/update-email-attribute.md | 37 +++++---- .../databases/update-enum-attribute.md | 45 ++++++----- .../databases/update-float-attribute.md | 47 ++++++----- .../databases/update-integer-attribute.md | 47 ++++++----- .../examples/databases/update-ip-attribute.md | 37 +++++---- .../databases/update-line-attribute.md | 37 +++++---- .../databases/update-longtext-attribute.md | 37 +++++---- .../databases/update-mediumtext-attribute.md | 37 +++++---- .../databases/update-point-attribute.md | 37 +++++---- .../databases/update-polygon-attribute.md | 37 +++++---- .../update-relationship-attribute.md | 35 ++++---- .../databases/update-string-attribute.md | 45 ++++++----- .../databases/update-text-attribute.md | 37 +++++---- docs/examples/databases/update-transaction.md | 29 ++++--- .../databases/update-url-attribute.md | 37 +++++---- .../databases/update-varchar-attribute.md | 45 ++++++----- docs/examples/databases/update.md | 31 +++++--- docs/examples/databases/upsert-document.md | 35 ++++---- docs/examples/databases/upsert-documents.md | 31 +++++--- .../examples/documentsdb/create-collection.md | 47 ++++++----- docs/examples/documentsdb/create-document.md | 35 ++++---- docs/examples/documentsdb/create-documents.md | 31 +++++--- docs/examples/documentsdb/create-failover.md | 27 ++++--- docs/examples/documentsdb/create-index.md | 45 ++++++----- .../examples/documentsdb/create-operations.md | 27 ++++--- docs/examples/documentsdb/create-query.md | 35 ++++---- .../documentsdb/create-transaction.md | 25 +++--- docs/examples/documentsdb/create.md | 37 +++++---- .../decrement-document-attribute.md | 37 +++++---- .../examples/documentsdb/delete-collection.md | 25 +++--- docs/examples/documentsdb/delete-document.md | 29 ++++--- docs/examples/documentsdb/delete-documents.md | 31 +++++--- docs/examples/documentsdb/delete-index.md | 27 ++++--- .../documentsdb/delete-transaction.md | 23 ++++-- docs/examples/documentsdb/delete.md | 23 ++++-- docs/examples/documentsdb/get-collection.md | 27 ++++--- docs/examples/documentsdb/get-document.md | 33 +++++--- docs/examples/documentsdb/get-index.md | 29 ++++--- docs/examples/documentsdb/get-replicas.md | 25 +++--- docs/examples/documentsdb/get-status.md | 25 +++--- docs/examples/documentsdb/get-transaction.md | 25 +++--- docs/examples/documentsdb/get.md | 25 +++--- .../increment-document-attribute.md | 37 +++++---- docs/examples/documentsdb/list-collections.md | 31 +++++--- docs/examples/documentsdb/list-documents.md | 35 ++++---- docs/examples/documentsdb/list-indexes.md | 31 +++++--- docs/examples/documentsdb/list-operations.md | 31 +++++--- .../documentsdb/list-specifications.md | 21 +++-- .../examples/documentsdb/list-transactions.md | 27 ++++--- docs/examples/documentsdb/list.md | 27 ++++--- .../examples/documentsdb/update-collection.md | 45 ++++++----- docs/examples/documentsdb/update-document.md | 35 ++++---- docs/examples/documentsdb/update-documents.md | 33 +++++--- .../documentsdb/update-transaction.md | 29 ++++--- docs/examples/documentsdb/update.md | 37 +++++---- docs/examples/documentsdb/upsert-document.md | 35 ++++---- docs/examples/documentsdb/upsert-documents.md | 31 +++++--- .../domains/create-preset-google-workspace.md | 25 +++--- .../examples/domains/create-preset-i-cloud.md | 25 +++--- .../examples/domains/create-preset-mailgun.md | 25 +++--- .../examples/domains/create-preset-outlook.md | 25 +++--- .../domains/create-preset-proton-mail.md | 25 +++--- docs/examples/domains/create-preset-zoho.md | 25 +++--- docs/examples/domains/create-record-a.md | 33 +++++--- docs/examples/domains/create-record-aaaa.md | 33 +++++--- docs/examples/domains/create-record-alias.md | 33 +++++--- docs/examples/domains/create-record-caa.md | 33 +++++--- docs/examples/domains/create-record-cname.md | 33 +++++--- docs/examples/domains/create-record-https.md | 33 +++++--- docs/examples/domains/create-record-mx.md | 35 ++++---- docs/examples/domains/create-record-ns.md | 33 +++++--- docs/examples/domains/create-record-srv.md | 45 ++++++----- docs/examples/domains/create-record-txt.md | 33 +++++--- docs/examples/domains/create.md | 27 ++++--- docs/examples/domains/delete-record.md | 25 +++--- docs/examples/domains/delete.md | 23 ++++-- .../domains/get-preset-google-workspace.md | 25 +++--- docs/examples/domains/get-preset-i-cloud.md | 25 +++--- docs/examples/domains/get-preset-mailgun.md | 25 +++--- docs/examples/domains/get-preset-outlook.md | 25 +++--- .../domains/get-preset-proton-mail.md | 25 +++--- docs/examples/domains/get-preset-zoho.md | 25 +++--- docs/examples/domains/get-price.md | 29 ++++--- docs/examples/domains/get-record.md | 27 ++++--- docs/examples/domains/get-transfer-status.md | 25 +++--- docs/examples/domains/get-zone.md | 23 ++++-- docs/examples/domains/get.md | 25 +++--- docs/examples/domains/list-prices.md | 29 ++++--- docs/examples/domains/list-records.md | 29 ++++--- docs/examples/domains/list.md | 29 ++++--- docs/examples/domains/update-nameservers.md | 27 ++++--- docs/examples/domains/update-record-a.md | 35 ++++---- docs/examples/domains/update-record-aaaa.md | 35 ++++---- docs/examples/domains/update-record-alias.md | 35 ++++---- docs/examples/domains/update-record-caa.md | 35 ++++---- docs/examples/domains/update-record-cname.md | 35 ++++---- docs/examples/domains/update-record-https.md | 35 ++++---- docs/examples/domains/update-record-mx.md | 37 +++++---- docs/examples/domains/update-record-ns.md | 35 ++++---- docs/examples/domains/update-record-srv.md | 47 ++++++----- docs/examples/domains/update-record-txt.md | 35 ++++---- docs/examples/domains/update-team.md | 27 ++++--- docs/examples/domains/update-zone.md | 27 ++++--- docs/examples/domains/verify-nameservers.md | 25 +++--- .../embeddings/create-text-embeddings.md | 27 ++++--- docs/examples/functions/create-deployment.md | 33 +++++--- .../functions/create-duplicate-deployment.md | 29 ++++--- docs/examples/functions/create-execution.md | 37 +++++---- .../functions/create-template-deployment.md | 37 +++++---- docs/examples/functions/create-variable.md | 35 ++++---- .../functions/create-vcs-deployment.md | 31 +++++--- docs/examples/functions/create.md | 77 ++++++++++-------- docs/examples/functions/delete-deployment.md | 25 +++--- docs/examples/functions/delete-execution.md | 25 +++--- docs/examples/functions/delete-variable.md | 25 +++--- docs/examples/functions/delete.md | 23 ++++-- .../functions/get-deployment-download.md | 29 ++++--- docs/examples/functions/get-deployment.md | 27 ++++--- docs/examples/functions/get-execution.md | 27 ++++--- docs/examples/functions/get-variable.md | 27 ++++--- docs/examples/functions/get.md | 25 +++--- docs/examples/functions/list-deployments.md | 31 +++++--- docs/examples/functions/list-executions.md | 29 ++++--- docs/examples/functions/list-runtimes.md | 25 +++--- .../examples/functions/list-specifications.md | 27 ++++--- docs/examples/functions/list-variables.md | 29 ++++--- docs/examples/functions/list.md | 29 ++++--- .../functions/update-deployment-status.md | 27 ++++--- .../functions/update-function-deployment.md | 27 ++++--- docs/examples/functions/update-variable.md | 35 ++++---- docs/examples/functions/update.md | 79 ++++++++++--------- docs/examples/graphql/mutation.md | 23 ++++-- docs/examples/graphql/query.md | 23 ++++-- docs/examples/locale/get.md | 21 +++-- docs/examples/locale/list-codes.md | 25 +++--- docs/examples/locale/list-continents.md | 25 +++--- docs/examples/locale/list-countries-eu.md | 25 +++--- docs/examples/locale/list-countries-phones.md | 25 +++--- docs/examples/locale/list-countries.md | 25 +++--- docs/examples/locale/list-currencies.md | 25 +++--- docs/examples/locale/list-languages.md | 25 +++--- .../messaging/create-apns-provider.md | 45 ++++++----- .../messaging/create-appwrite-provider.md | 33 +++++--- docs/examples/messaging/create-email.md | 59 ++++++++------ .../examples/messaging/create-fcm-provider.md | 31 +++++--- .../messaging/create-mailgun-provider.md | 49 +++++++----- .../messaging/create-msg-91-provider.md | 35 ++++---- docs/examples/messaging/create-push.md | 69 ++++++++-------- .../messaging/create-resend-provider.md | 45 ++++++----- .../messaging/create-sendgrid-provider.md | 45 ++++++----- .../examples/messaging/create-ses-provider.md | 49 +++++++----- docs/examples/messaging/create-sms.md | 37 +++++---- .../messaging/create-smtp-provider.md | 57 +++++++------ docs/examples/messaging/create-subscriber.md | 29 ++++--- .../messaging/create-telesign-provider.md | 35 ++++---- .../messaging/create-textmagic-provider.md | 35 ++++---- docs/examples/messaging/create-topic.md | 35 ++++---- .../messaging/create-twilio-provider.md | 35 ++++---- .../messaging/create-vonage-provider.md | 35 ++++---- docs/examples/messaging/delete-provider.md | 23 ++++-- docs/examples/messaging/delete-subscriber.md | 25 +++--- docs/examples/messaging/delete-topic.md | 23 ++++-- docs/examples/messaging/delete.md | 23 ++++-- docs/examples/messaging/get-message.md | 25 +++--- docs/examples/messaging/get-provider.md | 25 +++--- docs/examples/messaging/get-subscriber.md | 27 ++++--- docs/examples/messaging/get-topic.md | 25 +++--- docs/examples/messaging/list-messages.md | 29 ++++--- docs/examples/messaging/list-providers.md | 29 ++++--- docs/examples/messaging/list-subscribers.md | 31 +++++--- docs/examples/messaging/list-targets.md | 29 ++++--- docs/examples/messaging/list-topics.md | 29 ++++--- .../messaging/update-apns-provider.md | 45 ++++++----- .../messaging/update-appwrite-provider.md | 33 +++++--- docs/examples/messaging/update-email.md | 59 ++++++++------ .../examples/messaging/update-fcm-provider.md | 31 +++++--- .../messaging/update-mailgun-provider.md | 49 +++++++----- .../messaging/update-msg-91-provider.md | 35 ++++---- docs/examples/messaging/update-push.md | 69 ++++++++-------- .../messaging/update-resend-provider.md | 45 ++++++----- .../messaging/update-sendgrid-provider.md | 45 ++++++----- .../examples/messaging/update-ses-provider.md | 49 +++++++----- docs/examples/messaging/update-sms.md | 37 +++++---- .../messaging/update-smtp-provider.md | 57 +++++++------ .../messaging/update-telesign-provider.md | 35 ++++---- .../messaging/update-textmagic-provider.md | 35 ++++---- docs/examples/messaging/update-topic.md | 35 ++++---- .../messaging/update-twilio-provider.md | 35 ++++---- .../messaging/update-vonage-provider.md | 35 ++++---- docs/examples/mongo/create-backup-policy.md | 37 +++++---- docs/examples/mongo/create-backup.md | 27 ++++--- docs/examples/mongo/create-branch.md | 29 ++++--- docs/examples/mongo/create-failover.md | 27 ++++--- docs/examples/mongo/create-migration.md | 29 ++++--- docs/examples/mongo/create-restoration.md | 45 ++++++----- docs/examples/mongo/create-upgrade.md | 27 ++++--- docs/examples/mongo/create.md | 57 +++++++------ docs/examples/mongo/delete-backup-policy.md | 25 +++--- docs/examples/mongo/delete-backup.md | 25 +++--- docs/examples/mongo/delete-branch.md | 27 ++++--- docs/examples/mongo/delete.md | 23 ++++-- docs/examples/mongo/get-backup-policy.md | 27 ++++--- docs/examples/mongo/get-backup.md | 27 ++++--- docs/examples/mongo/get-pitr.md | 25 +++--- docs/examples/mongo/get-replicas.md | 25 +++--- docs/examples/mongo/get-restoration.md | 27 ++++--- docs/examples/mongo/get-status.md | 25 +++--- docs/examples/mongo/get.md | 25 +++--- docs/examples/mongo/list-backup-policies.md | 29 ++++--- docs/examples/mongo/list-backups.md | 29 ++++--- docs/examples/mongo/list-branches.md | 25 +++--- docs/examples/mongo/list-operations.md | 31 +++++--- docs/examples/mongo/list-restorations.md | 33 +++++--- docs/examples/mongo/list-specifications.md | 21 +++-- docs/examples/mongo/list.md | 27 ++++--- docs/examples/mongo/promote-restoration.md | 27 ++++--- docs/examples/mongo/update-backup-policy.md | 35 ++++---- docs/examples/mongo/update-backup-storage.md | 45 ++++++----- docs/examples/mongo/update-credentials.md | 25 +++--- docs/examples/mongo/update-maintenance.md | 29 ++++--- docs/examples/mongo/update.md | 71 +++++++++-------- docs/examples/mysql/create-backup-policy.md | 37 +++++---- docs/examples/mysql/create-backup.md | 27 ++++--- docs/examples/mysql/create-branch.md | 29 ++++--- docs/examples/mysql/create-execution.md | 31 +++++--- docs/examples/mysql/create-failover.md | 27 ++++--- docs/examples/mysql/create-migration.md | 29 ++++--- docs/examples/mysql/create-restoration.md | 45 ++++++----- docs/examples/mysql/create-upgrade.md | 27 ++++--- docs/examples/mysql/create.md | 57 +++++++------ docs/examples/mysql/delete-backup-policy.md | 25 +++--- docs/examples/mysql/delete-backup.md | 25 +++--- docs/examples/mysql/delete-branch.md | 27 ++++--- docs/examples/mysql/delete.md | 23 ++++-- docs/examples/mysql/get-backup-policy.md | 27 ++++--- docs/examples/mysql/get-backup.md | 27 ++++--- docs/examples/mysql/get-pitr.md | 25 +++--- docs/examples/mysql/get-pooler.md | 25 +++--- docs/examples/mysql/get-replicas.md | 25 +++--- docs/examples/mysql/get-restoration.md | 27 ++++--- docs/examples/mysql/get-status.md | 25 +++--- docs/examples/mysql/get.md | 25 +++--- docs/examples/mysql/list-backup-policies.md | 29 ++++--- docs/examples/mysql/list-backups.md | 29 ++++--- docs/examples/mysql/list-branches.md | 25 +++--- docs/examples/mysql/list-operations.md | 31 +++++--- docs/examples/mysql/list-restorations.md | 33 +++++--- docs/examples/mysql/list-specifications.md | 21 +++-- docs/examples/mysql/list.md | 27 ++++--- docs/examples/mysql/promote-restoration.md | 27 ++++--- docs/examples/mysql/update-backup-policy.md | 35 ++++---- docs/examples/mysql/update-backup-storage.md | 45 ++++++----- docs/examples/mysql/update-credentials.md | 25 +++--- docs/examples/mysql/update-maintenance.md | 29 ++++--- docs/examples/mysql/update-pooler.md | 47 ++++++----- docs/examples/mysql/update.md | 71 +++++++++-------- docs/examples/oauth2/approve.md | 29 ++++--- docs/examples/oauth2/authorize-post.md | 57 +++++++------ docs/examples/oauth2/authorize.md | 57 +++++++------ .../oauth2/create-device-authorization.md | 33 +++++--- docs/examples/oauth2/create-grant.md | 25 +++--- docs/examples/oauth2/create-par.md | 55 +++++++------ docs/examples/oauth2/create-token.md | 49 +++++++----- docs/examples/oauth2/get-grant.md | 25 +++--- docs/examples/oauth2/introspect.md | 31 +++++--- docs/examples/oauth2/list-organizations.md | 29 ++++--- docs/examples/oauth2/list-projects.md | 29 ++++--- docs/examples/oauth2/reject.md | 25 +++--- docs/examples/oauth2/revoke.md | 29 ++++--- .../create-ephemeral-project-key.md | 29 ++++--- .../organization/create-installation.md | 27 ++++--- .../organization/create-membership.md | 35 ++++---- docs/examples/organization/create-project.md | 29 ++++--- .../organization/delete-installation.md | 23 ++++-- .../organization/delete-membership.md | 23 ++++-- .../organization/delete-project-key.md | 25 +++--- docs/examples/organization/delete-project.md | 23 ++++-- docs/examples/organization/delete.md | 19 +++-- .../examples/organization/get-installation.md | 25 +++--- docs/examples/organization/get-membership.md | 25 +++--- docs/examples/organization/get-project-key.md | 27 ++++--- docs/examples/organization/get-project.md | 25 +++--- docs/examples/organization/get.md | 21 +++-- .../organization/list-installations.md | 27 ++++--- .../examples/organization/list-memberships.md | 29 ++++--- .../organization/list-project-keys.md | 29 ++++--- docs/examples/organization/list-projects.md | 29 ++++--- .../organization/update-installation.md | 27 ++++--- .../organization/update-membership.md | 27 ++++--- .../organization/update-project-key.md | 35 ++++---- docs/examples/organization/update-project.md | 27 ++++--- docs/examples/organization/update.md | 25 +++--- .../postgresql/create-backup-policy.md | 37 +++++---- docs/examples/postgresql/create-backup.md | 27 ++++--- docs/examples/postgresql/create-branch.md | 29 ++++--- docs/examples/postgresql/create-execution.md | 31 +++++--- docs/examples/postgresql/create-extension.md | 27 ++++--- docs/examples/postgresql/create-failover.md | 27 ++++--- docs/examples/postgresql/create-migration.md | 29 ++++--- .../examples/postgresql/create-restoration.md | 45 ++++++----- docs/examples/postgresql/create-upgrade.md | 27 ++++--- docs/examples/postgresql/create.md | 57 +++++++------ .../postgresql/delete-backup-policy.md | 25 +++--- docs/examples/postgresql/delete-backup.md | 25 +++--- docs/examples/postgresql/delete-branch.md | 27 ++++--- docs/examples/postgresql/delete-extension.md | 27 ++++--- docs/examples/postgresql/delete.md | 23 ++++-- docs/examples/postgresql/get-backup-policy.md | 27 ++++--- docs/examples/postgresql/get-backup.md | 27 ++++--- docs/examples/postgresql/get-pitr.md | 25 +++--- docs/examples/postgresql/get-pooler.md | 25 +++--- docs/examples/postgresql/get-replicas.md | 25 +++--- docs/examples/postgresql/get-restoration.md | 27 ++++--- docs/examples/postgresql/get-status.md | 25 +++--- docs/examples/postgresql/get.md | 25 +++--- .../postgresql/list-backup-policies.md | 29 ++++--- docs/examples/postgresql/list-backups.md | 29 ++++--- docs/examples/postgresql/list-branches.md | 25 +++--- docs/examples/postgresql/list-extensions.md | 25 +++--- docs/examples/postgresql/list-operations.md | 31 +++++--- docs/examples/postgresql/list-restorations.md | 33 +++++--- .../postgresql/list-specifications.md | 21 +++-- docs/examples/postgresql/list.md | 27 ++++--- .../postgresql/promote-restoration.md | 27 ++++--- .../postgresql/update-backup-policy.md | 35 ++++---- .../postgresql/update-backup-storage.md | 45 ++++++----- .../examples/postgresql/update-credentials.md | 25 +++--- .../examples/postgresql/update-maintenance.md | 29 ++++--- docs/examples/postgresql/update-pooler.md | 47 ++++++----- docs/examples/postgresql/update.md | 71 +++++++++-------- docs/examples/presences/delete.md | 23 ++++-- docs/examples/presences/get.md | 25 +++--- docs/examples/presences/list.md | 29 ++++--- docs/examples/presences/update.md | 37 +++++---- docs/examples/presences/upsert.md | 35 ++++---- .../project/create-android-platform.md | 31 +++++--- .../examples/project/create-apple-platform.md | 29 ++++--- docs/examples/project/create-environment.md | 27 ++++--- docs/examples/project/create-ephemeral-key.md | 27 ++++--- .../examples/project/create-linux-platform.md | 29 ++++--- docs/examples/project/create-mock-phone.md | 27 ++++--- docs/examples/project/create-smtp-test.md | 23 ++++-- docs/examples/project/create-variable.md | 33 +++++--- docs/examples/project/create-web-platform.md | 29 ++++--- .../project/create-windows-platform.md | 29 ++++--- docs/examples/project/delete-environment.md | 23 ++++-- docs/examples/project/delete-key.md | 23 ++++-- docs/examples/project/delete-mock-phone.md | 23 ++++-- docs/examples/project/delete-platform.md | 23 ++++-- docs/examples/project/delete-variable.md | 23 ++++-- docs/examples/project/delete.md | 19 +++-- docs/examples/project/get-email-template.md | 27 ++++--- docs/examples/project/get-environment.md | 25 +++--- docs/examples/project/get-key.md | 25 +++--- docs/examples/project/get-mock-phone.md | 25 +++--- .../examples/project/get-o-auth-2-provider.md | 25 +++--- docs/examples/project/get-platform.md | 25 +++--- docs/examples/project/get-policy.md | 25 +++--- docs/examples/project/get-variable.md | 25 +++--- docs/examples/project/get.md | 21 +++-- docs/examples/project/list-email-templates.md | 27 ++++--- docs/examples/project/list-environments.md | 27 ++++--- docs/examples/project/list-keys.md | 27 ++++--- docs/examples/project/list-mock-phones.md | 27 ++++--- .../project/list-o-auth-2-providers.md | 27 ++++--- docs/examples/project/list-platforms.md | 27 ++++--- docs/examples/project/list-policies.md | 27 ++++--- docs/examples/project/list-variables.md | 27 ++++--- .../project/update-android-platform.md | 31 +++++--- .../examples/project/update-apple-platform.md | 29 ++++--- docs/examples/project/update-auth-method.md | 27 ++++--- .../update-deny-aliased-email-policy.md | 25 +++--- .../update-deny-corporate-email-policy.md | 25 +++--- .../update-deny-disposable-email-policy.md | 25 +++--- .../project/update-deny-free-email-policy.md | 25 +++--- .../examples/project/update-email-template.md | 45 ++++++----- docs/examples/project/update-environment.md | 27 ++++--- docs/examples/project/update-key.md | 33 +++++--- docs/examples/project/update-labels.md | 25 +++--- .../examples/project/update-linux-platform.md | 29 ++++--- .../update-membership-privacy-policy.md | 35 ++++---- .../project/update-mfa-factors-policy.md | 31 +++++--- docs/examples/project/update-mock-phone.md | 27 ++++--- .../project/update-o-auth-2-amazon.md | 29 ++++--- .../examples/project/update-o-auth-2-apple.md | 37 +++++---- .../project/update-o-auth-2-appwrite.md | 29 ++++--- .../project/update-o-auth-2-auth-0.md | 33 +++++--- .../project/update-o-auth-2-authentik.md | 31 +++++--- .../project/update-o-auth-2-autodesk.md | 29 ++++--- .../project/update-o-auth-2-bitbucket.md | 29 ++++--- .../examples/project/update-o-auth-2-bitly.md | 29 ++++--- docs/examples/project/update-o-auth-2-box.md | 29 ++++--- .../project/update-o-auth-2-cloudflare.md | 29 ++++--- .../project/update-o-auth-2-dailymotion.md | 29 ++++--- .../project/update-o-auth-2-discord.md | 31 +++++--- .../project/update-o-auth-2-disqus.md | 29 ++++--- .../project/update-o-auth-2-dropbox.md | 29 ++++--- docs/examples/project/update-o-auth-2-etsy.md | 29 ++++--- .../project/update-o-auth-2-facebook.md | 29 ++++--- .../examples/project/update-o-auth-2-figma.md | 29 ++++--- .../project/update-o-auth-2-fusion-auth.md | 31 +++++--- .../project/update-o-auth-2-git-hub.md | 31 +++++--- .../project/update-o-auth-2-gitlab.md | 31 +++++--- .../project/update-o-auth-2-google.md | 35 ++++---- .../project/update-o-auth-2-hugging-face.md | 29 ++++--- .../examples/project/update-o-auth-2-kakao.md | 31 +++++--- .../project/update-o-auth-2-keycloak.md | 33 +++++--- docs/examples/project/update-o-auth-2-kick.md | 29 ++++--- .../project/update-o-auth-2-linkedin.md | 29 ++++--- .../project/update-o-auth-2-microsoft.md | 33 +++++--- .../project/update-o-auth-2-notion.md | 29 ++++--- docs/examples/project/update-o-auth-2-oidc.md | 47 ++++++----- docs/examples/project/update-o-auth-2-okta.md | 35 ++++---- .../project/update-o-auth-2-paypal-sandbox.md | 29 ++++--- .../project/update-o-auth-2-paypal.md | 29 ++++--- .../examples/project/update-o-auth-2-podio.md | 29 ++++--- .../project/update-o-auth-2-resend.md | 29 ++++--- .../project/update-o-auth-2-salesforce.md | 31 +++++--- .../project/update-o-auth-2-server.md | 61 +++++++------- .../examples/project/update-o-auth-2-slack.md | 29 ++++--- .../project/update-o-auth-2-spotify.md | 29 ++++--- .../project/update-o-auth-2-stripe.md | 29 ++++--- .../project/update-o-auth-2-tik-tok.md | 29 ++++--- .../update-o-auth-2-tradeshift-sandbox.md | 29 ++++--- .../project/update-o-auth-2-tradeshift.md | 29 ++++--- .../project/update-o-auth-2-twitch.md | 29 ++++--- .../project/update-o-auth-2-webflow.md | 29 ++++--- .../project/update-o-auth-2-word-press.md | 29 ++++--- .../examples/project/update-o-auth-2-yahoo.md | 29 ++++--- .../project/update-o-auth-2-yandex.md | 29 ++++--- docs/examples/project/update-o-auth-2-zoho.md | 31 +++++--- docs/examples/project/update-o-auth-2-zoom.md | 29 ++++--- docs/examples/project/update-o-auth-2x.md | 29 ++++--- .../examples/project/update-passkey-policy.md | 25 +++--- .../update-password-dictionary-policy.md | 27 ++++--- .../project/update-password-history-policy.md | 25 +++--- .../update-password-personal-data-policy.md | 27 ++++--- .../project/update-password-pwned-policy.md | 29 ++++--- .../update-password-rotation-policy.md | 27 ++++--- .../update-password-strength-policy.md | 33 +++++--- docs/examples/project/update-protocol.md | 27 ++++--- docs/examples/project/update-service.md | 27 ++++--- .../project/update-session-alert-policy.md | 25 +++--- .../project/update-session-duration-policy.md | 25 +++--- .../update-session-invalidation-policy.md | 25 +++--- .../project/update-session-limit-policy.md | 25 +++--- docs/examples/project/update-smtp.md | 49 +++++++----- .../project/update-user-limit-policy.md | 25 +++--- docs/examples/project/update-variable.md | 33 +++++--- docs/examples/project/update-web-platform.md | 29 ++++--- .../project/update-windows-platform.md | 29 ++++--- docs/examples/proxy/create-api-rule.md | 25 +++--- docs/examples/proxy/create-function-rule.md | 29 ++++--- docs/examples/proxy/create-invalidation.md | 29 ++++--- docs/examples/proxy/create-redirect-rule.md | 33 +++++--- docs/examples/proxy/create-site-rule.md | 29 ++++--- docs/examples/proxy/create-smtp-rule.md | 29 ++++--- docs/examples/proxy/delete-rule.md | 23 ++++-- docs/examples/proxy/get-rule.md | 25 +++--- docs/examples/proxy/list-rules.md | 27 ++++--- docs/examples/proxy/update-rule-status.md | 25 +++--- docs/examples/sites/create-deployment.md | 35 ++++---- .../sites/create-duplicate-deployment.md | 27 ++++--- .../sites/create-template-deployment.md | 37 +++++---- docs/examples/sites/create-variable.md | 35 ++++---- docs/examples/sites/create-vcs-deployment.md | 31 +++++--- docs/examples/sites/create.md | 79 ++++++++++--------- docs/examples/sites/delete-deployment.md | 25 +++--- docs/examples/sites/delete-log.md | 25 +++--- docs/examples/sites/delete-variable.md | 25 +++--- docs/examples/sites/delete.md | 23 ++++-- .../examples/sites/get-deployment-download.md | 29 ++++--- docs/examples/sites/get-deployment.md | 27 ++++--- docs/examples/sites/get-log.md | 27 ++++--- docs/examples/sites/get-variable.md | 27 ++++--- docs/examples/sites/get.md | 25 +++--- docs/examples/sites/list-deployments.md | 31 +++++--- docs/examples/sites/list-frameworks.md | 25 +++--- docs/examples/sites/list-logs.md | 29 ++++--- docs/examples/sites/list-specifications.md | 27 ++++--- docs/examples/sites/list-variables.md | 29 ++++--- docs/examples/sites/list.md | 29 ++++--- .../sites/update-deployment-status.md | 27 ++++--- docs/examples/sites/update-site-deployment.md | 27 ++++--- docs/examples/sites/update-variable.md | 35 ++++---- docs/examples/sites/update.md | 79 ++++++++++--------- docs/examples/storage/create-bucket.md | 55 +++++++------ docs/examples/storage/create-file.md | 33 +++++--- docs/examples/storage/delete-bucket.md | 23 ++++-- docs/examples/storage/delete-file.md | 25 +++--- docs/examples/storage/get-bucket.md | 25 +++--- docs/examples/storage/get-file-download.md | 27 ++++--- docs/examples/storage/get-file-preview.md | 49 +++++++----- docs/examples/storage/get-file-view.md | 27 ++++--- docs/examples/storage/get-file.md | 27 ++++--- docs/examples/storage/list-buckets.md | 29 ++++--- docs/examples/storage/list-files.md | 31 +++++--- docs/examples/storage/update-bucket.md | 55 +++++++------ docs/examples/storage/update-file.md | 31 +++++--- .../tablesdb/create-big-int-column.md | 47 ++++++----- .../tablesdb/create-boolean-column.md | 37 +++++---- docs/examples/tablesdb/create-cutover.md | 27 ++++--- .../tablesdb/create-datetime-column.md | 37 +++++---- docs/examples/tablesdb/create-email-column.md | 37 +++++---- docs/examples/tablesdb/create-enum-column.md | 45 ++++++----- docs/examples/tablesdb/create-failover.md | 27 ++++--- docs/examples/tablesdb/create-float-column.md | 47 ++++++----- docs/examples/tablesdb/create-index.md | 45 ++++++----- .../tablesdb/create-integer-column.md | 47 ++++++----- docs/examples/tablesdb/create-ip-column.md | 37 +++++---- docs/examples/tablesdb/create-line-column.md | 35 ++++---- .../tablesdb/create-longtext-column.md | 45 ++++++----- .../tablesdb/create-mediumtext-column.md | 45 ++++++----- docs/examples/tablesdb/create-migration.md | 29 ++++--- docs/examples/tablesdb/create-operations.md | 27 ++++--- docs/examples/tablesdb/create-point-column.md | 35 ++++---- .../tablesdb/create-polygon-column.md | 35 ++++---- docs/examples/tablesdb/create-query.md | 35 ++++---- .../tablesdb/create-relationship-column.md | 47 ++++++----- docs/examples/tablesdb/create-row.md | 35 ++++---- docs/examples/tablesdb/create-rows.md | 31 +++++--- .../examples/tablesdb/create-string-column.md | 47 ++++++----- docs/examples/tablesdb/create-table.md | 47 ++++++----- docs/examples/tablesdb/create-text-column.md | 45 ++++++----- docs/examples/tablesdb/create-transaction.md | 25 +++--- docs/examples/tablesdb/create-url-column.md | 37 +++++---- .../tablesdb/create-varchar-column.md | 47 ++++++----- docs/examples/tablesdb/create.md | 37 +++++---- .../examples/tablesdb/decrement-row-column.md | 37 +++++---- docs/examples/tablesdb/delete-column.md | 27 ++++--- docs/examples/tablesdb/delete-index.md | 27 ++++--- docs/examples/tablesdb/delete-migration.md | 25 +++--- docs/examples/tablesdb/delete-row.md | 29 ++++--- docs/examples/tablesdb/delete-rows.md | 31 +++++--- docs/examples/tablesdb/delete-table.md | 25 +++--- docs/examples/tablesdb/delete-transaction.md | 23 ++++-- docs/examples/tablesdb/delete.md | 23 ++++-- docs/examples/tablesdb/get-column.md | 29 ++++--- docs/examples/tablesdb/get-index.md | 29 ++++--- docs/examples/tablesdb/get-migration.md | 27 ++++--- docs/examples/tablesdb/get-replicas.md | 25 +++--- docs/examples/tablesdb/get-row.md | 33 +++++--- docs/examples/tablesdb/get-status.md | 25 +++--- docs/examples/tablesdb/get-table.md | 27 ++++--- docs/examples/tablesdb/get-transaction.md | 25 +++--- docs/examples/tablesdb/get.md | 25 +++--- .../examples/tablesdb/increment-row-column.md | 37 +++++---- docs/examples/tablesdb/list-columns.md | 31 +++++--- docs/examples/tablesdb/list-indexes.md | 31 +++++--- docs/examples/tablesdb/list-migrations.md | 25 +++--- docs/examples/tablesdb/list-operations.md | 31 +++++--- docs/examples/tablesdb/list-rows.md | 35 ++++---- docs/examples/tablesdb/list-specifications.md | 21 +++-- docs/examples/tablesdb/list-tables.md | 31 +++++--- docs/examples/tablesdb/list-transactions.md | 27 ++++--- docs/examples/tablesdb/list.md | 29 ++++--- .../tablesdb/update-big-int-column.md | 47 ++++++----- .../tablesdb/update-boolean-column.md | 37 +++++---- .../tablesdb/update-datetime-column.md | 37 +++++---- docs/examples/tablesdb/update-email-column.md | 37 +++++---- docs/examples/tablesdb/update-enum-column.md | 45 ++++++----- docs/examples/tablesdb/update-float-column.md | 47 ++++++----- .../tablesdb/update-integer-column.md | 47 ++++++----- docs/examples/tablesdb/update-ip-column.md | 37 +++++---- docs/examples/tablesdb/update-line-column.md | 37 +++++---- .../tablesdb/update-longtext-column.md | 37 +++++---- .../tablesdb/update-mediumtext-column.md | 37 +++++---- docs/examples/tablesdb/update-point-column.md | 37 +++++---- .../tablesdb/update-polygon-column.md | 37 +++++---- .../tablesdb/update-relationship-column.md | 35 ++++---- docs/examples/tablesdb/update-row.md | 35 ++++---- docs/examples/tablesdb/update-rows.md | 33 +++++--- .../examples/tablesdb/update-string-column.md | 45 ++++++----- docs/examples/tablesdb/update-table.md | 45 ++++++----- docs/examples/tablesdb/update-text-column.md | 37 +++++---- docs/examples/tablesdb/update-transaction.md | 29 ++++--- docs/examples/tablesdb/update-url-column.md | 37 +++++---- .../tablesdb/update-varchar-column.md | 45 ++++++----- docs/examples/tablesdb/update.md | 37 +++++---- docs/examples/tablesdb/upsert-row.md | 35 ++++---- docs/examples/tablesdb/upsert-rows.md | 31 +++++--- docs/examples/teams/create-installation.md | 29 ++++--- docs/examples/teams/create-membership.md | 45 ++++++----- docs/examples/teams/create.md | 29 ++++--- docs/examples/teams/delete-installation.md | 25 +++--- docs/examples/teams/delete-membership.md | 25 +++--- docs/examples/teams/delete.md | 23 ++++-- docs/examples/teams/get-installation.md | 27 ++++--- docs/examples/teams/get-membership.md | 27 ++++--- docs/examples/teams/get-prefs.md | 25 +++--- docs/examples/teams/get.md | 25 +++--- docs/examples/teams/list-installations.md | 29 ++++--- docs/examples/teams/list-memberships.md | 31 +++++--- docs/examples/teams/list.md | 29 ++++--- docs/examples/teams/update-installation.md | 29 ++++--- .../teams/update-membership-status.md | 31 +++++--- docs/examples/teams/update-membership.md | 29 ++++--- docs/examples/teams/update-name.md | 27 ++++--- docs/examples/teams/update-prefs.md | 27 ++++--- docs/examples/tokens/create-file-token.md | 29 ++++--- docs/examples/tokens/delete.md | 23 ++++-- docs/examples/tokens/get.md | 25 +++--- docs/examples/tokens/list.md | 31 +++++--- docs/examples/tokens/update.md | 27 ++++--- docs/examples/users/create-argon-2-user.md | 31 +++++--- docs/examples/users/create-bcrypt-user.md | 31 +++++--- docs/examples/users/create-jwt.md | 29 ++++--- docs/examples/users/create-md-5-user.md | 31 +++++--- .../users/create-mfa-recovery-codes.md | 25 +++--- docs/examples/users/create-ph-pass-user.md | 31 +++++--- .../users/create-scrypt-modified-user.md | 37 +++++---- docs/examples/users/create-scrypt-user.md | 47 ++++++----- docs/examples/users/create-session.md | 25 +++--- docs/examples/users/create-sha-user.md | 33 +++++--- docs/examples/users/create-target.md | 35 ++++---- docs/examples/users/create-token.md | 29 ++++--- docs/examples/users/create.md | 33 +++++--- docs/examples/users/delete-identity.md | 23 ++++-- .../users/delete-mfa-authenticator.md | 25 +++--- docs/examples/users/delete-passkey.md | 25 +++--- docs/examples/users/delete-session.md | 25 +++--- docs/examples/users/delete-sessions.md | 23 ++++-- docs/examples/users/delete-target.md | 25 +++--- docs/examples/users/delete.md | 23 ++++-- docs/examples/users/get-mfa-challenge.md | 27 ++++--- docs/examples/users/get-mfa-recovery-codes.md | 25 +++--- docs/examples/users/get-passkey.md | 27 ++++--- docs/examples/users/get-prefs.md | 25 +++--- docs/examples/users/get-target.md | 27 ++++--- docs/examples/users/get.md | 25 +++--- docs/examples/users/list-identities.md | 29 ++++--- docs/examples/users/list-memberships.md | 31 +++++--- docs/examples/users/list-mfa-factors.md | 25 +++--- docs/examples/users/list-passkeys.md | 29 ++++--- docs/examples/users/list-sessions.md | 27 ++++--- docs/examples/users/list-targets.md | 29 ++++--- docs/examples/users/list.md | 29 ++++--- .../users/update-email-verification.md | 27 ++++--- docs/examples/users/update-email.md | 27 ++++--- docs/examples/users/update-impersonator.md | 27 ++++--- docs/examples/users/update-labels.md | 27 ++++--- .../users/update-mfa-recovery-codes.md | 25 +++--- docs/examples/users/update-mfa.md | 27 ++++--- docs/examples/users/update-name.md | 27 ++++--- docs/examples/users/update-passkey.md | 29 ++++--- docs/examples/users/update-password.md | 27 ++++--- .../users/update-phone-verification.md | 27 ++++--- docs/examples/users/update-phone.md | 27 ++++--- docs/examples/users/update-prefs.md | 27 ++++--- docs/examples/users/update-status.md | 27 ++++--- docs/examples/users/update-target.md | 33 +++++--- docs/examples/vectorsdb/create-collection.md | 45 ++++++----- docs/examples/vectorsdb/create-document.md | 35 ++++---- docs/examples/vectorsdb/create-documents.md | 31 +++++--- docs/examples/vectorsdb/create-failover.md | 27 ++++--- docs/examples/vectorsdb/create-index.md | 45 ++++++----- docs/examples/vectorsdb/create-operations.md | 27 ++++--- docs/examples/vectorsdb/create-query.md | 35 ++++---- docs/examples/vectorsdb/create-transaction.md | 25 +++--- docs/examples/vectorsdb/create.md | 37 +++++---- docs/examples/vectorsdb/delete-collection.md | 25 +++--- docs/examples/vectorsdb/delete-document.md | 29 ++++--- docs/examples/vectorsdb/delete-documents.md | 31 +++++--- docs/examples/vectorsdb/delete-index.md | 27 ++++--- docs/examples/vectorsdb/delete-transaction.md | 23 ++++-- docs/examples/vectorsdb/delete.md | 23 ++++-- docs/examples/vectorsdb/get-collection.md | 27 ++++--- docs/examples/vectorsdb/get-document.md | 33 +++++--- docs/examples/vectorsdb/get-index.md | 29 ++++--- docs/examples/vectorsdb/get-replicas.md | 25 +++--- docs/examples/vectorsdb/get-status.md | 25 +++--- docs/examples/vectorsdb/get-transaction.md | 25 +++--- docs/examples/vectorsdb/get.md | 25 +++--- docs/examples/vectorsdb/list-collections.md | 31 +++++--- docs/examples/vectorsdb/list-documents.md | 35 ++++---- docs/examples/vectorsdb/list-indexes.md | 31 +++++--- docs/examples/vectorsdb/list-operations.md | 31 +++++--- .../examples/vectorsdb/list-specifications.md | 21 +++-- docs/examples/vectorsdb/list-transactions.md | 27 ++++--- docs/examples/vectorsdb/list.md | 27 ++++--- docs/examples/vectorsdb/update-collection.md | 45 ++++++----- docs/examples/vectorsdb/update-document.md | 35 ++++---- docs/examples/vectorsdb/update-documents.md | 33 +++++--- docs/examples/vectorsdb/update-transaction.md | 29 ++++--- docs/examples/vectorsdb/update.md | 37 +++++---- docs/examples/vectorsdb/upsert-document.md | 35 ++++---- docs/examples/vectorsdb/upsert-documents.md | 31 +++++--- docs/examples/waf/create-bypass-rule.md | 45 ++++++----- docs/examples/waf/create-challenge-rule.md | 51 ++++++------ docs/examples/waf/create-deny-rule.md | 45 ++++++----- docs/examples/waf/create-rate-limit-rule.md | 55 +++++++------ docs/examples/waf/create-redirect-rule.md | 49 +++++++----- docs/examples/waf/delete-rule.md | 23 ++++-- docs/examples/waf/get-rule.md | 25 +++--- docs/examples/waf/list-rules.md | 29 ++++--- docs/examples/waf/update-bypass-rule.md | 45 ++++++----- docs/examples/waf/update-challenge-rule.md | 51 ++++++------ docs/examples/waf/update-deny-rule.md | 45 ++++++----- docs/examples/waf/update-rate-limit-rule.md | 53 +++++++------ docs/examples/waf/update-redirect-rule.md | 49 +++++++----- docs/examples/webhooks/create.md | 49 +++++++----- docs/examples/webhooks/delete.md | 23 ++++-- docs/examples/webhooks/get.md | 25 +++--- docs/examples/webhooks/list.md | 27 ++++--- docs/examples/webhooks/update-secret.md | 27 ++++--- docs/examples/webhooks/update.md | 47 ++++++----- 874 files changed, 16715 insertions(+), 10597 deletions(-) diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md index 70a7dd34..2397aa24 100644 --- a/docs/examples/account/create-anonymous-session.md +++ b/docs/examples/account/create-anonymous-session.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Session -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) +async def main(): + 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: Session = await account.create_anonymous_session() + + print(result.model_dump()) -result: Session = account.create_anonymous_session() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index 7e016dab..a2121e76 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Session -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) +async def main(): + 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: Session = await account.create_email_password_session( + email = 'email@example.com', + password = 'password', + duration = 60 # optional + ) + + print(result.model_dump()) -result: Session = account.create_email_password_session( - email = 'email@example.com', - password = 'password', - duration = 60 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md index 78c5ecaa..5a310193 100644 --- a/docs/examples/account/create-email-token.md +++ b/docs/examples/account/create-email-token.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.create_email_token( + user_id = '', + email = 'email@example.com', + phrase = False # optional + ) + + print(result.model_dump()) -result: Token = account.create_email_token( - user_id = '', - email = 'email@example.com', - phrase = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-email-verification-otp.md b/docs/examples/account/create-email-verification-otp.md index 92de90e8..aba0bda1 100644 --- a/docs/examples/account/create-email-verification-otp.md +++ b/docs/examples/account/create-email-verification-otp.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.create_email_verification_otp( + phrase = False # optional + ) + + print(result.model_dump()) -result: Token = account.create_email_verification_otp( - phrase = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-email-verification.md b/docs/examples/account/create-email-verification.md index d4d8fd86..d8506e25 100644 --- a/docs/examples/account/create-email-verification.md +++ b/docs/examples/account/create-email-verification.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.create_email_verification( + url = 'https://example.com' + ) + + print(result.model_dump()) -result: Token = account.create_email_verification( - url = 'https://example.com' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-id-token-session.md b/docs/examples/account/create-id-token-session.md index b076d40c..cff07d73 100644 --- a/docs/examples/account/create-id-token-session.md +++ b/docs/examples/account/create-id-token-session.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Session from appwrite.enums.id_token_provider import IdTokenProvider -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) +async def main(): + 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: Session = await account.create_id_token_session( + provider = IdTokenProvider.APPLE, + id_token = '', + nonce = '', # optional + access_token = '', # optional + access_token_expiry = 0, # optional + name = '' # optional + ) + + print(result.model_dump()) -result: Session = account.create_id_token_session( - provider = IdTokenProvider.APPLE, - id_token = '', - nonce = '', # optional - access_token = '', # optional - access_token_expiry = 0, # optional - name = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-magic-url-token.md b/docs/examples/account/create-magic-url-token.md index 5ded0128..d98d61a5 100644 --- a/docs/examples/account/create-magic-url-token.md +++ b/docs/examples/account/create-magic-url-token.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.create_magic_url_token( + user_id = '', + email = 'email@example.com', + url = 'https://example.com', # optional + phrase = False # optional + ) + + print(result.model_dump()) -result: Token = account.create_magic_url_token( - user_id = '', - email = 'email@example.com', - url = 'https://example.com', # optional - phrase = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index 745a0314..47b3cef2 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import MfaType from appwrite.enums.authenticator_type 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) +async def main(): + 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: MfaType = await account.create_mfa_authenticator( + type = AuthenticatorType.TOTP + ) + + print(result.model_dump()) -result: MfaType = account.create_mfa_authenticator( - type = AuthenticatorType.TOTP -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index e26d4e9b..7e78704c 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import MfaChallenge from appwrite.enums.authentication_factor import AuthenticationFactor -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) +async def main(): + 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: MfaChallenge = await account.create_mfa_challenge( + factor = AuthenticationFactor.EMAIL + ) + + print(result.model_dump()) -result: MfaChallenge = account.create_mfa_challenge( - factor = AuthenticationFactor.EMAIL -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index b7a2c4dd..67235316 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import MfaRecoveryCodes -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) +async def main(): + 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: MfaRecoveryCodes = await account.create_mfa_recovery_codes() + + print(result.model_dump()) -result: MfaRecoveryCodes = account.create_mfa_recovery_codes() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index e21fb47d..31a0a647 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.enums.o_auth_provider import OAuthProvider -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) +async def main(): + 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: str = await account.create_o_auth2_token( + provider = OAuthProvider.AMAZON, + success = 'https://example.com', # optional + failure = 'https://example.com', # optional + scopes = [], # optional + state = '' # optional + ) + -result: str = account.create_o_auth2_token( - provider = OAuthProvider.AMAZON, - success = 'https://example.com', # optional - failure = 'https://example.com', # optional - scopes = [], # optional - state = '' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md index 5e33ab57..ed898b37 100644 --- a/docs/examples/account/create-passkey-token.md +++ b/docs/examples/account/create-passkey-token.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import PasskeyChallenge -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) +async def main(): + 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: PasskeyChallenge = await account.create_passkey_token() + + print(result.model_dump()) -result: PasskeyChallenge = account.create_passkey_token() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md index 75bc56fd..cf863d31 100644 --- a/docs/examples/account/create-passkey.md +++ b/docs/examples/account/create-passkey.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import PasskeyChallenge -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) +async def main(): + 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: PasskeyChallenge = await account.create_passkey( + passkey_id = '', # optional + name = '' # optional + ) + + print(result.model_dump()) -result: PasskeyChallenge = account.create_passkey( - passkey_id = '', # optional - name = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md index fb09d64e..f920ab43 100644 --- a/docs/examples/account/create-phone-token.md +++ b/docs/examples/account/create-phone-token.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.create_phone_token( + user_id = '', + phone = '+12065550100' + ) + + print(result.model_dump()) -result: Token = account.create_phone_token( - user_id = '', - phone = '+12065550100' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md index 35d058e2..ae63231a 100644 --- a/docs/examples/account/create-phone-verification.md +++ b/docs/examples/account/create-phone-verification.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.create_phone_verification() + + print(result.model_dump()) -result: Token = account.create_phone_verification() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-recovery-otp.md b/docs/examples/account/create-recovery-otp.md index 02240e31..b0d23215 100644 --- a/docs/examples/account/create-recovery-otp.md +++ b/docs/examples/account/create-recovery-otp.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.create_recovery_otp( + email = 'email@example.com', + phrase = False # optional + ) + + print(result.model_dump()) -result: Token = account.create_recovery_otp( - email = 'email@example.com', - phrase = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index ea63672f..9bc0119b 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.create_recovery( + email = 'email@example.com', + url = 'https://example.com' + ) + + print(result.model_dump()) -result: Token = account.create_recovery( - email = 'email@example.com', - url = 'https://example.com' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md index b09cf722..33f1db52 100644 --- a/docs/examples/account/create-session.md +++ b/docs/examples/account/create-session.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Session -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) +async def main(): + 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: Session = await account.create_session( + user_id = '', + secret = '' + ) + + print(result.model_dump()) -result: Session = account.create_session( - user_id = '', - secret = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index c44a7693..da1249a0 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.create_verification( + url = 'https://example.com' + ) + + print(result.model_dump()) -result: Token = account.create_verification( - url = 'https://example.com' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index 503b3701..88790d18 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User -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) +async def main(): + 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: User = await account.create( + user_id = '', + email = 'email@example.com', + password = 'password', + name = '' # optional + ) + + print(result.model_dump()) -result: User = account.create( - user_id = '', - email = 'email@example.com', - password = 'password', - name = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/delete-consent-token.md b/docs/examples/account/delete-consent-token.md index 614b78ee..6e12afea 100644 --- a/docs/examples/account/delete-consent-token.md +++ b/docs/examples/account/delete-consent-token.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await account.delete_consent_token( + consent_id = '', + token_id = '' + ) + -result = account.delete_consent_token( - consent_id = '', - token_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/account/delete-consent.md b/docs/examples/account/delete-consent.md index 8c2c4113..9d057200 100644 --- a/docs/examples/account/delete-consent.md +++ b/docs/examples/account/delete-consent.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await account.delete_consent( + consent_id = '' + ) + -result = account.delete_consent( - consent_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md index 1ba48c20..6069769e 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await account.delete_identity( + identity_id = '' + ) + -result = account.delete_identity( - identity_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index bc5219a0..7bead4cd 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.enums.authenticator_type 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) +async def main(): + 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 = await account.delete_mfa_authenticator( + type = AuthenticatorType.TOTP + ) + -result = account.delete_mfa_authenticator( - type = AuthenticatorType.TOTP -) +asyncio.run(main()) ``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md index c366ed6a..51f3284d 100644 --- a/docs/examples/account/delete-passkey.md +++ b/docs/examples/account/delete-passkey.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await account.delete_passkey( + passkey_id = '' + ) + -result = account.delete_passkey( - passkey_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index 051a38a5..fe4533a4 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await account.delete_session( + session_id = '' + ) + -result = account.delete_session( - session_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index ae380854..a124f82a 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await account.delete_sessions( + current = False # optional + ) + -result = account.delete_sessions( - current = False # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/account/get-consent-token.md b/docs/examples/account/get-consent-token.md index a5edd0a7..467ee2d6 100644 --- a/docs/examples/account/get-consent-token.md +++ b/docs/examples/account/get-consent-token.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Oauth2ConsentToken -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) +async def main(): + 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: Oauth2ConsentToken = await account.get_consent_token( + consent_id = '', + token_id = '' + ) + + print(result.model_dump()) -result: Oauth2ConsentToken = account.get_consent_token( - consent_id = '', - token_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/get-consent.md b/docs/examples/account/get-consent.md index 45ba0a82..91b98346 100644 --- a/docs/examples/account/get-consent.md +++ b/docs/examples/account/get-consent.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Oauth2Consent -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) +async def main(): + 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: Oauth2Consent = await account.get_consent( + consent_id = '' + ) + + print(result.model_dump()) -result: Oauth2Consent = account.get_consent( - consent_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index f236eb6b..bd0a789d 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import MfaRecoveryCodes -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) +async def main(): + 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: MfaRecoveryCodes = await account.get_mfa_recovery_codes() + + print(result.model_dump()) -result: MfaRecoveryCodes = account.get_mfa_recovery_codes() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md index 018f8467..94a24f00 100644 --- a/docs/examples/account/get-passkey.md +++ b/docs/examples/account/get-passkey.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Passkey -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) +async def main(): + 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: Passkey = await account.get_passkey( + passkey_id = '' + ) + + print(result.model_dump()) -result: Passkey = account.get_passkey( - passkey_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index db586152..773607be 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Preferences -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) +async def main(): + 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: Preferences = await account.get_prefs() + + print(result.model_dump()) -result: Preferences = account.get_prefs() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index 9a247b2a..812d8515 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Session -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) +async def main(): + 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: Session = await account.get_session( + session_id = '' + ) + + print(result.model_dump()) -result: Session = account.get_session( - session_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index c06fd6ba..55f051ac 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User -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) +async def main(): + 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: User = await account.get() + + print(result.model_dump()) -result: User = account.get() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/list-consent-tokens.md b/docs/examples/account/list-consent-tokens.md index 3be9fbe3..8f3eef6d 100644 --- a/docs/examples/account/list-consent-tokens.md +++ b/docs/examples/account/list-consent-tokens.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Oauth2ConsentTokenList -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) +async def main(): + 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: Oauth2ConsentTokenList = await account.list_consent_tokens( + consent_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: Oauth2ConsentTokenList = account.list_consent_tokens( - consent_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/list-consents.md b/docs/examples/account/list-consents.md index d2b5b69c..208332c9 100644 --- a/docs/examples/account/list-consents.md +++ b/docs/examples/account/list-consents.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Oauth2ConsentList -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) +async def main(): + 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: Oauth2ConsentList = await account.list_consents( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: Oauth2ConsentList = account.list_consents( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index 5b8496de..05830487 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import IdentityList -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) +async def main(): + 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: IdentityList = await account.list_identities( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: IdentityList = account.list_identities( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/list-memberships.md b/docs/examples/account/list-memberships.md index 2238f602..f057ff5c 100644 --- a/docs/examples/account/list-memberships.md +++ b/docs/examples/account/list-memberships.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import MembershipList -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) +async def main(): + 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: MembershipList = await account.list_memberships( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: MembershipList = account.list_memberships( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index 411a3e9a..a236e4e9 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import MfaFactors -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) +async def main(): + 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: MfaFactors = await account.list_mfa_factors() + + print(result.model_dump()) -result: MfaFactors = account.list_mfa_factors() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/list-passkeys.md b/docs/examples/account/list-passkeys.md index 8c8df029..3df37f77 100644 --- a/docs/examples/account/list-passkeys.md +++ b/docs/examples/account/list-passkeys.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import PasskeyList -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) +async def main(): + 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: PasskeyList = await account.list_passkeys( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: PasskeyList = account.list_passkeys( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 828aad6f..0c1a17d7 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import SessionList -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) +async def main(): + 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: SessionList = await account.list_sessions( + total = False # optional + ) + + print(result.model_dump()) -result: SessionList = account.list_sessions( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-email-verification-otp.md b/docs/examples/account/update-email-verification-otp.md index b112871f..ee2bda78 100644 --- a/docs/examples/account/update-email-verification-otp.md +++ b/docs/examples/account/update-email-verification-otp.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.update_email_verification_otp( + user_id = '', + secret = '' + ) + + print(result.model_dump()) -result: Token = account.update_email_verification_otp( - user_id = '', - secret = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-email-verification.md b/docs/examples/account/update-email-verification.md index 5415f7d9..8d869776 100644 --- a/docs/examples/account/update-email-verification.md +++ b/docs/examples/account/update-email-verification.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.update_email_verification( + user_id = '', + secret = '' + ) + + print(result.model_dump()) -result: Token = account.update_email_verification( - user_id = '', - secret = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index d559e026..2cf1bcb7 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User -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) +async def main(): + 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: User = await account.update_email( + email = 'email@example.com', + password = 'password' + ) + + print(result.model_dump()) -result: User = account.update_email( - email = 'email@example.com', - password = 'password' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-magic-url-session.md b/docs/examples/account/update-magic-url-session.md index 754bbcdf..8414d2f7 100644 --- a/docs/examples/account/update-magic-url-session.md +++ b/docs/examples/account/update-magic-url-session.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Session -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) +async def main(): + 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: Session = await account.update_magic_url_session( + user_id = '', + secret = '' + ) + + print(result.model_dump()) -result: Session = account.update_magic_url_session( - user_id = '', - secret = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index 60204b9d..57bd0581 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User from appwrite.enums.authenticator_type 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) +async def main(): + 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: User = await account.update_mfa_authenticator( + type = AuthenticatorType.TOTP, + otp = '' + ) + + print(result.model_dump()) -result: User = account.update_mfa_authenticator( - type = AuthenticatorType.TOTP, - otp = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index 40d6382f..ceefe47f 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Session -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) +async def main(): + 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: Session = await account.update_mfa_challenge( + challenge_id = '', + otp = '' + ) + + print(result.model_dump()) -result: Session = account.update_mfa_challenge( - challenge_id = '', - otp = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index 38ff568d..7f08461b 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import MfaRecoveryCodes -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) +async def main(): + 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: MfaRecoveryCodes = await account.update_mfa_recovery_codes() + + print(result.model_dump()) -result: MfaRecoveryCodes = account.update_mfa_recovery_codes() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-mfa.md b/docs/examples/account/update-mfa.md index 607cea79..b561d206 100644 --- a/docs/examples/account/update-mfa.md +++ b/docs/examples/account/update-mfa.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User -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) +async def main(): + 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: User = await account.update_mfa( + mfa = False + ) + + print(result.model_dump()) -result: User = account.update_mfa( - mfa = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index d16c8dd0..849477e5 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User -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) +async def main(): + 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: User = await account.update_name( + name = '' + ) + + print(result.model_dump()) -result: User = account.update_name( - name = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md index 21fabcbf..f9e69c7a 100644 --- a/docs/examples/account/update-passkey-token.md +++ b/docs/examples/account/update-passkey-token.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import TokenSecret -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) +async def main(): + 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: TokenSecret = await account.update_passkey_token( + challenge_id = '', + credential = {} + ) + + print(result.model_dump()) -result: TokenSecret = account.update_passkey_token( - challenge_id = '', - credential = {} -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md index 64904203..7b071486 100644 --- a/docs/examples/account/update-passkey-verification.md +++ b/docs/examples/account/update-passkey-verification.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Passkey -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) +async def main(): + 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: Passkey = await account.update_passkey_verification( + passkey_id = '', + credential = {} + ) + + print(result.model_dump()) -result: Passkey = account.update_passkey_verification( - passkey_id = '', - credential = {} -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md index aae42a4b..f33eb03a 100644 --- a/docs/examples/account/update-passkey.md +++ b/docs/examples/account/update-passkey.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Passkey -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) +async def main(): + 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: Passkey = await account.update_passkey( + passkey_id = '', + name = '' + ) + + print(result.model_dump()) -result: Passkey = account.update_passkey( - passkey_id = '', - name = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 2c6db58b..2fec3e04 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User -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) +async def main(): + 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: User = await account.update_password( + password = 'password', + old_password = 'password' # optional + ) + + print(result.model_dump()) -result: User = account.update_password( - password = 'password', - old_password = 'password' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md index 300cadd8..74d4a7f2 100644 --- a/docs/examples/account/update-phone-session.md +++ b/docs/examples/account/update-phone-session.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Session -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) +async def main(): + 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: Session = await account.update_phone_session( + user_id = '', + secret = '' + ) + + print(result.model_dump()) -result: Session = account.update_phone_session( - user_id = '', - secret = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index 9091264d..48716046 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.update_phone_verification( + user_id = '', + secret = '' + ) + + print(result.model_dump()) -result: Token = account.update_phone_verification( - user_id = '', - secret = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index 6dcd811e..a150c81d 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User -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) +async def main(): + 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: User = await account.update_phone( + phone = '+12065550100', + password = 'password' + ) + + print(result.model_dump()) -result: User = account.update_phone( - phone = '+12065550100', - password = 'password' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 1c6a0a51..27409540 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User -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) +async def main(): + 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: User = account.update_prefs( - prefs = { + result: User = await account.update_prefs( + prefs = { "language": "en", "timezone": "UTC", "darkTheme": True } -) + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-recovery-otp.md b/docs/examples/account/update-recovery-otp.md index e34e5808..4a9e9a8f 100644 --- a/docs/examples/account/update-recovery-otp.md +++ b/docs/examples/account/update-recovery-otp.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.update_recovery_otp( + user_id = '', + secret = '', + password = 'password' + ) + + print(result.model_dump()) -result: Token = account.update_recovery_otp( - user_id = '', - secret = '', - password = 'password' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 3201722e..73ee3e47 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.update_recovery( + user_id = '', + secret = '', + password = 'password' + ) + + print(result.model_dump()) -result: Token = account.update_recovery( - user_id = '', - secret = '', - password = 'password' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index 6232e0b3..6f63f98f 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Session -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) +async def main(): + 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: Session = await account.update_session( + session_id = '' + ) + + print(result.model_dump()) -result: Session = account.update_session( - session_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md index d4801453..674b7a83 100644 --- a/docs/examples/account/update-status.md +++ b/docs/examples/account/update-status.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import User -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) +async def main(): + 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: User = await account.update_status() + + print(result.model_dump()) -result: User = account.update_status() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 5dffe6ad..6363ac7c 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.account import Account from appwrite.models import Token -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) +async def main(): + 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: Token = await account.update_verification( + user_id = '', + secret = '' + ) + + print(result.model_dump()) -result: Token = account.update_verification( - user_id = '', - secret = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/activities/get-event.md b/docs/examples/activities/get-event.md index 12819034..d39be6eb 100644 --- a/docs/examples/activities/get-event.md +++ b/docs/examples/activities/get-event.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.activities import Activities from appwrite.models import ActivityEvent -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 -activities = Activities(client) +async def main(): + 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 + + activities = Activities(client) + + result: ActivityEvent = await activities.get_event( + event_id = '' + ) + + print(result.model_dump()) -result: ActivityEvent = activities.get_event( - event_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md index 14dd6f7d..5297b600 100644 --- a/docs/examples/activities/list-events.md +++ b/docs/examples/activities/list-events.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.activities import Activities from appwrite.models import ActivityEventList -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 -activities = Activities(client) +async def main(): + 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 + + activities = Activities(client) + + result: ActivityEventList = await activities.list_events( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: ActivityEventList = activities.list_events( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/advisor/delete-report.md b/docs/examples/advisor/delete-report.md index ef50a2f0..bab70c79 100644 --- a/docs/examples/advisor/delete-report.md +++ b/docs/examples/advisor/delete-report.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.advisor import Advisor -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 -advisor = Advisor(client) +async def main(): + 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 + + advisor = Advisor(client) + + result = await advisor.delete_report( + report_id = '' + ) + -result = advisor.delete_report( - report_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/advisor/get-insight.md b/docs/examples/advisor/get-insight.md index 7f4b804a..42cbe914 100644 --- a/docs/examples/advisor/get-insight.md +++ b/docs/examples/advisor/get-insight.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.advisor import Advisor from appwrite.models import Insight -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 -advisor = Advisor(client) +async def main(): + 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 + + advisor = Advisor(client) + + result: Insight = await advisor.get_insight( + report_id = '', + insight_id = '' + ) + + print(result.model_dump()) -result: Insight = advisor.get_insight( - report_id = '', - insight_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/advisor/get-report.md b/docs/examples/advisor/get-report.md index 2d9836ac..453d22d0 100644 --- a/docs/examples/advisor/get-report.md +++ b/docs/examples/advisor/get-report.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.advisor import Advisor from appwrite.models import Report -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 -advisor = Advisor(client) +async def main(): + 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 + + advisor = Advisor(client) + + result: Report = await advisor.get_report( + report_id = '' + ) + + print(result.model_dump()) -result: Report = advisor.get_report( - report_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/advisor/list-insights.md b/docs/examples/advisor/list-insights.md index 2813e6e3..979f39f3 100644 --- a/docs/examples/advisor/list-insights.md +++ b/docs/examples/advisor/list-insights.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.advisor import Advisor from appwrite.models import InsightList -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 -advisor = Advisor(client) +async def main(): + 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 + + advisor = Advisor(client) + + result: InsightList = await advisor.list_insights( + report_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: InsightList = advisor.list_insights( - report_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/advisor/list-reports.md b/docs/examples/advisor/list-reports.md index 146bbf1c..19f22550 100644 --- a/docs/examples/advisor/list-reports.md +++ b/docs/examples/advisor/list-reports.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.advisor import Advisor from appwrite.models import ReportList -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 -advisor = Advisor(client) +async def main(): + 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 + + advisor = Advisor(client) + + result: ReportList = await advisor.list_reports( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: ReportList = advisor.list_reports( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/create-installation-token.md b/docs/examples/apps/create-installation-token.md index acbe6cc7..e21b6f41 100644 --- a/docs/examples/apps/create-installation-token.md +++ b/docs/examples/apps/create-installation-token.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import Oauth2Token -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: Oauth2Token = await apps.create_installation_token( + app_id = '', + installation_id = '' + ) + + print(result.model_dump()) -result: Oauth2Token = apps.create_installation_token( - app_id = '', - installation_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/create-key.md b/docs/examples/apps/create-key.md index 2821ba65..480a8caf 100644 --- a/docs/examples/apps/create-key.md +++ b/docs/examples/apps/create-key.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppKey -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppKey = await apps.create_key( + app_id = '' + ) + + print(result.model_dump()) -result: AppKey = apps.create_key( - app_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/create-secret.md b/docs/examples/apps/create-secret.md index 3c901c7e..05d1e6bb 100644 --- a/docs/examples/apps/create-secret.md +++ b/docs/examples/apps/create-secret.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppSecretPlaintext -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppSecretPlaintext = await apps.create_secret( + app_id = '' + ) + + print(result.model_dump()) -result: AppSecretPlaintext = apps.create_secret( - app_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/create.md b/docs/examples/apps/create.md index 04524904..7e10c24d 100644 --- a/docs/examples/apps/create.md +++ b/docs/examples/apps/create.md @@ -1,36 +1,43 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import App -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 - -apps = Apps(client) - -result: App = apps.create( - app_id = '', - name = '', - redirect_uris = [], - description = '', # optional - client_uri = 'https://example.com', # optional - logo_uri = 'https://example.com', # optional - privacy_policy_url = 'https://example.com', # optional - terms_url = 'https://example.com', # optional - contacts = [], # optional - tagline = '', # optional - tags = [], # optional - images = [], # optional - support_url = 'https://example.com', # optional - data_deletion_url = 'https://example.com', # optional - post_logout_redirect_uris = [], # optional - enabled = False, # optional - type = 'public', # optional - device_flow = False, # optional - team_id = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + apps = Apps(client) + + result: App = await apps.create( + app_id = '', + name = '', + redirect_uris = [], + description = '', # optional + client_uri = 'https://example.com', # optional + logo_uri = 'https://example.com', # optional + privacy_policy_url = 'https://example.com', # optional + terms_url = 'https://example.com', # optional + contacts = [], # optional + tagline = '', # optional + tags = [], # optional + images = [], # optional + support_url = 'https://example.com', # optional + data_deletion_url = 'https://example.com', # optional + post_logout_redirect_uris = [], # optional + enabled = False, # optional + type = 'public', # optional + device_flow = False, # optional + team_id = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/apps/delete-installation.md b/docs/examples/apps/delete-installation.md index 2a941e8e..83bc2415 100644 --- a/docs/examples/apps/delete-installation.md +++ b/docs/examples/apps/delete-installation.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result = await apps.delete_installation( + app_id = '', + installation_id = '' + ) + -result = apps.delete_installation( - app_id = '', - installation_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/delete-key.md b/docs/examples/apps/delete-key.md index dca52e39..45b3f101 100644 --- a/docs/examples/apps/delete-key.md +++ b/docs/examples/apps/delete-key.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result = await apps.delete_key( + app_id = '', + key_id = '' + ) + -result = apps.delete_key( - app_id = '', - key_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/delete-secret.md b/docs/examples/apps/delete-secret.md index ae7f0976..0faefecb 100644 --- a/docs/examples/apps/delete-secret.md +++ b/docs/examples/apps/delete-secret.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result = await apps.delete_secret( + app_id = '', + secret_id = '' + ) + -result = apps.delete_secret( - app_id = '', - secret_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/delete-tokens.md b/docs/examples/apps/delete-tokens.md index 60c7f6ff..e0045b8b 100644 --- a/docs/examples/apps/delete-tokens.md +++ b/docs/examples/apps/delete-tokens.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result = await apps.delete_tokens( + app_id = '' + ) + -result = apps.delete_tokens( - app_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/delete.md b/docs/examples/apps/delete.md index 2318e2ef..7bdfc9ec 100644 --- a/docs/examples/apps/delete.md +++ b/docs/examples/apps/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result = await apps.delete( + app_id = '' + ) + -result = apps.delete( - app_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/get-installation.md b/docs/examples/apps/get-installation.md index d71858c9..5292ea48 100644 --- a/docs/examples/apps/get-installation.md +++ b/docs/examples/apps/get-installation.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppInstallation -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppInstallation = await apps.get_installation( + app_id = '', + installation_id = '' + ) + + print(result.model_dump()) -result: AppInstallation = apps.get_installation( - app_id = '', - installation_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/get-key.md b/docs/examples/apps/get-key.md index 4df3d424..9158f80a 100644 --- a/docs/examples/apps/get-key.md +++ b/docs/examples/apps/get-key.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppKey -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppKey = await apps.get_key( + app_id = '', + key_id = '' + ) + + print(result.model_dump()) -result: AppKey = apps.get_key( - app_id = '', - key_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/get-secret.md b/docs/examples/apps/get-secret.md index deaea447..d6593b02 100644 --- a/docs/examples/apps/get-secret.md +++ b/docs/examples/apps/get-secret.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppSecret -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppSecret = await apps.get_secret( + app_id = '', + secret_id = '' + ) + + print(result.model_dump()) -result: AppSecret = apps.get_secret( - app_id = '', - secret_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/get.md b/docs/examples/apps/get.md index 05a82fdc..ec63ef78 100644 --- a/docs/examples/apps/get.md +++ b/docs/examples/apps/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import App -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: App = await apps.get( + app_id = '' + ) + + print(result.model_dump()) -result: App = apps.get( - app_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/list-installation-scopes.md b/docs/examples/apps/list-installation-scopes.md index 4705cf7b..f7ba19ee 100644 --- a/docs/examples/apps/list-installation-scopes.md +++ b/docs/examples/apps/list-installation-scopes.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppScopeList -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppScopeList = await apps.list_installation_scopes() + + print(result.model_dump()) -result: AppScopeList = apps.list_installation_scopes() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/list-installations.md b/docs/examples/apps/list-installations.md index e21575cb..9fc14cb5 100644 --- a/docs/examples/apps/list-installations.md +++ b/docs/examples/apps/list-installations.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppInstallationList -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppInstallationList = await apps.list_installations( + app_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: AppInstallationList = apps.list_installations( - app_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/list-keys.md b/docs/examples/apps/list-keys.md index 7ed78543..8b10ecb9 100644 --- a/docs/examples/apps/list-keys.md +++ b/docs/examples/apps/list-keys.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppKeyList -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppKeyList = await apps.list_keys( + app_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: AppKeyList = apps.list_keys( - app_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/list-o-auth-2-scopes.md b/docs/examples/apps/list-o-auth-2-scopes.md index 8720e78c..477e5eb6 100644 --- a/docs/examples/apps/list-o-auth-2-scopes.md +++ b/docs/examples/apps/list-o-auth-2-scopes.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppScopeList -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppScopeList = await apps.list_o_auth2_scopes() + + print(result.model_dump()) -result: AppScopeList = apps.list_o_auth2_scopes() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/list-secrets.md b/docs/examples/apps/list-secrets.md index 83a4dcd3..440ae7ae 100644 --- a/docs/examples/apps/list-secrets.md +++ b/docs/examples/apps/list-secrets.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppSecretList -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppSecretList = await apps.list_secrets( + app_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: AppSecretList = apps.list_secrets( - app_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/list.md b/docs/examples/apps/list.md index d8edd5f4..2522d64e 100644 --- a/docs/examples/apps/list.md +++ b/docs/examples/apps/list.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import AppsList -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: AppsList = await apps.list( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: AppsList = apps.list( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/update-labels.md b/docs/examples/apps/update-labels.md index 0601df3f..7720d4f1 100644 --- a/docs/examples/apps/update-labels.md +++ b/docs/examples/apps/update-labels.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import App -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: App = await apps.update_labels( + app_id = '', + labels = [] + ) + + print(result.model_dump()) -result: App = apps.update_labels( - app_id = '', - labels = [] -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/update-team.md b/docs/examples/apps/update-team.md index 44203fff..d2173c06 100644 --- a/docs/examples/apps/update-team.md +++ b/docs/examples/apps/update-team.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import App -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 -apps = Apps(client) +async def main(): + 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 + + apps = Apps(client) + + result: App = await apps.update_team( + app_id = '', + team_id = '' + ) + + print(result.model_dump()) -result: App = apps.update_team( - app_id = '', - team_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/apps/update.md b/docs/examples/apps/update.md index c9006df6..30a4cc3f 100644 --- a/docs/examples/apps/update.md +++ b/docs/examples/apps/update.md @@ -1,37 +1,44 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.apps import Apps from appwrite.models import App -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 - -apps = Apps(client) - -result: App = apps.update( - app_id = '', - name = '', - description = '', # optional - client_uri = 'https://example.com', # optional - logo_uri = 'https://example.com', # optional - privacy_policy_url = 'https://example.com', # optional - terms_url = 'https://example.com', # optional - contacts = [], # optional - tagline = '', # optional - tags = [], # optional - images = [], # optional - support_url = 'https://example.com', # optional - data_deletion_url = 'https://example.com', # optional - enabled = False, # optional - redirect_uris = [], # optional - post_logout_redirect_uris = [], # optional - type = 'public', # optional - device_flow = False, # optional - installation_scopes = [], # optional - installation_redirect_url = 'https://example.com' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + apps = Apps(client) + + result: App = await apps.update( + app_id = '', + name = '', + description = '', # optional + client_uri = 'https://example.com', # optional + logo_uri = 'https://example.com', # optional + privacy_policy_url = 'https://example.com', # optional + terms_url = 'https://example.com', # optional + contacts = [], # optional + tagline = '', # optional + tags = [], # optional + images = [], # optional + support_url = 'https://example.com', # optional + data_deletion_url = 'https://example.com', # optional + enabled = False, # optional + redirect_uris = [], # optional + post_logout_redirect_uris = [], # optional + type = 'public', # optional + device_flow = False, # optional + installation_scopes = [], # optional + installation_redirect_url = 'https://example.com' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/delete-photo.md b/docs/examples/avatars/delete-photo.md index 0851c0c5..3fa26691 100644 --- a/docs/examples/avatars/delete-photo.md +++ b/docs/examples/avatars/delete-photo.md @@ -1,13 +1,20 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result = await avatars.delete_photo() + -result = avatars.delete_photo() +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 622244be..38c0cdf7 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars from appwrite.enums.browser import Browser -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result: bytes = await avatars.get_browser( + code = Browser.AVANT_BROWSER, + width = 0, # optional + height = 0, # optional + quality = -1 # optional + ) + -result: bytes = avatars.get_browser( - code = Browser.AVANT_BROWSER, - width = 0, # optional - height = 0, # optional - quality = -1 # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index 8888b752..97439708 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars from appwrite.enums.credit_card import CreditCard -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result: bytes = await avatars.get_credit_card( + code = CreditCard.AMERICAN_EXPRESS, + width = 0, # optional + height = 0, # optional + quality = -1 # optional + ) + -result: bytes = avatars.get_credit_card( - code = CreditCard.AMERICAN_EXPRESS, - width = 0, # optional - height = 0, # optional - quality = -1 # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index dd234eaf..2d3c0dd8 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result: bytes = await avatars.get_favicon( + url = 'https://example.com' + ) + -result: bytes = avatars.get_favicon( - url = 'https://example.com' -) +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index c8b628d8..e5e91a93 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars from appwrite.enums.flag import Flag -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result: bytes = await avatars.get_flag( + code = Flag.AFGHANISTAN, + width = 0, # optional + height = 0, # optional + quality = -1 # optional + ) + -result: bytes = avatars.get_flag( - code = Flag.AFGHANISTAN, - width = 0, # optional - height = 0, # optional - quality = -1 # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 9beea030..efb4e399 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result: bytes = await avatars.get_image( + url = 'https://example.com', + width = 0, # optional + height = 0 # optional + ) + -result: bytes = avatars.get_image( - url = 'https://example.com', - width = 0, # optional - height = 0 # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 08788555..01beb9a8 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result: bytes = await avatars.get_initials( + name = '', # optional + width = 0, # optional + height = 0, # optional + background = 'FFFFFF' # optional + ) + -result: bytes = avatars.get_initials( - name = '', # optional - width = 0, # optional - height = 0, # optional - background = 'FFFFFF' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/get-photo.md b/docs/examples/avatars/get-photo.md index 64cdf309..018b1cfc 100644 --- a/docs/examples/avatars/get-photo.md +++ b/docs/examples/avatars/get-photo.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result: bytes = await avatars.get_photo( + width = 0, # optional + height = 0, # optional + quality = 0, # optional + output = 'png', # optional + rating = 'g', # optional + user_id = 'current()', # optional + email_hash = '', # optional + name = '' # optional + ) + -result: bytes = avatars.get_photo( - width = 0, # optional - height = 0, # optional - quality = 0, # optional - output = 'png', # optional - rating = 'g', # optional - user_id = 'current()', # optional - email_hash = '', # optional - name = '' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/get-qr.md b/docs/examples/avatars/get-qr.md index a7968e75..0682e0e1 100644 --- a/docs/examples/avatars/get-qr.md +++ b/docs/examples/avatars/get-qr.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result: bytes = await avatars.get_qr( + text = '', + size = 1, # optional + margin = 0, # optional + download = False # optional + ) + -result: bytes = avatars.get_qr( - text = '', - size = 1, # optional - margin = 0, # optional - download = False # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 7e39b59b..1a52170f 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars from appwrite.enums.browser_theme import BrowserTheme @@ -6,35 +8,40 @@ from appwrite.enums.timezone import Timezone from appwrite.enums.browser_permission import BrowserPermission from appwrite.enums.image_format import ImageFormat -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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) -result: bytes = avatars.get_screenshot( - url = 'https://example.com', - headers = { + result: bytes = await avatars.get_screenshot( + url = 'https://example.com', + headers = { "Accept-Language": "en-US,en;q=0.9" }, # optional - viewport_width = 1920, # optional - viewport_height = 1080, # optional - scale = 2, # optional - theme = BrowserTheme.DARK, # optional - user_agent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', # optional - fullpage = True, # optional - locale = 'en-US', # optional - timezone = Timezone.AFRICA_ABIDJAN, # optional - latitude = 37.7749, # optional - longitude = -122.4194, # optional - accuracy = 100, # optional - touch = True, # optional - permissions = [BrowserPermission.GEOLOCATION, BrowserPermission.NOTIFICATIONS], # optional - sleep = 3, # optional - width = 800, # optional - height = 600, # optional - quality = 85, # optional - output = ImageFormat.JPEG # optional -) + viewport_width = 1920, # optional + viewport_height = 1080, # optional + scale = 2, # optional + theme = BrowserTheme.DARK, # optional + user_agent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', # optional + fullpage = True, # optional + locale = 'en-US', # optional + timezone = Timezone.AFRICA_ABIDJAN, # optional + latitude = 37.7749, # optional + longitude = -122.4194, # optional + accuracy = 100, # optional + touch = True, # optional + permissions = [BrowserPermission.GEOLOCATION, BrowserPermission.NOTIFICATIONS], # optional + sleep = 3, # optional + width = 800, # optional + height = 600, # optional + quality = 85, # optional + output = ImageFormat.JPEG # optional + ) + + +asyncio.run(main()) ``` diff --git a/docs/examples/avatars/update-photo.md b/docs/examples/avatars/update-photo.md index cdd605a0..06f16c8c 100644 --- a/docs/examples/avatars/update-photo.md +++ b/docs/examples/avatars/update-photo.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.avatars import Avatars from appwrite.input_file import InputFile from appwrite.models 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 -avatars = Avatars(client) +async def main(): + 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 + + avatars = Avatars(client) + + result: Account = await avatars.update_photo( + file = InputFile.from_path('file.png') + ) + + print(result.model_dump()) -result: Account = avatars.update_photo( - file = InputFile.from_path('file.png') -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md index 6d25a93b..008e92b8 100644 --- a/docs/examples/backups/create-archive.md +++ b/docs/examples/backups/create-archive.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupArchive from appwrite.enums.backup_services import BackupServices -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupArchive = await backups.create_archive( + services = [BackupServices.DATABASES], + resource_id = '' # optional + ) + + print(result.model_dump()) -result: BackupArchive = backups.create_archive( - services = [BackupServices.DATABASES], - resource_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md index a100d80e..46c33d90 100644 --- a/docs/examples/backups/create-policy.md +++ b/docs/examples/backups/create-policy.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupPolicy from appwrite.enums.backup_services import BackupServices -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupPolicy = await backups.create_policy( + policy_id = '', + services = [BackupServices.DATABASES], + retention = 1, + schedule = '', + name = '', # optional + resource_id = '', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: BackupPolicy = backups.create_policy( - policy_id = '', - services = [BackupServices.DATABASES], - retention = 1, - schedule = '', - name = '', # optional - resource_id = '', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md index 0c116884..bc4dcf7a 100644 --- a/docs/examples/backups/create-restoration.md +++ b/docs/examples/backups/create-restoration.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupRestoration from appwrite.enums.backup_services import BackupServices -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupRestoration = await backups.create_restoration( + archive_id = '', + services = [BackupServices.DATABASES], + new_resource_id = '', # optional + new_resource_name = '' # optional + ) + + print(result.model_dump()) -result: BackupRestoration = backups.create_restoration( - archive_id = '', - services = [BackupServices.DATABASES], - new_resource_id = '', # optional - new_resource_name = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md index 106e9f0f..56f3b16c 100644 --- a/docs/examples/backups/delete-archive.md +++ b/docs/examples/backups/delete-archive.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result = await backups.delete_archive( + archive_id = '' + ) + -result = backups.delete_archive( - archive_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md index 0583a820..db2383dd 100644 --- a/docs/examples/backups/delete-policy.md +++ b/docs/examples/backups/delete-policy.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result = await backups.delete_policy( + policy_id = '' + ) + -result = backups.delete_policy( - policy_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md index 60b9c646..9b597e9e 100644 --- a/docs/examples/backups/get-archive.md +++ b/docs/examples/backups/get-archive.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupArchive -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupArchive = await backups.get_archive( + archive_id = '' + ) + + print(result.model_dump()) -result: BackupArchive = backups.get_archive( - archive_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md index 3fa673a8..406fcdde 100644 --- a/docs/examples/backups/get-policy.md +++ b/docs/examples/backups/get-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupPolicy -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupPolicy = await backups.get_policy( + policy_id = '' + ) + + print(result.model_dump()) -result: BackupPolicy = backups.get_policy( - policy_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md index 775f047b..82068d48 100644 --- a/docs/examples/backups/get-restoration.md +++ b/docs/examples/backups/get-restoration.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupRestoration -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupRestoration = await backups.get_restoration( + restoration_id = '' + ) + + print(result.model_dump()) -result: BackupRestoration = backups.get_restoration( - restoration_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md index 42674b17..e12b2e51 100644 --- a/docs/examples/backups/list-archives.md +++ b/docs/examples/backups/list-archives.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupArchiveList -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupArchiveList = await backups.list_archives( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: BackupArchiveList = backups.list_archives( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md index 65bc8c9f..cd886f33 100644 --- a/docs/examples/backups/list-policies.md +++ b/docs/examples/backups/list-policies.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupPolicyList -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupPolicyList = await backups.list_policies( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: BackupPolicyList = backups.list_policies( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md index 4556933b..2fb28e51 100644 --- a/docs/examples/backups/list-restorations.md +++ b/docs/examples/backups/list-restorations.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupRestorationList -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupRestorationList = await backups.list_restorations( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: BackupRestorationList = backups.list_restorations( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md index 74fbdeb3..dc6e1e1c 100644 --- a/docs/examples/backups/update-policy.md +++ b/docs/examples/backups/update-policy.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.backups import Backups from appwrite.models import BackupPolicy -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 -backups = Backups(client) +async def main(): + 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 + + backups = Backups(client) + + result: BackupPolicy = await backups.update_policy( + policy_id = '', + name = '', # optional + retention = 1, # optional + schedule = '', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: BackupPolicy = backups.update_policy( - policy_id = '', - name = '', # optional - retention = 1, # optional - schedule = '', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-big-int-attribute.md b/docs/examples/databases/create-big-int-attribute.md index 18025ca5..f586ec28 100644 --- a/docs/examples/databases/create-big-int-attribute.md +++ b/docs/examples/databases/create-big-int-attribute.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeBigint -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: AttributeBigint = databases.create_big_int_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - min = 0, # optional - max = 1000000, # optional - default = 0, # optional - array = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeBigint = await databases.create_big_int_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + min = 0, # optional + max = 1000000, # optional + default = 0, # optional + array = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index 5a9a946b..42272713 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeBoolean -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) +async def main(): + 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: AttributeBoolean = await databases.create_boolean_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = False, # optional + array = False, # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeBoolean = databases.create_boolean_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = False, # optional - array = False, # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index 655144e3..7b9b1742 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Collection from appwrite.permission import Permission from appwrite.role import Role -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: Collection = databases.create_collection( - database_id = '', - collection_id = '', - name = '', - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False, # optional - attributes = [], # optional - indexes = [], # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: Collection = await databases.create_collection( + database_id = '', + collection_id = '', + name = '', + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False, # optional + attributes = [], # optional + indexes = [], # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index 4e4c3702..2e2de327 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeDatetime -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) +async def main(): + 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: AttributeDatetime = await databases.create_datetime_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '2020-10-15T06:38:00.000+00:00', # optional + array = False, # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeDatetime = databases.create_datetime_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = '2020-10-15T06:38:00.000+00:00', # optional - array = False, # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 26b00344..a6d46f09 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role -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) +async def main(): + 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: Document = databases.create_document( - database_id = '', - collection_id = '', - document_id = '', - data = { + result: Document = await databases.create_document( + database_id = '', + collection_id = '', + document_id = '', + data = { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 30, "isAdmin": False }, - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 13e7b94f..ce273321 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -1,19 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import DocumentList -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) +async def main(): + 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: DocumentList = databases.create_documents( - database_id = '', - collection_id = '', - documents = [ + result: DocumentList = await databases.create_documents( + database_id = '', + collection_id = '', + documents = [ { "$id": "example1", "username": "walter.obrien", @@ -23,8 +27,11 @@ result: DocumentList = databases.create_documents( "isAdmin": false } ], - transaction_id = '' # optional -) + transaction_id = '' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index 4745d038..0489b13d 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeEmail -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) +async def main(): + 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: AttributeEmail = await databases.create_email_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'email@example.com', # optional + array = False, # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeEmail = databases.create_email_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'email@example.com', # optional - array = False, # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index d6c6f6de..f58741e7 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeEnum -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: AttributeEnum = databases.create_enum_attribute( - database_id = '', - collection_id = '', - key = '', - elements = ["active", "inactive"], - required = False, - default = 'active', # optional - array = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeEnum = await databases.create_enum_attribute( + database_id = '', + collection_id = '', + key = '', + elements = ["active", "inactive"], + required = False, + default = 'active', # optional + array = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index dd76cec2..57bec919 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeFloat -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: AttributeFloat = databases.create_float_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - min = 0, # optional - max = 100, # optional - default = 10.5, # optional - array = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeFloat = await databases.create_float_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + min = 0, # optional + max = 100, # optional + default = 10.5, # optional + array = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 8102336b..aab12197 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Index from appwrite.enums.databases_index_type import DatabasesIndexType from appwrite.enums.order_by import OrderBy -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: Index = databases.create_index( - database_id = '', - collection_id = '', - key = '', - type = DatabasesIndexType.KEY, - attributes = ["username"], - orders = [OrderBy.ASC], # optional - lengths = [], # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: Index = await databases.create_index( + database_id = '', + collection_id = '', + key = '', + type = DatabasesIndexType.KEY, + attributes = ["username"], + orders = [OrderBy.ASC], # optional + lengths = [], # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index f89a52d2..cdb45ced 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeInteger -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: AttributeInteger = databases.create_integer_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - min = 0, # optional - max = 100, # optional - default = 10, # optional - array = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeInteger = await databases.create_integer_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + min = 0, # optional + max = 100, # optional + default = 10, # optional + array = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index 19f18397..9735a24b 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeIp -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) +async def main(): + 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: AttributeIp = await databases.create_ip_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '192.0.2.0', # optional + array = False, # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeIp = databases.create_ip_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = '192.0.2.0', # optional - array = False, # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index 77f1fa6d..70982d9f 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeLine -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) +async def main(): + 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: AttributeLine = await databases.create_line_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = [[1, 2], [3, 4], [5, 6]], # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeLine = databases.create_line_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = [[1, 2], [3, 4], [5, 6]], # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-longtext-attribute.md b/docs/examples/databases/create-longtext-attribute.md index a8cdecc5..83e37480 100644 --- a/docs/examples/databases/create-longtext-attribute.md +++ b/docs/examples/databases/create-longtext-attribute.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeLongtext -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: AttributeLongtext = databases.create_longtext_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeLongtext = await databases.create_longtext_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-mediumtext-attribute.md b/docs/examples/databases/create-mediumtext-attribute.md index 68a04431..d1ce0f1b 100644 --- a/docs/examples/databases/create-mediumtext-attribute.md +++ b/docs/examples/databases/create-mediumtext-attribute.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeMediumtext -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: AttributeMediumtext = databases.create_mediumtext_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeMediumtext = await databases.create_mediumtext_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md index ce412c3b..86f12115 100644 --- a/docs/examples/databases/create-operations.md +++ b/docs/examples/databases/create-operations.md @@ -1,18 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Transaction -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) +async def main(): + 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: Transaction = databases.create_operations( - transaction_id = '', - operations = [ + result: Transaction = await databases.create_operations( + transaction_id = '', + operations = [ { "action": "create", "databaseId": "", @@ -23,7 +27,10 @@ result: Transaction = databases.create_operations( } } ] # optional -) + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index 91859e78..81f046d1 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributePoint -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) +async def main(): + 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: AttributePoint = await databases.create_point_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = [1, 2], # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributePoint = databases.create_point_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = [1, 2], # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index 6651bd3e..f57a64d0 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributePolygon -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) +async def main(): + 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: AttributePolygon = await databases.create_polygon_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributePolygon = databases.create_polygon_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-query.md b/docs/examples/databases/create-query.md index 917b4254..8faa3606 100644 --- a/docs/examples/databases/create-query.md +++ b/docs/examples/databases/create-query.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import DocumentList -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) +async def main(): + 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: DocumentList = await databases.create_query( + database_id = '', + collection_id = '', + queries = [], # optional + transaction_id = '', # optional + total = False, # optional + ttl = 0 # optional + ) + + print(result.model_dump()) -result: DocumentList = databases.create_query( - database_id = '', - collection_id = '', - queries = [], # optional - transaction_id = '', # optional - total = False, # optional - ttl = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index a04c6e1b..aff99d3a 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeRelationship from appwrite.enums.relationship_type import RelationshipType from appwrite.enums.relation_mutate import RelationMutate -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: AttributeRelationship = 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 - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeRelationship = await 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 + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index 17d8bae1..3c7afac4 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeString -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: AttributeString = databases.create_string_attribute( - database_id = '', - collection_id = '', - key = '', - size = 1, - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeString = await databases.create_string_attribute( + database_id = '', + collection_id = '', + key = '', + size = 1, + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-text-attribute.md b/docs/examples/databases/create-text-attribute.md index 0271b051..4f0d4611 100644 --- a/docs/examples/databases/create-text-attribute.md +++ b/docs/examples/databases/create-text-attribute.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeText -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: AttributeText = databases.create_text_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeText = await databases.create_text_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-transaction.md b/docs/examples/databases/create-transaction.md index 733b2cf3..066e9788 100644 --- a/docs/examples/databases/create-transaction.md +++ b/docs/examples/databases/create-transaction.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Transaction -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) +async def main(): + 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: Transaction = await databases.create_transaction( + ttl = 60 # optional + ) + + print(result.model_dump()) -result: Transaction = databases.create_transaction( - ttl = 60 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index b1b823cf..79aa5bc8 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeUrl -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) +async def main(): + 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: AttributeUrl = await databases.create_url_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'https://example.com', # optional + array = False, # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeUrl = databases.create_url_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'https://example.com', # optional - array = False, # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create-varchar-attribute.md b/docs/examples/databases/create-varchar-attribute.md index 4ebe389a..6822d662 100644 --- a/docs/examples/databases/create-varchar-attribute.md +++ b/docs/examples/databases/create-varchar-attribute.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeVarchar -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: AttributeVarchar = databases.create_varchar_attribute( - database_id = '', - collection_id = '', - key = '', - size = 1, - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeVarchar = await databases.create_varchar_attribute( + database_id = '', + collection_id = '', + key = '', + size = 1, + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index 6d8b67bc..e43cce0e 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Database -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) +async def main(): + 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: Database = await databases.create( + database_id = '', + name = '', + enabled = False, # optional + description = '' # optional + ) + + print(result.model_dump()) -result: Database = databases.create( - database_id = '', - name = '', - enabled = False, # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index 15a42ec3..b907e909 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Document -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) +async def main(): + 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: Document = await databases.decrement_document_attribute( + database_id = '', + collection_id = '', + document_id = '', + attribute = '', + value = 1, # optional + min = 0, # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: Document = databases.decrement_document_attribute( - database_id = '', - collection_id = '', - document_id = '', - attribute = '', - value = 1, # optional - min = 0, # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index f3ba6476..3e080b1c 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -1,17 +1,24 @@ ```python +import asyncio + 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) +async def main(): + 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 = await databases.delete_attribute( + database_id = '', + collection_id = '', + key = '' + ) + -result = databases.delete_attribute( - database_id = '', - collection_id = '', - key = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index ff486c58..338e6e61 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await databases.delete_collection( + database_id = '', + collection_id = '' + ) + -result = databases.delete_collection( - database_id = '', - collection_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 6a56cd2d..e6601e95 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -1,18 +1,25 @@ ```python +import asyncio + 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) +async def main(): + 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 = await databases.delete_document( + database_id = '', + collection_id = '', + document_id = '', + transaction_id = '' # optional + ) + -result = databases.delete_document( - database_id = '', - collection_id = '', - document_id = '', - transaction_id = '' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 21a2a214..15c16029 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import DocumentList -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) +async def main(): + 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: DocumentList = await databases.delete_documents( + database_id = '', + collection_id = '', + queries = ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: DocumentList = databases.delete_documents( - database_id = '', - collection_id = '', - queries = ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index 1e48fa8e..2f0d8ea4 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -1,17 +1,24 @@ ```python +import asyncio + 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) +async def main(): + 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 = await databases.delete_index( + database_id = '', + collection_id = '', + key = '' + ) + -result = databases.delete_index( - database_id = '', - collection_id = '', - key = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/delete-transaction.md b/docs/examples/databases/delete-transaction.md index bbc0d975..01e477ed 100644 --- a/docs/examples/databases/delete-transaction.md +++ b/docs/examples/databases/delete-transaction.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await databases.delete_transaction( + transaction_id = '' + ) + -result = databases.delete_transaction( - transaction_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 4bf78037..3e964dd3 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await databases.delete( + database_id = '' + ) + -result = databases.delete( - database_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index fdcc23da..09995153 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeBoolean @@ -21,18 +23,23 @@ from appwrite.models import AttributeLongtext from appwrite.models import AttributeString from typing import Union -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) +async def main(): + 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: Union[AttributeBoolean, AttributeBigint, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString] = await databases.get_attribute( + database_id = '', + collection_id = '', + key = '' + ) + + print(result.model_dump()) -result: Union[AttributeBoolean, AttributeBigint, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString] = databases.get_attribute( - database_id = '', - collection_id = '', - key = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index 6650f4ae..27cc793a 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Collection -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) +async def main(): + 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: Collection = await databases.get_collection( + database_id = '', + collection_id = '' + ) + + print(result.model_dump()) -result: Collection = databases.get_collection( - database_id = '', - collection_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index c6d968ac..4a3a0138 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Document -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) +async def main(): + 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: Document = await databases.get_document( + database_id = '', + collection_id = '', + document_id = '', + queries = [], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: Document = databases.get_document( - database_id = '', - collection_id = '', - document_id = '', - queries = [], # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index 4d327be1..a56b8c97 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Index -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) +async def main(): + 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: Index = await databases.get_index( + database_id = '', + collection_id = '', + key = '' + ) + + print(result.model_dump()) -result: Index = databases.get_index( - database_id = '', - collection_id = '', - key = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/get-transaction.md b/docs/examples/databases/get-transaction.md index 3348baa8..fa931fa3 100644 --- a/docs/examples/databases/get-transaction.md +++ b/docs/examples/databases/get-transaction.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Transaction -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) +async def main(): + 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: Transaction = await databases.get_transaction( + transaction_id = '' + ) + + print(result.model_dump()) -result: Transaction = databases.get_transaction( - transaction_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index b2906c56..35a2c361 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Database -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) +async def main(): + 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: Database = await databases.get( + database_id = '' + ) + + print(result.model_dump()) -result: Database = databases.get( - database_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 77a96bd3..52e829f3 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Document -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) +async def main(): + 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: Document = await databases.increment_document_attribute( + database_id = '', + collection_id = '', + document_id = '', + attribute = '', + value = 1, # optional + max = 100, # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: Document = databases.increment_document_attribute( - database_id = '', - collection_id = '', - document_id = '', - attribute = '', - value = 1, # optional - max = 100, # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index 4fc25f41..978259ff 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeList -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) +async def main(): + 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: AttributeList = await databases.list_attributes( + database_id = '', + collection_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: AttributeList = databases.list_attributes( - database_id = '', - collection_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index 19e71456..c4a5d1dd 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import CollectionList -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) +async def main(): + 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: CollectionList = await databases.list_collections( + database_id = '', + queries = [], # optional + search = '', # optional + total = False # optional + ) + + print(result.model_dump()) -result: CollectionList = databases.list_collections( - database_id = '', - queries = [], # optional - search = '', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index f085c7d3..e1a36973 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import DocumentList -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) +async def main(): + 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: DocumentList = await databases.list_documents( + database_id = '', + collection_id = '', + queries = [], # optional + transaction_id = '', # optional + total = False, # optional + ttl = 0 # optional + ) + + print(result.model_dump()) -result: DocumentList = databases.list_documents( - database_id = '', - collection_id = '', - queries = [], # optional - transaction_id = '', # optional - total = False, # optional - ttl = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index 7129c5a5..7351f0d3 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import IndexList -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) +async def main(): + 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: IndexList = await databases.list_indexes( + database_id = '', + collection_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: IndexList = databases.list_indexes( - database_id = '', - collection_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md index d382cb93..6621f969 100644 --- a/docs/examples/databases/list-transactions.md +++ b/docs/examples/databases/list-transactions.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import TransactionList -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) +async def main(): + 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: TransactionList = await databases.list_transactions( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: TransactionList = databases.list_transactions( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index 7fb1acd2..3959e5f5 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import DatabaseList -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) +async def main(): + 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: DatabaseList = await databases.list( + queries = [], # optional + search = '', # optional + total = False # optional + ) + + print(result.model_dump()) -result: DatabaseList = databases.list( - queries = [], # optional - search = '', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-big-int-attribute.md b/docs/examples/databases/update-big-int-attribute.md index c6390c47..f38e5b1c 100644 --- a/docs/examples/databases/update-big-int-attribute.md +++ b/docs/examples/databases/update-big-int-attribute.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeBigint -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: AttributeBigint = databases.update_big_int_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 0, - min = 0, # optional - max = 1000000, # optional - new_key = '', # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeBigint = await databases.update_big_int_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 0, + min = 0, # optional + max = 1000000, # optional + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index cf61992a..c3fa806b 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeBoolean -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) +async def main(): + 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: AttributeBoolean = await databases.update_boolean_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = False, + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeBoolean = databases.update_boolean_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = False, - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 70599c47..59f9aeeb 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Collection from appwrite.permission import Permission from appwrite.role import Role -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: Collection = databases.update_collection( - database_id = '', - collection_id = '', - name = '', # optional - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False, # optional - purge = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: Collection = await databases.update_collection( + database_id = '', + collection_id = '', + name = '', # optional + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False, # optional + purge = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index 8c93de1f..607f2e29 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeDatetime -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) +async def main(): + 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: AttributeDatetime = await databases.update_datetime_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '2020-10-15T06:38:00.000+00:00', + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeDatetime = databases.update_datetime_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = '2020-10-15T06:38:00.000+00:00', - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 667d9b6e..1904bc2e 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role -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) +async def main(): + 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: Document = databases.update_document( - database_id = '', - collection_id = '', - document_id = '', - data = { + result: Document = await databases.update_document( + database_id = '', + collection_id = '', + document_id = '', + data = { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 33, "isAdmin": False }, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index edae26a4..21cae55b 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import DocumentList -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) +async def main(): + 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: DocumentList = databases.update_documents( - database_id = '', - collection_id = '', - data = { + result: DocumentList = await databases.update_documents( + database_id = '', + collection_id = '', + data = { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 33, "isAdmin": False }, # optional - queries = [], # optional - transaction_id = '' # optional -) + queries = [], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index 0317082f..08bf963f 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeEmail -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) +async def main(): + 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: AttributeEmail = await databases.update_email_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'email@example.com', + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeEmail = databases.update_email_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'email@example.com', - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index fe9d8fad..170bfeee 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeEnum -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: AttributeEnum = databases.update_enum_attribute( - database_id = '', - collection_id = '', - key = '', - elements = ["active", "inactive"], - required = False, - default = 'active', - new_key = '', # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeEnum = await databases.update_enum_attribute( + database_id = '', + collection_id = '', + key = '', + elements = ["active", "inactive"], + required = False, + default = 'active', + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index 5fc8bf32..8fccbb56 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeFloat -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: AttributeFloat = databases.update_float_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 10.5, - min = 0, # optional - max = 100, # optional - new_key = '', # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeFloat = await databases.update_float_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 10.5, + min = 0, # optional + max = 100, # optional + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index 88bc6301..10f55d89 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeInteger -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: AttributeInteger = databases.update_integer_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 10, - min = 0, # optional - max = 100, # optional - new_key = '', # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeInteger = await databases.update_integer_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 10, + min = 0, # optional + max = 100, # optional + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index 822f58a9..26b6cf65 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeIp -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) +async def main(): + 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: AttributeIp = await databases.update_ip_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '192.0.2.0', + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeIp = databases.update_ip_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = '192.0.2.0', - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index 5bda52b3..7bde7a11 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeLine -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) +async def main(): + 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: AttributeLine = await databases.update_line_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = [[1, 2], [3, 4], [5, 6]], # optional + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeLine = databases.update_line_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = [[1, 2], [3, 4], [5, 6]], # optional - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-longtext-attribute.md b/docs/examples/databases/update-longtext-attribute.md index 38671d67..d89f63ba 100644 --- a/docs/examples/databases/update-longtext-attribute.md +++ b/docs/examples/databases/update-longtext-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeLongtext -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) +async def main(): + 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: AttributeLongtext = await databases.update_longtext_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'Hello World', + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeLongtext = databases.update_longtext_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'Hello World', - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-mediumtext-attribute.md b/docs/examples/databases/update-mediumtext-attribute.md index ff2364b6..0aa2dd7c 100644 --- a/docs/examples/databases/update-mediumtext-attribute.md +++ b/docs/examples/databases/update-mediumtext-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeMediumtext -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) +async def main(): + 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: AttributeMediumtext = await databases.update_mediumtext_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'Hello World', + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeMediumtext = databases.update_mediumtext_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'Hello World', - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index bf91ea2d..87754279 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributePoint -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) +async def main(): + 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: AttributePoint = await databases.update_point_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = [1, 2], # optional + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributePoint = databases.update_point_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = [1, 2], # optional - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index 2a8d94b0..e6d7d63b 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributePolygon -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) +async def main(): + 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: AttributePolygon = await databases.update_polygon_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributePolygon = databases.update_polygon_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index c39fa987..c0e11446 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeRelationship from appwrite.enums.relation_mutate import RelationMutate -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) +async def main(): + 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: AttributeRelationship = await databases.update_relationship_attribute( + database_id = '', + collection_id = '', + key = '', + on_delete = RelationMutate.CASCADE, # optional + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeRelationship = databases.update_relationship_attribute( - database_id = '', - collection_id = '', - key = '', - on_delete = RelationMutate.CASCADE, # optional - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 2989a4cc..090acad9 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeString -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: AttributeString = databases.update_string_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'Hello World', - size = 1, # optional - new_key = '', # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeString = await databases.update_string_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'Hello World', + size = 1, # optional + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-text-attribute.md b/docs/examples/databases/update-text-attribute.md index c28dd7f0..72f2ddb3 100644 --- a/docs/examples/databases/update-text-attribute.md +++ b/docs/examples/databases/update-text-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeText -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) +async def main(): + 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: AttributeText = await databases.update_text_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'Hello World', + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeText = databases.update_text_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'Hello World', - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-transaction.md b/docs/examples/databases/update-transaction.md index 937a227e..2b6fd1b7 100644 --- a/docs/examples/databases/update-transaction.md +++ b/docs/examples/databases/update-transaction.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Transaction -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) +async def main(): + 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: Transaction = await databases.update_transaction( + transaction_id = '', + commit = False, # optional + rollback = False # optional + ) + + print(result.model_dump()) -result: Transaction = databases.update_transaction( - transaction_id = '', - commit = False, # optional - rollback = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index 4f772b97..6dd28677 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeUrl -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) +async def main(): + 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: AttributeUrl = await databases.update_url_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'https://example.com', + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) -result: AttributeUrl = databases.update_url_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'https://example.com', - new_key = '', # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update-varchar-attribute.md b/docs/examples/databases/update-varchar-attribute.md index 5fb7a73f..072789fe 100644 --- a/docs/examples/databases/update-varchar-attribute.md +++ b/docs/examples/databases/update-varchar-attribute.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import AttributeVarchar -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: AttributeVarchar = databases.update_varchar_attribute( - database_id = '', - collection_id = '', - key = '', - required = False, - default = 'Hello World', - size = 1, # optional - new_key = '', # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: AttributeVarchar = await databases.update_varchar_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = 'Hello World', + size = 1, # optional + new_key = '', # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index ae7b33eb..1f0db743 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Database -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) +async def main(): + 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: Database = await databases.update( + database_id = '', + name = '', # optional + enabled = False, # optional + description = '' # optional + ) + + print(result.model_dump()) -result: Database = databases.update( - database_id = '', - name = '', # optional - enabled = False, # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index b18eb794..eb226c98 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role -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) +async def main(): + 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: Document = databases.upsert_document( - database_id = '', - collection_id = '', - document_id = '', - data = { + result: Document = await databases.upsert_document( + database_id = '', + collection_id = '', + document_id = '', + data = { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 30, "isAdmin": False }, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index ae28f031..1570585c 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -1,19 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import DocumentList -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) +async def main(): + 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: DocumentList = databases.upsert_documents( - database_id = '', - collection_id = '', - documents = [ + result: DocumentList = await databases.upsert_documents( + database_id = '', + collection_id = '', + documents = [ { "$id": "example1", "username": "walter.obrien", @@ -23,8 +27,11 @@ result: DocumentList = databases.upsert_documents( "isAdmin": false } ], - transaction_id = '' # optional -) + transaction_id = '' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/create-collection.md b/docs/examples/documentsdb/create-collection.md index da77bced..8d2200bf 100644 --- a/docs/examples/documentsdb/create-collection.md +++ b/docs/examples/documentsdb/create-collection.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Collection from appwrite.permission import Permission from appwrite.role import Role -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 - -documents_db = DocumentsDB(client) - -result: Collection = documents_db.create_collection( - database_id = '', - collection_id = '', - name = '', - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False, # optional - attributes = [], # optional - indexes = [], # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Collection = await documents_db.create_collection( + database_id = '', + collection_id = '', + name = '', + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False, # optional + attributes = [], # optional + indexes = [], # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md index a6a3055f..928ef96a 100644 --- a/docs/examples/documentsdb/create-document.md +++ b/docs/examples/documentsdb/create-document.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) -result: Document = documents_db.create_document( - database_id = '', - collection_id = '', - document_id = '', - data = { + result: Document = await documents_db.create_document( + database_id = '', + collection_id = '', + document_id = '', + data = { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 30, "isAdmin": False }, - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 7f470a36..6a51f501 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -1,19 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DocumentList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) -result: DocumentList = documents_db.create_documents( - database_id = '', - collection_id = '', - documents = [ + result: DocumentList = await documents_db.create_documents( + database_id = '', + collection_id = '', + documents = [ { "$id": "example1", "username": "walter.obrien", @@ -23,8 +27,11 @@ result: DocumentList = documents_db.create_documents( "isAdmin": false } ], - transaction_id = '' # optional -) + transaction_id = '' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/create-failover.md b/docs/examples/documentsdb/create-failover.md index fc7b0570..2b1d6957 100644 --- a/docs/examples/documentsdb/create-failover.md +++ b/docs/examples/documentsdb/create-failover.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DedicatedDatabase -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DedicatedDatabase = await documents_db.create_failover( + database_id = '', + target_replica_id = '' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = documents_db.create_failover( - database_id = '', - target_replica_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index 4e9361cd..6b98e203 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Index from appwrite.enums.documents_db_index_type import DocumentsDBIndexType from appwrite.enums.order_by import OrderBy -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 - -documents_db = DocumentsDB(client) - -result: Index = documents_db.create_index( - database_id = '', - collection_id = '', - key = '', - type = DocumentsDBIndexType.KEY, - attributes = ["username"], - orders = [OrderBy.ASC], # optional - lengths = [], # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Index = await documents_db.create_index( + database_id = '', + collection_id = '', + key = '', + type = DocumentsDBIndexType.KEY, + attributes = ["username"], + orders = [OrderBy.ASC], # optional + lengths = [], # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md index 23128e81..a584332c 100644 --- a/docs/examples/documentsdb/create-operations.md +++ b/docs/examples/documentsdb/create-operations.md @@ -1,18 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Transaction -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) -result: Transaction = documents_db.create_operations( - transaction_id = '', - operations = [ + result: Transaction = await documents_db.create_operations( + transaction_id = '', + operations = [ { "action": "create", "databaseId": "", @@ -23,7 +27,10 @@ result: Transaction = documents_db.create_operations( } } ] # optional -) + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/create-query.md b/docs/examples/documentsdb/create-query.md index 80f1298c..6758f9e7 100644 --- a/docs/examples/documentsdb/create-query.md +++ b/docs/examples/documentsdb/create-query.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DocumentList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DocumentList = await documents_db.create_query( + database_id = '', + collection_id = '', + queries = [], # optional + transaction_id = '', # optional + total = False, # optional + ttl = 0 # optional + ) + + print(result.model_dump()) -result: DocumentList = documents_db.create_query( - database_id = '', - collection_id = '', - queries = [], # optional - transaction_id = '', # optional - total = False, # optional - ttl = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md index d34b358e..17e9e671 100644 --- a/docs/examples/documentsdb/create-transaction.md +++ b/docs/examples/documentsdb/create-transaction.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Transaction -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Transaction = await documents_db.create_transaction( + ttl = 60 # optional + ) + + print(result.model_dump()) -result: Transaction = documents_db.create_transaction( - ttl = 60 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/create.md b/docs/examples/documentsdb/create.md index 9d424527..c5ec0bab 100644 --- a/docs/examples/documentsdb/create.md +++ b/docs/examples/documentsdb/create.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Database -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Database = await documents_db.create( + database_id = '', + name = '', + enabled = False, # optional + description = '', # optional + specification = 'serverless', # optional + replicas = 0, # optional + sync_mode = 'async' # optional + ) + + print(result.model_dump()) -result: Database = documents_db.create( - database_id = '', - name = '', - enabled = False, # optional - description = '', # optional - specification = 'serverless', # optional - replicas = 0, # optional - sync_mode = 'async' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md index d6c75329..cbeeefe4 100644 --- a/docs/examples/documentsdb/decrement-document-attribute.md +++ b/docs/examples/documentsdb/decrement-document-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Document -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Document = await documents_db.decrement_document_attribute( + database_id = '', + collection_id = '', + document_id = '', + attribute = '', + value = 1, # optional + min = 0, # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: Document = documents_db.decrement_document_attribute( - database_id = '', - collection_id = '', - document_id = '', - attribute = '', - value = 1, # optional - min = 0, # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/delete-collection.md b/docs/examples/documentsdb/delete-collection.md index 1652ab2b..2eab15b2 100644 --- a/docs/examples/documentsdb/delete-collection.md +++ b/docs/examples/documentsdb/delete-collection.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result = await documents_db.delete_collection( + database_id = '', + collection_id = '' + ) + -result = documents_db.delete_collection( - database_id = '', - collection_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md index e588088e..b325b581 100644 --- a/docs/examples/documentsdb/delete-document.md +++ b/docs/examples/documentsdb/delete-document.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result = await documents_db.delete_document( + database_id = '', + collection_id = '', + document_id = '', + transaction_id = '' # optional + ) + -result = documents_db.delete_document( - database_id = '', - collection_id = '', - document_id = '', - transaction_id = '' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index 4b127c79..5a399a66 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DocumentList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DocumentList = await documents_db.delete_documents( + database_id = '', + collection_id = '', + queries = ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: DocumentList = documents_db.delete_documents( - database_id = '', - collection_id = '', - queries = ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/delete-index.md b/docs/examples/documentsdb/delete-index.md index befd9fee..92e6fa6b 100644 --- a/docs/examples/documentsdb/delete-index.md +++ b/docs/examples/documentsdb/delete-index.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result = await documents_db.delete_index( + database_id = '', + collection_id = '', + key = '' + ) + -result = documents_db.delete_index( - database_id = '', - collection_id = '', - key = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md index 009bf807..6eaac0ea 100644 --- a/docs/examples/documentsdb/delete-transaction.md +++ b/docs/examples/documentsdb/delete-transaction.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result = await documents_db.delete_transaction( + transaction_id = '' + ) + -result = documents_db.delete_transaction( - transaction_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/delete.md b/docs/examples/documentsdb/delete.md index 64845091..902967e9 100644 --- a/docs/examples/documentsdb/delete.md +++ b/docs/examples/documentsdb/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result = await documents_db.delete( + database_id = '' + ) + -result = documents_db.delete( - database_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/get-collection.md b/docs/examples/documentsdb/get-collection.md index 5ec739b8..cfb76dc0 100644 --- a/docs/examples/documentsdb/get-collection.md +++ b/docs/examples/documentsdb/get-collection.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Collection -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Collection = await documents_db.get_collection( + database_id = '', + collection_id = '' + ) + + print(result.model_dump()) -result: Collection = documents_db.get_collection( - database_id = '', - collection_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md index 3f0006e7..c02f06bf 100644 --- a/docs/examples/documentsdb/get-document.md +++ b/docs/examples/documentsdb/get-document.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Document -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Document = await documents_db.get_document( + database_id = '', + collection_id = '', + document_id = '', + queries = [], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: Document = documents_db.get_document( - database_id = '', - collection_id = '', - document_id = '', - queries = [], # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/get-index.md b/docs/examples/documentsdb/get-index.md index 598873f0..af27a994 100644 --- a/docs/examples/documentsdb/get-index.md +++ b/docs/examples/documentsdb/get-index.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Index -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Index = await documents_db.get_index( + database_id = '', + collection_id = '', + key = '' + ) + + print(result.model_dump()) -result: Index = documents_db.get_index( - database_id = '', - collection_id = '', - key = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/get-replicas.md b/docs/examples/documentsdb/get-replicas.md index 1eabb127..e858824c 100644 --- a/docs/examples/documentsdb/get-replicas.md +++ b/docs/examples/documentsdb/get-replicas.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DedicatedDatabaseReplicas -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DedicatedDatabaseReplicas = await documents_db.get_replicas( + database_id = '' + ) + + print(result.model_dump()) -result: DedicatedDatabaseReplicas = documents_db.get_replicas( - database_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/get-status.md b/docs/examples/documentsdb/get-status.md index 9e26368a..cd0bcad1 100644 --- a/docs/examples/documentsdb/get-status.md +++ b/docs/examples/documentsdb/get-status.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DatabaseStatus -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DatabaseStatus = await documents_db.get_status( + database_id = '' + ) + + print(result.model_dump()) -result: DatabaseStatus = documents_db.get_status( - database_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md index 27d88ee7..0f9d9af2 100644 --- a/docs/examples/documentsdb/get-transaction.md +++ b/docs/examples/documentsdb/get-transaction.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Transaction -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Transaction = await documents_db.get_transaction( + transaction_id = '' + ) + + print(result.model_dump()) -result: Transaction = documents_db.get_transaction( - transaction_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/get.md b/docs/examples/documentsdb/get.md index fc2ffb9b..8daeb7b0 100644 --- a/docs/examples/documentsdb/get.md +++ b/docs/examples/documentsdb/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Database -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Database = await documents_db.get( + database_id = '' + ) + + print(result.model_dump()) -result: Database = documents_db.get( - database_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md index 08e61883..496e01f2 100644 --- a/docs/examples/documentsdb/increment-document-attribute.md +++ b/docs/examples/documentsdb/increment-document-attribute.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Document -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Document = await documents_db.increment_document_attribute( + database_id = '', + collection_id = '', + document_id = '', + attribute = '', + value = 1, # optional + max = 100, # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: Document = documents_db.increment_document_attribute( - database_id = '', - collection_id = '', - document_id = '', - attribute = '', - value = 1, # optional - max = 100, # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/list-collections.md b/docs/examples/documentsdb/list-collections.md index 0d72a376..00839ccb 100644 --- a/docs/examples/documentsdb/list-collections.md +++ b/docs/examples/documentsdb/list-collections.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import CollectionList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: CollectionList = await documents_db.list_collections( + database_id = '', + queries = [], # optional + search = '', # optional + total = False # optional + ) + + print(result.model_dump()) -result: CollectionList = documents_db.list_collections( - database_id = '', - queries = [], # optional - search = '', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md index c1b2a360..2262efb5 100644 --- a/docs/examples/documentsdb/list-documents.md +++ b/docs/examples/documentsdb/list-documents.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DocumentList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DocumentList = await documents_db.list_documents( + database_id = '', + collection_id = '', + queries = [], # optional + transaction_id = '', # optional + total = False, # optional + ttl = 0 # optional + ) + + print(result.model_dump()) -result: DocumentList = documents_db.list_documents( - database_id = '', - collection_id = '', - queries = [], # optional - transaction_id = '', # optional - total = False, # optional - ttl = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/list-indexes.md b/docs/examples/documentsdb/list-indexes.md index 26655d72..3b4122c2 100644 --- a/docs/examples/documentsdb/list-indexes.md +++ b/docs/examples/documentsdb/list-indexes.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import IndexList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: IndexList = await documents_db.list_indexes( + database_id = '', + collection_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: IndexList = documents_db.list_indexes( - database_id = '', - collection_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/list-operations.md b/docs/examples/documentsdb/list-operations.md index 90c01baa..4836f0ab 100644 --- a/docs/examples/documentsdb/list-operations.md +++ b/docs/examples/documentsdb/list-operations.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DedicatedDatabaseOperationList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DedicatedDatabaseOperationList = await documents_db.list_operations( + database_id = '', + status = 'queued', # optional + limit = 1, # optional + offset = 0 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseOperationList = documents_db.list_operations( - database_id = '', - status = 'queued', # optional - limit = 1, # optional - offset = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/list-specifications.md b/docs/examples/documentsdb/list-specifications.md index 6917c483..f9b2ade3 100644 --- a/docs/examples/documentsdb/list-specifications.md +++ b/docs/examples/documentsdb/list-specifications.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DedicatedDatabaseSpecificationList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DedicatedDatabaseSpecificationList = await documents_db.list_specifications() + + print(result.model_dump()) -result: DedicatedDatabaseSpecificationList = documents_db.list_specifications() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md index 7128d9b5..6b95f334 100644 --- a/docs/examples/documentsdb/list-transactions.md +++ b/docs/examples/documentsdb/list-transactions.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import TransactionList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: TransactionList = await documents_db.list_transactions( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: TransactionList = documents_db.list_transactions( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/list.md b/docs/examples/documentsdb/list.md index 59d3557e..b7af9bfa 100644 --- a/docs/examples/documentsdb/list.md +++ b/docs/examples/documentsdb/list.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DatabaseList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DatabaseList = await documents_db.list( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: DatabaseList = documents_db.list( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/update-collection.md b/docs/examples/documentsdb/update-collection.md index 0c3d010f..61eb5d04 100644 --- a/docs/examples/documentsdb/update-collection.md +++ b/docs/examples/documentsdb/update-collection.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Collection from appwrite.permission import Permission from appwrite.role import Role -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 - -documents_db = DocumentsDB(client) - -result: Collection = documents_db.update_collection( - database_id = '', - collection_id = '', - name = '', - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False, # optional - purge = False, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Collection = await documents_db.update_collection( + database_id = '', + collection_id = '', + name = '', + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False, # optional + purge = False, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md index cf0bfcc9..e1d9a77b 100644 --- a/docs/examples/documentsdb/update-document.md +++ b/docs/examples/documentsdb/update-document.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Document = await documents_db.update_document( + database_id = '', + collection_id = '', + document_id = '', + data = {}, # optional + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: Document = documents_db.update_document( - database_id = '', - collection_id = '', - document_id = '', - data = {}, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/update-documents.md b/docs/examples/documentsdb/update-documents.md index 2c183e55..f70912f3 100644 --- a/docs/examples/documentsdb/update-documents.md +++ b/docs/examples/documentsdb/update-documents.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DocumentList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: DocumentList = await documents_db.update_documents( + database_id = '', + collection_id = '', + data = {}, # optional + queries = [], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: DocumentList = documents_db.update_documents( - database_id = '', - collection_id = '', - data = {}, # optional - queries = [], # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md index fff946cb..38c4c865 100644 --- a/docs/examples/documentsdb/update-transaction.md +++ b/docs/examples/documentsdb/update-transaction.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Transaction -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Transaction = await documents_db.update_transaction( + transaction_id = '', + commit = False, # optional + rollback = False # optional + ) + + print(result.model_dump()) -result: Transaction = documents_db.update_transaction( - transaction_id = '', - commit = False, # optional - rollback = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md index 3cd8bea3..c817f651 100644 --- a/docs/examples/documentsdb/update.md +++ b/docs/examples/documentsdb/update.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Database -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Database = await documents_db.update( + database_id = '', + name = '', + enabled = False, # optional + description = '', # optional + specification = 'serverless', # optional + replicas = 0, # optional + sync_mode = 'async' # optional + ) + + print(result.model_dump()) -result: Database = documents_db.update( - database_id = '', - name = '', - enabled = False, # optional - description = '', # optional - specification = 'serverless', # optional - replicas = 0, # optional - sync_mode = 'async' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md index 07086f4a..71943816 100644 --- a/docs/examples/documentsdb/upsert-document.md +++ b/docs/examples/documentsdb/upsert-document.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) + + result: Document = await documents_db.upsert_document( + database_id = '', + collection_id = '', + document_id = '', + data = {}, # optional + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional + ) + + print(result.model_dump()) -result: Document = documents_db.upsert_document( - database_id = '', - collection_id = '', - document_id = '', - data = {}, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index f1613df1..d881e094 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -1,19 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.documents_db import DocumentsDB from appwrite.models import DocumentList -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 -documents_db = DocumentsDB(client) +async def main(): + 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 + + documents_db = DocumentsDB(client) -result: DocumentList = documents_db.upsert_documents( - database_id = '', - collection_id = '', - documents = [ + result: DocumentList = await documents_db.upsert_documents( + database_id = '', + collection_id = '', + documents = [ { "$id": "example1", "username": "walter.obrien", @@ -23,8 +27,11 @@ result: DocumentList = documents_db.upsert_documents( "isAdmin": false } ], - transaction_id = '' # optional -) + transaction_id = '' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-preset-google-workspace.md b/docs/examples/domains/create-preset-google-workspace.md index 73c5594e..11d8d952 100644 --- a/docs/examples/domains/create-preset-google-workspace.md +++ b/docs/examples/domains/create-preset-google-workspace.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.create_preset_google_workspace( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.create_preset_google_workspace( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-preset-i-cloud.md b/docs/examples/domains/create-preset-i-cloud.md index d9a957aa..192917c5 100644 --- a/docs/examples/domains/create-preset-i-cloud.md +++ b/docs/examples/domains/create-preset-i-cloud.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.create_preset_i_cloud( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.create_preset_i_cloud( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-preset-mailgun.md b/docs/examples/domains/create-preset-mailgun.md index 89012267..e76c7ca0 100644 --- a/docs/examples/domains/create-preset-mailgun.md +++ b/docs/examples/domains/create-preset-mailgun.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.create_preset_mailgun( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.create_preset_mailgun( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-preset-outlook.md b/docs/examples/domains/create-preset-outlook.md index b8e0f790..e4075a2c 100644 --- a/docs/examples/domains/create-preset-outlook.md +++ b/docs/examples/domains/create-preset-outlook.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.create_preset_outlook( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.create_preset_outlook( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-preset-proton-mail.md b/docs/examples/domains/create-preset-proton-mail.md index 1caf9d5d..16f46262 100644 --- a/docs/examples/domains/create-preset-proton-mail.md +++ b/docs/examples/domains/create-preset-proton-mail.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.create_preset_proton_mail( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.create_preset_proton_mail( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-preset-zoho.md b/docs/examples/domains/create-preset-zoho.md index bc5a7c2a..40eb31ad 100644 --- a/docs/examples/domains/create-preset-zoho.md +++ b/docs/examples/domains/create-preset-zoho.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.create_preset_zoho( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.create_preset_zoho( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-a.md b/docs/examples/domains/create-record-a.md index 17be375e..cc83b24b 100644 --- a/docs/examples/domains/create-record-a.md +++ b/docs/examples/domains/create-record-a.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_a( + domain_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.create_record_a( - domain_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-aaaa.md b/docs/examples/domains/create-record-aaaa.md index c02fff65..f4a2cc5f 100644 --- a/docs/examples/domains/create-record-aaaa.md +++ b/docs/examples/domains/create-record-aaaa.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_aaaa( + domain_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.create_record_aaaa( - domain_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-alias.md b/docs/examples/domains/create-record-alias.md index a5c9f167..a40a66b7 100644 --- a/docs/examples/domains/create-record-alias.md +++ b/docs/examples/domains/create-record-alias.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_alias( + domain_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.create_record_alias( - domain_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-caa.md b/docs/examples/domains/create-record-caa.md index 5e0ee5d8..e336ebc8 100644 --- a/docs/examples/domains/create-record-caa.md +++ b/docs/examples/domains/create-record-caa.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_caa( + domain_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.create_record_caa( - domain_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-cname.md b/docs/examples/domains/create-record-cname.md index 8afe96a2..51bfd625 100644 --- a/docs/examples/domains/create-record-cname.md +++ b/docs/examples/domains/create-record-cname.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_cname( + domain_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.create_record_cname( - domain_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-https.md b/docs/examples/domains/create-record-https.md index 2448b64c..9505bb69 100644 --- a/docs/examples/domains/create-record-https.md +++ b/docs/examples/domains/create-record-https.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_https( + domain_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.create_record_https( - domain_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-mx.md b/docs/examples/domains/create-record-mx.md index ef492fe1..29e1b7e3 100644 --- a/docs/examples/domains/create-record-mx.md +++ b/docs/examples/domains/create-record-mx.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_mx( + domain_id = '', + name = '', + value = '', + ttl = 1, + priority = 0, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.create_record_mx( - domain_id = '', - name = '', - value = '', - ttl = 1, - priority = 0, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-ns.md b/docs/examples/domains/create-record-ns.md index bc2e4187..79037c38 100644 --- a/docs/examples/domains/create-record-ns.md +++ b/docs/examples/domains/create-record-ns.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_ns( + domain_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.create_record_ns( - domain_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-srv.md b/docs/examples/domains/create-record-srv.md index 04071b34..1ba61695 100644 --- a/docs/examples/domains/create-record-srv.md +++ b/docs/examples/domains/create-record-srv.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 - -domains = Domains(client) - -result: DnsRecord = domains.create_record_srv( - domain_id = '', - name = '', - value = '', - ttl = 1, - priority = 0, - weight = 0, - port = 0, - comment = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_srv( + domain_id = '', + name = '', + value = '', + ttl = 1, + priority = 0, + weight = 0, + port = 0, + comment = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create-record-txt.md b/docs/examples/domains/create-record-txt.md index 4a66afd0..2b34d94c 100644 --- a/docs/examples/domains/create-record-txt.md +++ b/docs/examples/domains/create-record-txt.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.create_record_txt( + domain_id = '', + name = '', + ttl = 1, + value = '', # optional + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.create_record_txt( - domain_id = '', - name = '', - ttl = 1, - value = '', # optional - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/create.md b/docs/examples/domains/create.md index 01c02414..370d9478 100644 --- a/docs/examples/domains/create.md +++ b/docs/examples/domains/create.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import Domain -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: Domain = await domains.create( + team_id = '', + domain = 'example.com' + ) + + print(result.model_dump()) -result: Domain = domains.create( - team_id = '', - domain = 'example.com' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/delete-record.md b/docs/examples/domains/delete-record.md index 40b12e83..9326955f 100644 --- a/docs/examples/domains/delete-record.md +++ b/docs/examples/domains/delete-record.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result = await domains.delete_record( + domain_id = '', + record_id = '' + ) + -result = domains.delete_record( - domain_id = '', - record_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/delete.md b/docs/examples/domains/delete.md index f9cb3c43..092ce314 100644 --- a/docs/examples/domains/delete.md +++ b/docs/examples/domains/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result = await domains.delete( + domain_id = '' + ) + -result = domains.delete( - domain_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-preset-google-workspace.md b/docs/examples/domains/get-preset-google-workspace.md index e228af7c..537ed4f1 100644 --- a/docs/examples/domains/get-preset-google-workspace.md +++ b/docs/examples/domains/get-preset-google-workspace.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.get_preset_google_workspace( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.get_preset_google_workspace( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-preset-i-cloud.md b/docs/examples/domains/get-preset-i-cloud.md index 5b0169c2..6f6a4dc2 100644 --- a/docs/examples/domains/get-preset-i-cloud.md +++ b/docs/examples/domains/get-preset-i-cloud.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.get_preset_i_cloud( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.get_preset_i_cloud( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-preset-mailgun.md b/docs/examples/domains/get-preset-mailgun.md index 494f42a5..793978e3 100644 --- a/docs/examples/domains/get-preset-mailgun.md +++ b/docs/examples/domains/get-preset-mailgun.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.get_preset_mailgun( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.get_preset_mailgun( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-preset-outlook.md b/docs/examples/domains/get-preset-outlook.md index 5daf056d..7ce52f59 100644 --- a/docs/examples/domains/get-preset-outlook.md +++ b/docs/examples/domains/get-preset-outlook.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.get_preset_outlook( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.get_preset_outlook( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-preset-proton-mail.md b/docs/examples/domains/get-preset-proton-mail.md index 5dff2d5b..a7c06626 100644 --- a/docs/examples/domains/get-preset-proton-mail.md +++ b/docs/examples/domains/get-preset-proton-mail.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.get_preset_proton_mail( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.get_preset_proton_mail( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-preset-zoho.md b/docs/examples/domains/get-preset-zoho.md index b9f6e1ab..ef5e6b9d 100644 --- a/docs/examples/domains/get-preset-zoho.md +++ b/docs/examples/domains/get-preset-zoho.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.get_preset_zoho( + domain_id = '' + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.get_preset_zoho( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md index 648998d5..35e7a5ef 100644 --- a/docs/examples/domains/get-price.md +++ b/docs/examples/domains/get-price.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DomainPrice from appwrite.enums.domain_registration_type import DomainRegistrationType -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DomainPrice = await domains.get_price( + domain = 'example.com', + period_years = None, # optional + registration_type = DomainRegistrationType.NEW # optional + ) + + print(result.model_dump()) -result: DomainPrice = domains.get_price( - domain = 'example.com', - period_years = None, # optional - registration_type = DomainRegistrationType.NEW # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-record.md b/docs/examples/domains/get-record.md index e923cd6c..cf05bdbd 100644 --- a/docs/examples/domains/get-record.md +++ b/docs/examples/domains/get-record.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.get_record( + domain_id = '', + record_id = '' + ) + + print(result.model_dump()) -result: DnsRecord = domains.get_record( - domain_id = '', - record_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-transfer-status.md b/docs/examples/domains/get-transfer-status.md index ca10cf7a..879e3543 100644 --- a/docs/examples/domains/get-transfer-status.md +++ b/docs/examples/domains/get-transfer-status.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DomainTransferStatus -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DomainTransferStatus = await domains.get_transfer_status( + domain_id = '' + ) + + print(result.model_dump()) -result: DomainTransferStatus = domains.get_transfer_status( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get-zone.md b/docs/examples/domains/get-zone.md index ad17f2dc..2687862d 100644 --- a/docs/examples/domains/get-zone.md +++ b/docs/examples/domains/get-zone.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result = await domains.get_zone( + domain_id = '' + ) + -result = domains.get_zone( - domain_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/get.md b/docs/examples/domains/get.md index c1d772d4..deb1c375 100644 --- a/docs/examples/domains/get.md +++ b/docs/examples/domains/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import Domain -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: Domain = await domains.get( + domain_id = '' + ) + + print(result.model_dump()) -result: Domain = domains.get( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md index ea6907e7..bf03b18c 100644 --- a/docs/examples/domains/list-prices.md +++ b/docs/examples/domains/list-prices.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DomainPricesList from appwrite.enums.domain_registration_type import DomainRegistrationType -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DomainPricesList = await domains.list_prices( + domains = [], + period_years = None, # optional + registration_type = DomainRegistrationType.NEW # optional + ) + + print(result.model_dump()) -result: DomainPricesList = domains.list_prices( - domains = [], - period_years = None, # optional - registration_type = DomainRegistrationType.NEW # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/list-records.md b/docs/examples/domains/list-records.md index 94275a49..c1f89612 100644 --- a/docs/examples/domains/list-records.md +++ b/docs/examples/domains/list-records.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecordsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecordsList = await domains.list_records( + domain_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: DnsRecordsList = domains.list_records( - domain_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/list.md b/docs/examples/domains/list.md index 602fa974..b53bf534 100644 --- a/docs/examples/domains/list.md +++ b/docs/examples/domains/list.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DomainsList -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DomainsList = await domains.list( + queries = [], # optional + search = '', # optional + total = False # optional + ) + + print(result.model_dump()) -result: DomainsList = domains.list( - queries = [], # optional - search = '', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-nameservers.md b/docs/examples/domains/update-nameservers.md index 0e5ed4be..a2c19c7d 100644 --- a/docs/examples/domains/update-nameservers.md +++ b/docs/examples/domains/update-nameservers.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import Domain -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: Domain = await domains.update_nameservers( + domain_id = '', + nameservers = [] # optional + ) + + print(result.model_dump()) -result: Domain = domains.update_nameservers( - domain_id = '', - nameservers = [] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-a.md b/docs/examples/domains/update-record-a.md index 516e273b..cba614cb 100644 --- a/docs/examples/domains/update-record-a.md +++ b/docs/examples/domains/update-record-a.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_a( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.update_record_a( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-aaaa.md b/docs/examples/domains/update-record-aaaa.md index 1d36e41f..825a4b8b 100644 --- a/docs/examples/domains/update-record-aaaa.md +++ b/docs/examples/domains/update-record-aaaa.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_aaaa( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.update_record_aaaa( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-alias.md b/docs/examples/domains/update-record-alias.md index 9dc96784..8a664a1d 100644 --- a/docs/examples/domains/update-record-alias.md +++ b/docs/examples/domains/update-record-alias.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_alias( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.update_record_alias( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-caa.md b/docs/examples/domains/update-record-caa.md index e1c74e35..d9c40698 100644 --- a/docs/examples/domains/update-record-caa.md +++ b/docs/examples/domains/update-record-caa.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_caa( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.update_record_caa( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-cname.md b/docs/examples/domains/update-record-cname.md index 35e12cd6..e80ba4f9 100644 --- a/docs/examples/domains/update-record-cname.md +++ b/docs/examples/domains/update-record-cname.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_cname( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.update_record_cname( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-https.md b/docs/examples/domains/update-record-https.md index c31e963d..6e2817db 100644 --- a/docs/examples/domains/update-record-https.md +++ b/docs/examples/domains/update-record-https.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_https( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.update_record_https( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-mx.md b/docs/examples/domains/update-record-mx.md index bd96398a..a88e4021 100644 --- a/docs/examples/domains/update-record-mx.md +++ b/docs/examples/domains/update-record-mx.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_mx( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + priority = 0, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.update_record_mx( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - priority = 0, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-ns.md b/docs/examples/domains/update-record-ns.md index 3ca42be8..28ab9d8e 100644 --- a/docs/examples/domains/update-record-ns.md +++ b/docs/examples/domains/update-record-ns.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_ns( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.update_record_ns( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-srv.md b/docs/examples/domains/update-record-srv.md index c47f9f2c..72f8c72d 100644 --- a/docs/examples/domains/update-record-srv.md +++ b/docs/examples/domains/update-record-srv.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 - -domains = Domains(client) - -result: DnsRecord = domains.update_record_srv( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - priority = 0, - weight = 0, - port = 0, - comment = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_srv( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + priority = 0, + weight = 0, + port = 0, + comment = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-record-txt.md b/docs/examples/domains/update-record-txt.md index b6461701..1c75b07d 100644 --- a/docs/examples/domains/update-record-txt.md +++ b/docs/examples/domains/update-record-txt.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import DnsRecord -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: DnsRecord = await domains.update_record_txt( + domain_id = '', + record_id = '', + name = '', + value = '', + ttl = 1, + comment = '' # optional + ) + + print(result.model_dump()) -result: DnsRecord = domains.update_record_txt( - domain_id = '', - record_id = '', - name = '', - value = '', - ttl = 1, - comment = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-team.md b/docs/examples/domains/update-team.md index 3963e778..67f78c2f 100644 --- a/docs/examples/domains/update-team.md +++ b/docs/examples/domains/update-team.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import Domain -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: Domain = await domains.update_team( + domain_id = '', + team_id = '' + ) + + print(result.model_dump()) -result: Domain = domains.update_team( - domain_id = '', - team_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/update-zone.md b/docs/examples/domains/update-zone.md index 89e9011a..b4d62df5 100644 --- a/docs/examples/domains/update-zone.md +++ b/docs/examples/domains/update-zone.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import Domain -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: Domain = await domains.update_zone( + domain_id = '', + content = '' + ) + + print(result.model_dump()) -result: Domain = domains.update_zone( - domain_id = '', - content = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/domains/verify-nameservers.md b/docs/examples/domains/verify-nameservers.md index 13caac7f..249757b6 100644 --- a/docs/examples/domains/verify-nameservers.md +++ b/docs/examples/domains/verify-nameservers.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.domains import Domains from appwrite.models import Domain -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 -domains = Domains(client) +async def main(): + 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 + + domains = Domains(client) + + result: Domain = await domains.verify_nameservers( + domain_id = '' + ) + + print(result.model_dump()) -result: Domain = domains.verify_nameservers( - domain_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 36da57c3..66d169d1 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.embeddings import Embeddings from appwrite.models import EmbeddingList from appwrite.enums.embedding_model import EmbeddingModel -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 -embeddings = Embeddings(client) +async def main(): + 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 + + embeddings = Embeddings(client) + + result: EmbeddingList = await embeddings.create_text_embeddings( + texts = ["Appwrite helps developers build applications.", "Find documents with semantic search."], + model = EmbeddingModel.NOMIC_EMBED_TEXT # optional + ) + + print(result.model_dump()) -result: EmbeddingList = embeddings.create_text_embeddings( - texts = ["Appwrite helps developers build applications.", "Find documents with semantic search."], - model = EmbeddingModel.NOMIC_EMBED_TEXT # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index ed197c32..2ddfa98f 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.input_file import InputFile from appwrite.models import Deployment -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) +async def main(): + 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: Deployment = await functions.create_deployment( + function_id = '', + code = InputFile.from_path('file.png'), + activate = False, + entrypoint = '', # optional + commands = '' # optional + ) + + print(result.model_dump()) -result: Deployment = functions.create_deployment( - function_id = '', - code = InputFile.from_path('file.png'), - activate = False, - entrypoint = '', # optional - commands = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/create-duplicate-deployment.md b/docs/examples/functions/create-duplicate-deployment.md index 68400cbe..09cb3431 100644 --- a/docs/examples/functions/create-duplicate-deployment.md +++ b/docs/examples/functions/create-duplicate-deployment.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Deployment -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) +async def main(): + 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: Deployment = await functions.create_duplicate_deployment( + function_id = '', + deployment_id = '', + build_id = '' # optional + ) + + print(result.model_dump()) -result: Deployment = functions.create_duplicate_deployment( - function_id = '', - deployment_id = '', - build_id = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index a57c0415..f63a6546 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Execution from appwrite.enums.execution_method import ExecutionMethod -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 -functions = Functions(client) +async def main(): + 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 + + functions = Functions(client) + + result: Execution = await functions.create_execution( + function_id = '', + body = '', # optional + xasync = False, # optional + path = '', # optional + method = ExecutionMethod.GET, # optional + headers = {}, # optional + scheduled_at = '' # optional + ) + + print(result.model_dump()) -result: Execution = functions.create_execution( - function_id = '', - body = '', # optional - async = False, # optional - path = '', # optional - method = ExecutionMethod.GET, # optional - headers = {}, # optional - scheduled_at = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md index cd7511d5..9e4d53d9 100644 --- a/docs/examples/functions/create-template-deployment.md +++ b/docs/examples/functions/create-template-deployment.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Deployment from appwrite.enums.template_reference_type import TemplateReferenceType -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) +async def main(): + 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: Deployment = await functions.create_template_deployment( + function_id = '', + repository = '', + owner = '', + root_directory = '', + type = TemplateReferenceType.COMMIT, + reference = '', + activate = False # optional + ) + + print(result.model_dump()) -result: Deployment = functions.create_template_deployment( - function_id = '', - repository = '', - owner = '', - root_directory = '', - type = TemplateReferenceType.COMMIT, - reference = '', - activate = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index 6f596772..4a8cf01e 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Variable -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) +async def main(): + 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: Variable = await functions.create_variable( + function_id = '', + variable_id = '', + key = '', + value = '', + secret = False, # optional + description = '' # optional + ) + + print(result.model_dump()) -result: Variable = functions.create_variable( - function_id = '', - variable_id = '', - key = '', - value = '', - secret = False, # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/create-vcs-deployment.md b/docs/examples/functions/create-vcs-deployment.md index 37a2d604..abf594a7 100644 --- a/docs/examples/functions/create-vcs-deployment.md +++ b/docs/examples/functions/create-vcs-deployment.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Deployment from appwrite.enums.vcs_reference_type import VCSReferenceType -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) +async def main(): + 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: Deployment = await functions.create_vcs_deployment( + function_id = '', + type = VCSReferenceType.BRANCH, + reference = '', + activate = False # optional + ) + + print(result.model_dump()) -result: Deployment = functions.create_vcs_deployment( - function_id = '', - type = VCSReferenceType.BRANCH, - reference = '', - activate = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 4cc28c82..a1802d8f 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -1,43 +1,50 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Function from appwrite.enums.runtime import Runtime from appwrite.enums.project_key_scopes import ProjectKeyScopes -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: Function = functions.create( - function_id = '', - name = '', - runtime = Runtime.NODE_14_5, - execute = ["any"], # optional - events = [], # optional - schedule = '0 0 * * *', # optional - timeout = 1, # optional - enabled = False, # optional - logging = False, # optional - entrypoint = '', # optional - commands = '', # optional - scopes = [ProjectKeyScopes.PROJECT_READ], # optional - installation_id = '', # optional - provider_repository_id = '', # optional - provider_branch = '', # optional - provider_silent_mode = False, # optional - provider_root_directory = '', # optional - provider_branches = [], # optional - provider_paths = [], # optional - build_specification = 's-1vcpu-512mb', # optional - runtime_specification = 's-1vcpu-512mb', # optional - deployment_retention = 0, # optional - interval = 0, # optional - description = '' # optional -) - -print(result.model_dump()) + +async def main(): + 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: Function = await functions.create( + function_id = '', + name = '', + runtime = Runtime.NODE_14_5, + execute = ["any"], # optional + events = [], # optional + schedule = '0 0 * * *', # optional + timeout = 1, # optional + enabled = False, # optional + logging = False, # optional + entrypoint = '', # optional + commands = '', # optional + scopes = [ProjectKeyScopes.PROJECT_READ], # optional + installation_id = '', # optional + provider_repository_id = '', # optional + provider_branch = '', # optional + provider_silent_mode = False, # optional + provider_root_directory = '', # optional + provider_branches = [], # optional + provider_paths = [], # optional + build_specification = 's-1vcpu-512mb', # optional + runtime_specification = 's-1vcpu-512mb', # optional + deployment_retention = 0, # optional + interval = 0, # optional + description = '' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md index 72abfb74..5c123bff 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await functions.delete_deployment( + function_id = '', + deployment_id = '' + ) + -result = functions.delete_deployment( - function_id = '', - deployment_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/delete-execution.md b/docs/examples/functions/delete-execution.md index 634bfef7..6c0a555e 100644 --- a/docs/examples/functions/delete-execution.md +++ b/docs/examples/functions/delete-execution.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await functions.delete_execution( + function_id = '', + execution_id = '' + ) + -result = functions.delete_execution( - function_id = '', - execution_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md index e93cd9c5..c436370b 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await functions.delete_variable( + function_id = '', + variable_id = '' + ) + -result = functions.delete_variable( - function_id = '', - variable_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index ebd09f47..feccd106 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await functions.delete( + function_id = '' + ) + -result = functions.delete( - function_id = '' -) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md index 186211e8..a1941484 100644 --- a/docs/examples/functions/get-deployment-download.md +++ b/docs/examples/functions/get-deployment-download.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.enums.deployment_download_type import DeploymentDownloadType -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) +async def main(): + 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: bytes = await functions.get_deployment_download( + function_id = '', + deployment_id = '', + type = DeploymentDownloadType.SOURCE, # optional + token = '' # optional + ) + -result: bytes = functions.get_deployment_download( - function_id = '', - deployment_id = '', - type = DeploymentDownloadType.SOURCE, # optional - token = '' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index d9f8ba2b..7621eead 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Deployment -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) +async def main(): + 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: Deployment = await functions.get_deployment( + function_id = '', + deployment_id = '' + ) + + print(result.model_dump()) -result: Deployment = functions.get_deployment( - function_id = '', - deployment_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index 47d4ce38..2254c962 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Execution -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 -functions = Functions(client) +async def main(): + 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 + + functions = Functions(client) + + result: Execution = await functions.get_execution( + function_id = '', + execution_id = '' + ) + + print(result.model_dump()) -result: Execution = functions.get_execution( - function_id = '', - execution_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index 7ba591ad..82c747aa 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Variable -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) +async def main(): + 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: Variable = await functions.get_variable( + function_id = '', + variable_id = '' + ) + + print(result.model_dump()) -result: Variable = functions.get_variable( - function_id = '', - variable_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index a604e4d9..0327ba6e 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Function -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) +async def main(): + 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: Function = await functions.get( + function_id = '' + ) + + print(result.model_dump()) -result: Function = functions.get( - function_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index 09718165..ffad1a4c 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import DeploymentList -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) +async def main(): + 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: DeploymentList = await functions.list_deployments( + function_id = '', + queries = [], # optional + search = '', # optional + total = False # optional + ) + + print(result.model_dump()) -result: DeploymentList = functions.list_deployments( - function_id = '', - queries = [], # optional - search = '', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index 907ec859..6f67383f 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import ExecutionList -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 -functions = Functions(client) +async def main(): + 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 + + functions = Functions(client) + + result: ExecutionList = await functions.list_executions( + function_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: ExecutionList = functions.list_executions( - function_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index a33db3ad..26da7aae 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import RuntimeList -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) +async def main(): + 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: RuntimeList = await functions.list_runtimes( + total = False # optional + ) + + print(result.model_dump()) -result: RuntimeList = functions.list_runtimes( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index ff71a1be..aedad1eb 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import SpecificationList -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) +async def main(): + 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: SpecificationList = await functions.list_specifications( + type = 'runtimes', # optional + total = False # optional + ) + + print(result.model_dump()) -result: SpecificationList = functions.list_specifications( - type = 'runtimes', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index 693334b7..eb8c0775 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import VariableList -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) +async def main(): + 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: VariableList = await functions.list_variables( + function_id = '', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: VariableList = functions.list_variables( - function_id = '', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index 6f187696..fce7a120 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import FunctionList -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) +async def main(): + 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: FunctionList = await functions.list( + queries = [], # optional + search = '', # optional + total = False # optional + ) + + print(result.model_dump()) -result: FunctionList = functions.list( - queries = [], # optional - search = '', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/update-deployment-status.md b/docs/examples/functions/update-deployment-status.md index 97a55493..d46ca325 100644 --- a/docs/examples/functions/update-deployment-status.md +++ b/docs/examples/functions/update-deployment-status.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Deployment -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) +async def main(): + 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: Deployment = await functions.update_deployment_status( + function_id = '', + deployment_id = '' + ) + + print(result.model_dump()) -result: Deployment = functions.update_deployment_status( - function_id = '', - deployment_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/update-function-deployment.md b/docs/examples/functions/update-function-deployment.md index be39738a..154ff00d 100644 --- a/docs/examples/functions/update-function-deployment.md +++ b/docs/examples/functions/update-function-deployment.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Function -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) +async def main(): + 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: Function = await functions.update_function_deployment( + function_id = '', + deployment_id = '' + ) + + print(result.model_dump()) -result: Function = functions.update_function_deployment( - function_id = '', - deployment_id = '' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index 2368f0d2..f1a9d7ef 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Variable -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) +async def main(): + 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: Variable = await functions.update_variable( + function_id = '', + variable_id = '', + key = '', # optional + value = '', # optional + secret = False, # optional + description = '' # optional + ) + + print(result.model_dump()) -result: Variable = functions.update_variable( - function_id = '', - variable_id = '', - key = '', # optional - value = '', # optional - secret = False, # optional - description = '' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2efde2fb..75279fde 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -1,44 +1,51 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.models import Function from appwrite.enums.runtime import Runtime from appwrite.enums.project_key_scopes import ProjectKeyScopes -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: Function = functions.update( - function_id = '', - name = '', - runtime = Runtime.NODE_14_5, # optional - execute = ["any"], # optional - events = [], # optional - schedule = '0 0 * * *', # optional - timeout = 1, # optional - enabled = False, # optional - logging = False, # optional - entrypoint = '', # optional - commands = '', # optional - scopes = [ProjectKeyScopes.PROJECT_READ], # optional - installation_id = '', # optional - provider_repository_id = '', # optional - provider_branch = '', # optional - provider_silent_mode = False, # optional - provider_root_directory = '', # optional - provider_branches = [], # optional - provider_paths = [], # optional - build_specification = 's-1vcpu-512mb', # optional - runtime_specification = 's-1vcpu-512mb', # optional - deployment_retention = 0, # optional - interval = 0, # optional - description = '', # optional - email_enabled = False # optional -) - -print(result.model_dump()) + +async def main(): + 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: Function = await functions.update( + function_id = '', + name = '', + runtime = Runtime.NODE_14_5, # optional + execute = ["any"], # optional + events = [], # optional + schedule = '0 0 * * *', # optional + timeout = 1, # optional + enabled = False, # optional + logging = False, # optional + entrypoint = '', # optional + commands = '', # optional + scopes = [ProjectKeyScopes.PROJECT_READ], # optional + installation_id = '', # optional + provider_repository_id = '', # optional + provider_branch = '', # optional + provider_silent_mode = False, # optional + provider_root_directory = '', # optional + provider_branches = [], # optional + provider_paths = [], # optional + build_specification = 's-1vcpu-512mb', # optional + runtime_specification = 's-1vcpu-512mb', # optional + deployment_retention = 0, # optional + interval = 0, # optional + description = '', # optional + email_enabled = False # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index a7609b1f..cc7c7e06 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.graphql import Graphql -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_key('') # Your secret API key -graphql = Graphql(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_key('') # Your secret API key + + graphql = Graphql(client) -result = graphql.mutation( - query = { + result = await graphql.mutation( + query = { "query": "mutation { accountUpdateName(name: \"Walter\") { name } }" } -) + ) + + +asyncio.run(main()) ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 350c47ba..d47fdc75 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.graphql import Graphql -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_key('') # Your secret API key -graphql = Graphql(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_key('') # Your secret API key + + graphql = Graphql(client) -result = graphql.query( - query = { + result = await graphql.query( + query = { "query": "query { localeGet { ip } }" } -) + ) + + +asyncio.run(main()) ``` diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index bef85fab..8fc3b532 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.locale import Locale from appwrite.models import Locale as LocaleModel -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with -locale = Locale(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_session('') # The user session to authenticate with + + locale = Locale(client) + + result: LocaleModel = await locale.get() + + print(result.model_dump()) -result: LocaleModel = locale.get() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index 66079411..a0c98123 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.locale import Locale from appwrite.models import LocaleCodeList -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with -locale = Locale(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_session('') # The user session to authenticate with + + locale = Locale(client) + + result: LocaleCodeList = await locale.list_codes( + total = False # optional + ) + + print(result.model_dump()) -result: LocaleCodeList = locale.list_codes( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index cc7c3fd7..a9623478 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.locale import Locale from appwrite.models import ContinentList -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with -locale = Locale(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_session('') # The user session to authenticate with + + locale = Locale(client) + + result: ContinentList = await locale.list_continents( + total = False # optional + ) + + print(result.model_dump()) -result: ContinentList = locale.list_continents( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/locale/list-countries-eu.md b/docs/examples/locale/list-countries-eu.md index d7bebd5a..c2c626c1 100644 --- a/docs/examples/locale/list-countries-eu.md +++ b/docs/examples/locale/list-countries-eu.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.locale import Locale from appwrite.models import CountryList -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with -locale = Locale(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_session('') # The user session to authenticate with + + locale = Locale(client) + + result: CountryList = await locale.list_countries_eu( + total = False # optional + ) + + print(result.model_dump()) -result: CountryList = locale.list_countries_eu( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index cf23539b..9456b949 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.locale import Locale from appwrite.models import PhoneList -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with -locale = Locale(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_session('') # The user session to authenticate with + + locale = Locale(client) + + result: PhoneList = await locale.list_countries_phones( + total = False # optional + ) + + print(result.model_dump()) -result: PhoneList = locale.list_countries_phones( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index 73cb699f..82359c23 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.locale import Locale from appwrite.models import CountryList -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with -locale = Locale(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_session('') # The user session to authenticate with + + locale = Locale(client) + + result: CountryList = await locale.list_countries( + total = False # optional + ) + + print(result.model_dump()) -result: CountryList = locale.list_countries( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index 6d4d2628..31b38db1 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.locale import Locale from appwrite.models import CurrencyList -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with -locale = Locale(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_session('') # The user session to authenticate with + + locale = Locale(client) + + result: CurrencyList = await locale.list_currencies( + total = False # optional + ) + + print(result.model_dump()) -result: CurrencyList = locale.list_currencies( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index ea1f75f2..5e24f890 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.locale import Locale from appwrite.models import LanguageList -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with -locale = Locale(client) +async def main(): + client = Client() + client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('') # Your project ID + client.set_session('') # The user session to authenticate with + + locale = Locale(client) + + result: LanguageList = await locale.list_languages( + total = False # optional + ) + + print(result.model_dump()) -result: LanguageList = locale.list_languages( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index 52d144d6..b7e4f16d 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-appwrite-provider.md b/docs/examples/messaging/create-appwrite-provider.md index c17c582e..3c7c5e93 100644 --- a/docs/examples/messaging/create-appwrite-provider.md +++ b/docs/examples/messaging/create-appwrite-provider.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.create_appwrite_provider( + provider_id = '', + name = '', + enabled = False, # optional + qos = 0, # optional + expiry = 0 # optional + ) + + print(result.model_dump()) -result: Provider = messaging.create_appwrite_provider( - provider_id = '', - name = '', - enabled = False, # optional - qos = 0, # optional - expiry = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 6cf8f14d..5520f6c6 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -1,32 +1,39 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Message -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: Message = 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 = '2020-10-15T06:38:00.000+00:00', # optional - reply_to_email = 'email@example.com', # optional - reply_to_name = '', # optional - emails = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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: Message = await 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 = '2020-10-15T06:38:00.000+00:00', # optional + reply_to_email = 'email@example.com', # optional + reply_to_name = '', # optional + emails = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index b4dc9b2f..869e8d12 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.create_fcm_provider( + provider_id = '', + name = '', + service_account_json = {}, # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: Provider = messaging.create_fcm_provider( - provider_id = '', - name = '', - service_account_json = {}, # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md index 89ecea10..afbd430e 100644 --- a/docs/examples/messaging/create-mailgun-provider.md +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = messaging.create_mailgun_provider( - provider_id = '', - name = '', - api_key = '', # optional - domain = 'example.com', # 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await messaging.create_mailgun_provider( + provider_id = '', + name = '', + api_key = '', # optional + domain = 'example.com', # 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-msg-91-provider.md b/docs/examples/messaging/create-msg-91-provider.md index 9bf577df..8552adc7 100644 --- a/docs/examples/messaging/create-msg-91-provider.md +++ b/docs/examples/messaging/create-msg-91-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.create_msg91_provider( + provider_id = '', + name = '', + template_id = '', # optional + sender_id = '', # optional + auth_key = '', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: Provider = messaging.create_msg91_provider( - provider_id = '', - name = '', - template_id = '', # optional - sender_id = '', # optional - auth_key = '', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index f4b4ff8c..87caabce 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -1,38 +1,45 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Message from appwrite.enums.message_priority import MessagePriority -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: Message = 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 = 1, # optional - draft = False, # optional - scheduled_at = '2020-10-15T06:38:00.000+00:00', # optional - content_available = False, # optional - critical = False, # optional - priority = MessagePriority.NORMAL, # optional - channel_id = '<CHANNEL_ID>' # optional -) - -print(result.model_dump()) + +async def main(): + 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: Message = await messaging.create_push( + message_id = '<MESSAGE_ID>', + title = '<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 = 1, # optional + draft = False, # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00', # optional + content_available = False, # optional + critical = False, # optional + priority = MessagePriority.NORMAL, # optional + channel_id = '<CHANNEL_ID>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-resend-provider.md b/docs/examples/messaging/create-resend-provider.md index 5a1205a4..b4239524 100644 --- a/docs/examples/messaging/create-resend-provider.md +++ b/docs/examples/messaging/create-resend-provider.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = messaging.create_resend_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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await messaging.create_resend_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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md index e9abd646..b4db135e 100644 --- a/docs/examples/messaging/create-sendgrid-provider.md +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-ses-provider.md b/docs/examples/messaging/create-ses-provider.md index 369ffc71..0f576d38 100644 --- a/docs/examples/messaging/create-ses-provider.md +++ b/docs/examples/messaging/create-ses-provider.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = messaging.create_ses_provider( - provider_id = '<PROVIDER_ID>', - name = '<NAME>', - access_key = '<ACCESS_KEY>', # optional - secret_key = '<SECRET_KEY>', # optional - region = '<REGION>', # 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await messaging.create_ses_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + access_key = '<ACCESS_KEY>', # optional + secret_key = '<SECRET_KEY>', # optional + region = '<REGION>', # 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 7512a542..99af3dd4 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Message -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) +async def main(): + 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: Message = await messaging.create_sms( + message_id = '<MESSAGE_ID>', + content = '<CONTENT>', + topics = [], # optional + users = [], # optional + targets = [], # optional + draft = False, # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00' # optional + ) + + print(result.model_dump()) -result: Message = messaging.create_sms( - message_id = '<MESSAGE_ID>', - content = '<CONTENT>', - topics = [], # optional - users = [], # optional - targets = [], # optional - draft = False, # optional - scheduled_at = '2020-10-15T06:38:00.000+00:00' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index 98eabeff..6f0547e4 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -1,32 +1,39 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider from appwrite.enums.smtp_encryption import SmtpEncryption -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: Provider = messaging.create_smtp_provider( - provider_id = '<PROVIDER_ID>', - name = '<NAME>', - host = '<HOST>', - port = 587, # 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await messaging.create_smtp_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + host = '<HOST>', + port = 587, # 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md index 2c230b1a..698a65d2 100644 --- a/docs/examples/messaging/create-subscriber.md +++ b/docs/examples/messaging/create-subscriber.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Subscriber -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) +async def main(): + 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: Subscriber = await messaging.create_subscriber( + topic_id = '<TOPIC_ID>', + subscriber_id = '<SUBSCRIBER_ID>', + target_id = '<TARGET_ID>' + ) + + print(result.model_dump()) -result: Subscriber = messaging.create_subscriber( - topic_id = '<TOPIC_ID>', - subscriber_id = '<SUBSCRIBER_ID>', - target_id = '<TARGET_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md index e4e10589..6042e553 100644 --- a/docs/examples/messaging/create-telesign-provider.md +++ b/docs/examples/messaging/create-telesign-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.create_telesign_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + xfrom = '+12065550100', # optional + customer_id = '<CUSTOMER_ID>', # optional + api_key = '<API_KEY>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: Provider = 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 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md index 3b42e692..a934521c 100644 --- a/docs/examples/messaging/create-textmagic-provider.md +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.create_textmagic_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + xfrom = '+12065550100', # optional + username = '<USERNAME>', # optional + api_key = '<API_KEY>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: Provider = messaging.create_textmagic_provider( - provider_id = '<PROVIDER_ID>', - name = '<NAME>', - from = '+12065550100', # optional - username = '<USERNAME>', # optional - api_key = '<API_KEY>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 6e45f73a..a0f44434 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Topic -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) +async def main(): + 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: Topic = await messaging.create_topic( + topic_id = '<TOPIC_ID>', + name = '<NAME>', + subscribe = ["any"], # optional + qos = 0, # optional + expiry = 0, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: Topic = messaging.create_topic( - topic_id = '<TOPIC_ID>', - name = '<NAME>', - subscribe = ["any"], # optional - qos = 0, # optional - expiry = 0, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index b0e31595..09592d13 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.create_twilio_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + xfrom = '<FROM>', # optional + account_sid = '<ACCOUNT_SID>', # optional + auth_token = '<AUTH_TOKEN>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: Provider = messaging.create_twilio_provider( - provider_id = '<PROVIDER_ID>', - name = '<NAME>', - from = '<FROM>', # optional - account_sid = '<ACCOUNT_SID>', # optional - auth_token = '<AUTH_TOKEN>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md index 4afc224d..a8054cfd 100644 --- a/docs/examples/messaging/create-vonage-provider.md +++ b/docs/examples/messaging/create-vonage-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.create_vonage_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', + xfrom = '+12065550100', # optional + api_key = '<API_KEY>', # optional + api_secret = '<API_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: Provider = 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 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md index 887434c0..e5f032cd 100644 --- a/docs/examples/messaging/delete-provider.md +++ b/docs/examples/messaging/delete-provider.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await messaging.delete_provider( + provider_id = '<PROVIDER_ID>' + ) + -result = messaging.delete_provider( - provider_id = '<PROVIDER_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md index 32eec660..a06287e6 100644 --- a/docs/examples/messaging/delete-subscriber.md +++ b/docs/examples/messaging/delete-subscriber.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await messaging.delete_subscriber( + topic_id = '<TOPIC_ID>', + subscriber_id = '<SUBSCRIBER_ID>' + ) + -result = messaging.delete_subscriber( - topic_id = '<TOPIC_ID>', - subscriber_id = '<SUBSCRIBER_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md index f4658709..123d953d 100644 --- a/docs/examples/messaging/delete-topic.md +++ b/docs/examples/messaging/delete-topic.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await messaging.delete_topic( + topic_id = '<TOPIC_ID>' + ) + -result = messaging.delete_topic( - topic_id = '<TOPIC_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md index d3447ced..85630ba7 100644 --- a/docs/examples/messaging/delete.md +++ b/docs/examples/messaging/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await messaging.delete( + message_id = '<MESSAGE_ID>' + ) + -result = messaging.delete( - message_id = '<MESSAGE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md index b93df097..319b199f 100644 --- a/docs/examples/messaging/get-message.md +++ b/docs/examples/messaging/get-message.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Message -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) +async def main(): + 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: Message = await messaging.get_message( + message_id = '<MESSAGE_ID>' + ) + + print(result.model_dump()) -result: Message = messaging.get_message( - message_id = '<MESSAGE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md index 77750af4..8088e9ab 100644 --- a/docs/examples/messaging/get-provider.md +++ b/docs/examples/messaging/get-provider.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.get_provider( + provider_id = '<PROVIDER_ID>' + ) + + print(result.model_dump()) -result: Provider = messaging.get_provider( - provider_id = '<PROVIDER_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md index 58b6dda2..825a2b32 100644 --- a/docs/examples/messaging/get-subscriber.md +++ b/docs/examples/messaging/get-subscriber.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Subscriber -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) +async def main(): + 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: Subscriber = await messaging.get_subscriber( + topic_id = '<TOPIC_ID>', + subscriber_id = '<SUBSCRIBER_ID>' + ) + + print(result.model_dump()) -result: Subscriber = messaging.get_subscriber( - topic_id = '<TOPIC_ID>', - subscriber_id = '<SUBSCRIBER_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md index 7c38c801..be976909 100644 --- a/docs/examples/messaging/get-topic.md +++ b/docs/examples/messaging/get-topic.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Topic -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) +async def main(): + 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: Topic = await messaging.get_topic( + topic_id = '<TOPIC_ID>' + ) + + print(result.model_dump()) -result: Topic = messaging.get_topic( - topic_id = '<TOPIC_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md index cb833b25..43b0c571 100644 --- a/docs/examples/messaging/list-messages.md +++ b/docs/examples/messaging/list-messages.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import MessageList -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) +async def main(): + 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: MessageList = await messaging.list_messages( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: MessageList = messaging.list_messages( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md index eae8eee0..f474bdff 100644 --- a/docs/examples/messaging/list-providers.md +++ b/docs/examples/messaging/list-providers.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import ProviderList -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) +async def main(): + 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: ProviderList = await messaging.list_providers( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: ProviderList = messaging.list_providers( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md index 7502d00f..f107256a 100644 --- a/docs/examples/messaging/list-subscribers.md +++ b/docs/examples/messaging/list-subscribers.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import SubscriberList -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) +async def main(): + 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: SubscriberList = await messaging.list_subscribers( + topic_id = '<TOPIC_ID>', + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: SubscriberList = messaging.list_subscribers( - topic_id = '<TOPIC_ID>', - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md index 6c753b2f..f217cfe9 100644 --- a/docs/examples/messaging/list-targets.md +++ b/docs/examples/messaging/list-targets.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import TargetList -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) +async def main(): + 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: TargetList = await messaging.list_targets( + message_id = '<MESSAGE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: TargetList = messaging.list_targets( - message_id = '<MESSAGE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md index 106deab0..cdf8cbe3 100644 --- a/docs/examples/messaging/list-topics.md +++ b/docs/examples/messaging/list-topics.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import TopicList -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) +async def main(): + 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: TopicList = await messaging.list_topics( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: TopicList = messaging.list_topics( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index bdbfc06e..5aa30050 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-appwrite-provider.md b/docs/examples/messaging/update-appwrite-provider.md index 6b931ab6..40798840 100644 --- a/docs/examples/messaging/update-appwrite-provider.md +++ b/docs/examples/messaging/update-appwrite-provider.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.update_appwrite_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + qos = 0, # optional + expiry = 0 # optional + ) + + print(result.model_dump()) -result: Provider = messaging.update_appwrite_provider( - provider_id = '<PROVIDER_ID>', - name = '<NAME>', # optional - enabled = False, # optional - qos = 0, # optional - expiry = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 38a59902..9f749e26 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -1,32 +1,39 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Message -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: Message = 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 = '2020-10-15T06:38:00.000+00:00', # optional - attachments = [], # optional - reply_to_email = 'email@example.com', # optional - reply_to_name = '<REPLY_TO_NAME>', # optional - emails = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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: Message = await 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 = '2020-10-15T06:38:00.000+00:00', # optional + attachments = [], # optional + reply_to_email = 'email@example.com', # optional + reply_to_name = '<REPLY_TO_NAME>', # optional + emails = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index 6270cb80..f3419567 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.update_fcm_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + service_account_json = {} # optional + ) + + print(result.model_dump()) -result: Provider = messaging.update_fcm_provider( - provider_id = '<PROVIDER_ID>', - name = '<NAME>', # optional - enabled = False, # optional - service_account_json = {} # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md index 82086c41..63e2e401 100644 --- a/docs/examples/messaging/update-mailgun-provider.md +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = messaging.update_mailgun_provider( - provider_id = '<PROVIDER_ID>', - name = '<NAME>', # optional - api_key = '<API_KEY>', # optional - domain = 'example.com', # 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await messaging.update_mailgun_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + api_key = '<API_KEY>', # optional + domain = 'example.com', # 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-msg-91-provider.md b/docs/examples/messaging/update-msg-91-provider.md index d608d631..cba74216 100644 --- a/docs/examples/messaging/update-msg-91-provider.md +++ b/docs/examples/messaging/update-msg-91-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await 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 + ) + + print(result.model_dump()) -result: Provider = 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 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 0ae36aad..695bd68b 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -1,38 +1,45 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Message from appwrite.enums.message_priority import MessagePriority -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: Message = 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 = 1, # optional - draft = False, # optional - scheduled_at = '2020-10-15T06:38:00.000+00:00', # optional - content_available = False, # optional - critical = False, # optional - priority = MessagePriority.NORMAL, # optional - channel_id = '<CHANNEL_ID>' # optional -) - -print(result.model_dump()) + +async def main(): + 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: Message = await 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 = 1, # optional + draft = False, # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00', # optional + content_available = False, # optional + critical = False, # optional + priority = MessagePriority.NORMAL, # optional + channel_id = '<CHANNEL_ID>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-resend-provider.md b/docs/examples/messaging/update-resend-provider.md index 1de7e46f..6390787a 100644 --- a/docs/examples/messaging/update-resend-provider.md +++ b/docs/examples/messaging/update-resend-provider.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = messaging.update_resend_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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await messaging.update_resend_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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md index 23bf7bad..9eeefc7d 100644 --- a/docs/examples/messaging/update-sendgrid-provider.md +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-ses-provider.md b/docs/examples/messaging/update-ses-provider.md index ab77e2eb..2b250962 100644 --- a/docs/examples/messaging/update-ses-provider.md +++ b/docs/examples/messaging/update-ses-provider.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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: Provider = messaging.update_ses_provider( - provider_id = '<PROVIDER_ID>', - name = '<NAME>', # optional - enabled = False, # optional - access_key = '<ACCESS_KEY>', # optional - secret_key = '<SECRET_KEY>', # optional - region = '<REGION>', # 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await messaging.update_ses_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + access_key = '<ACCESS_KEY>', # optional + secret_key = '<SECRET_KEY>', # optional + region = '<REGION>', # 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 32698978..7f35333c 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Message -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) +async def main(): + 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: Message = await messaging.update_sms( + message_id = '<MESSAGE_ID>', + topics = [], # optional + users = [], # optional + targets = [], # optional + content = '<CONTENT>', # optional + draft = False, # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00' # optional + ) + + print(result.model_dump()) -result: Message = messaging.update_sms( - message_id = '<MESSAGE_ID>', - topics = [], # optional - users = [], # optional - targets = [], # optional - content = '<CONTENT>', # optional - draft = False, # optional - scheduled_at = '2020-10-15T06:38:00.000+00:00' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index 548d72a1..088daf9f 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -1,32 +1,39 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider from appwrite.enums.smtp_encryption import SmtpEncryption -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: Provider = 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 -) - -print(result.model_dump()) + +async def main(): + 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: Provider = await 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 + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md index d59fbaf6..a46c867f 100644 --- a/docs/examples/messaging/update-telesign-provider.md +++ b/docs/examples/messaging/update-telesign-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.update_telesign_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + customer_id = '<CUSTOMER_ID>', # optional + api_key = '<API_KEY>', # optional + xfrom = '<FROM>' # optional + ) + + print(result.model_dump()) -result: Provider = 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 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md index e1f9569b..a9c0b667 100644 --- a/docs/examples/messaging/update-textmagic-provider.md +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.update_textmagic_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + username = '<USERNAME>', # optional + api_key = '<API_KEY>', # optional + xfrom = '<FROM>' # optional + ) + + print(result.model_dump()) -result: Provider = 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 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 65213a5c..cb834ff7 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Topic -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) +async def main(): + 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: Topic = await messaging.update_topic( + topic_id = '<TOPIC_ID>', + name = '<NAME>', # optional + subscribe = ["any"], # optional + qos = 0, # optional + expiry = 0, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: Topic = messaging.update_topic( - topic_id = '<TOPIC_ID>', - name = '<NAME>', # optional - subscribe = ["any"], # optional - qos = 0, # optional - expiry = 0, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md index e4622e27..51655652 100644 --- a/docs/examples/messaging/update-twilio-provider.md +++ b/docs/examples/messaging/update-twilio-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.update_twilio_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + account_sid = '<ACCOUNT_SID>', # optional + auth_token = '<AUTH_TOKEN>', # optional + xfrom = '<FROM>' # optional + ) + + print(result.model_dump()) -result: Provider = 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 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md index ba379894..b45f7855 100644 --- a/docs/examples/messaging/update-vonage-provider.md +++ b/docs/examples/messaging/update-vonage-provider.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.messaging import Messaging from appwrite.models import Provider -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) +async def main(): + 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: Provider = await messaging.update_vonage_provider( + provider_id = '<PROVIDER_ID>', + name = '<NAME>', # optional + enabled = False, # optional + api_key = '<API_KEY>', # optional + api_secret = '<API_SECRET>', # optional + xfrom = '<FROM>' # optional + ) + + print(result.model_dump()) -result: Provider = 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 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/create-backup-policy.md b/docs/examples/mongo/create-backup-policy.md index 08db4ded..1284d06e 100644 --- a/docs/examples/mongo/create-backup-policy.md +++ b/docs/examples/mongo/create-backup-policy.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import BackupPolicy -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: BackupPolicy = await mongo.create_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>', + name = '<NAME>', + schedule = '', + retention = 1, + type = 'full', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: BackupPolicy = mongo.create_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>', - name = '<NAME>', - schedule = '', - retention = 1, - type = 'full', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/create-backup.md b/docs/examples/mongo/create-backup.md index 713de58c..0f7efbcc 100644 --- a/docs/examples/mongo/create-backup.md +++ b/docs/examples/mongo/create-backup.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseBackup -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseBackup = await mongo.create_backup( + database_id = '<DATABASE_ID>', + type = 'full' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseBackup = mongo.create_backup( - database_id = '<DATABASE_ID>', - type = 'full' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/create-branch.md b/docs/examples/mongo/create-branch.md index 9d8f6384..a0263978 100644 --- a/docs/examples/mongo/create-branch.md +++ b/docs/examples/mongo/create-branch.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabase -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabase = await mongo.create_branch( + database_id = '<DATABASE_ID>', + branch_id = '<BRANCH_ID>', # optional + ttl = 300 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = mongo.create_branch( - database_id = '<DATABASE_ID>', - branch_id = '<BRANCH_ID>', # optional - ttl = 300 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/create-failover.md b/docs/examples/mongo/create-failover.md index 09b08d1a..25096f7e 100644 --- a/docs/examples/mongo/create-failover.md +++ b/docs/examples/mongo/create-failover.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabase -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabase = await mongo.create_failover( + database_id = '<DATABASE_ID>', + target_replica_id = '<TARGET_REPLICA_ID>' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = mongo.create_failover( - database_id = '<DATABASE_ID>', - target_replica_id = '<TARGET_REPLICA_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/create-migration.md b/docs/examples/mongo/create-migration.md index d8f75db1..3fa66550 100644 --- a/docs/examples/mongo/create-migration.md +++ b/docs/examples/mongo/create-migration.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabase -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabase = await mongo.create_migration( + database_id = '<DATABASE_ID>', + target_type = 'shared', + specification = '<SPECIFICATION>' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = mongo.create_migration( - database_id = '<DATABASE_ID>', - target_type = 'shared', - specification = '<SPECIFICATION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index b24a7206..4f2c0794 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseRestoration -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 - -mongo = Mongo(client) - -result: DedicatedDatabaseRestoration = mongo.create_restoration( - database_id = '<DATABASE_ID>', - type = 'backup', # optional - backup_id = '<BACKUP_ID>', # optional - target_database_id = '<TARGET_DATABASE_ID>', # optional - target_time = '2020-10-15T06:38:00.000+00:00', # optional - restore_mode = 'in_place', # optional - target_name = '<TARGET_NAME>', # optional - auto_promote = False # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseRestoration = await mongo.create_restoration( + database_id = '<DATABASE_ID>', + type = 'backup', # optional + backup_id = '<BACKUP_ID>', # optional + target_database_id = '<TARGET_DATABASE_ID>', # optional + target_time = '2020-10-15T06:38:00.000+00:00', # optional + restore_mode = 'in_place', # optional + target_name = '<TARGET_NAME>', # optional + auto_promote = False # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/create-upgrade.md b/docs/examples/mongo/create-upgrade.md index 111bea18..d8ac6bbe 100644 --- a/docs/examples/mongo/create-upgrade.md +++ b/docs/examples/mongo/create-upgrade.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabase -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabase = await mongo.create_upgrade( + database_id = '<DATABASE_ID>', + target_version = '<TARGET_VERSION>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = mongo.create_upgrade( - database_id = '<DATABASE_ID>', - target_version = '<TARGET_VERSION>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/create.md b/docs/examples/mongo/create.md index 9909aa62..60657777 100644 --- a/docs/examples/mongo/create.md +++ b/docs/examples/mongo/create.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabase -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 - -mongo = Mongo(client) - -result: DedicatedDatabase = mongo.create( - database_id = '<DATABASE_ID>', - name = '<NAME>', - version = '17', # optional - specification = '<SPECIFICATION>', # optional - replicas = 0, # optional - sync_mode = 'async', # optional - network_idle_timeout_seconds = 60, # optional - network_ip_allowlist = [], # optional - idle_timeout_minutes = 5, # optional - pitr = False, # optional - pitr_retention_days = 1, # optional - storage_autoscaling = False, # optional - storage_autoscaling_threshold_percent = 50, # optional - storage_autoscaling_max_gb = 0 # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabase = await mongo.create( + database_id = '<DATABASE_ID>', + name = '<NAME>', + version = '17', # optional + specification = '<SPECIFICATION>', # optional + replicas = 0, # optional + sync_mode = 'async', # optional + network_idle_timeout_seconds = 60, # optional + network_ip_allowlist = [], # optional + idle_timeout_minutes = 5, # optional + pitr = False, # optional + pitr_retention_days = 1, # optional + storage_autoscaling = False, # optional + storage_autoscaling_threshold_percent = 50, # optional + storage_autoscaling_max_gb = 0 # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/delete-backup-policy.md b/docs/examples/mongo/delete-backup-policy.md index f5a65754..0f22cade 100644 --- a/docs/examples/mongo/delete-backup-policy.md +++ b/docs/examples/mongo/delete-backup-policy.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result = await mongo.delete_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>' + ) + -result = mongo.delete_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/delete-backup.md b/docs/examples/mongo/delete-backup.md index bbcd78c4..bdfd8399 100644 --- a/docs/examples/mongo/delete-backup.md +++ b/docs/examples/mongo/delete-backup.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result = await mongo.delete_backup( + database_id = '<DATABASE_ID>', + backup_id = '<BACKUP_ID>' + ) + -result = mongo.delete_backup( - database_id = '<DATABASE_ID>', - backup_id = '<BACKUP_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/delete-branch.md b/docs/examples/mongo/delete-branch.md index 879ef438..b450a103 100644 --- a/docs/examples/mongo/delete-branch.md +++ b/docs/examples/mongo/delete-branch.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabase -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabase = await mongo.delete_branch( + database_id = '<DATABASE_ID>', + branch_id = '<BRANCH_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = mongo.delete_branch( - database_id = '<DATABASE_ID>', - branch_id = '<BRANCH_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/delete.md b/docs/examples/mongo/delete.md index 9ba0e46c..6dabf027 100644 --- a/docs/examples/mongo/delete.md +++ b/docs/examples/mongo/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result = await mongo.delete( + database_id = '<DATABASE_ID>' + ) + -result = mongo.delete( - database_id = '<DATABASE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/get-backup-policy.md b/docs/examples/mongo/get-backup-policy.md index 1fb3406b..c0659d1e 100644 --- a/docs/examples/mongo/get-backup-policy.md +++ b/docs/examples/mongo/get-backup-policy.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import BackupPolicy -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: BackupPolicy = await mongo.get_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>' + ) + + print(result.model_dump()) -result: BackupPolicy = mongo.get_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/get-backup.md b/docs/examples/mongo/get-backup.md index 49e7db89..f8feff22 100644 --- a/docs/examples/mongo/get-backup.md +++ b/docs/examples/mongo/get-backup.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseBackup -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseBackup = await mongo.get_backup( + database_id = '<DATABASE_ID>', + backup_id = '<BACKUP_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseBackup = mongo.get_backup( - database_id = '<DATABASE_ID>', - backup_id = '<BACKUP_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/get-pitr.md b/docs/examples/mongo/get-pitr.md index b3ae9b81..729aef8e 100644 --- a/docs/examples/mongo/get-pitr.md +++ b/docs/examples/mongo/get-pitr.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabasePITRWindows -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabasePITRWindows = await mongo.get_pitr( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabasePITRWindows = mongo.get_pitr( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/get-replicas.md b/docs/examples/mongo/get-replicas.md index 2f8786ed..86029a00 100644 --- a/docs/examples/mongo/get-replicas.md +++ b/docs/examples/mongo/get-replicas.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseReplicas -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseReplicas = await mongo.get_replicas( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseReplicas = mongo.get_replicas( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/get-restoration.md b/docs/examples/mongo/get-restoration.md index 7e257259..bfc6fad2 100644 --- a/docs/examples/mongo/get-restoration.md +++ b/docs/examples/mongo/get-restoration.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseRestoration -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseRestoration = await mongo.get_restoration( + database_id = '<DATABASE_ID>', + restoration_id = '<RESTORATION_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseRestoration = mongo.get_restoration( - database_id = '<DATABASE_ID>', - restoration_id = '<RESTORATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/get-status.md b/docs/examples/mongo/get-status.md index f2f832dd..9fb8a84f 100644 --- a/docs/examples/mongo/get-status.md +++ b/docs/examples/mongo/get-status.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DatabaseStatus -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DatabaseStatus = await mongo.get_status( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DatabaseStatus = mongo.get_status( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/get.md b/docs/examples/mongo/get.md index c89e66a5..d4431727 100644 --- a/docs/examples/mongo/get.md +++ b/docs/examples/mongo/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabase -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabase = await mongo.get( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = mongo.get( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/list-backup-policies.md b/docs/examples/mongo/list-backup-policies.md index e79ffd33..e3555e0f 100644 --- a/docs/examples/mongo/list-backup-policies.md +++ b/docs/examples/mongo/list-backup-policies.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import BackupPolicyList -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: BackupPolicyList = await mongo.list_backup_policies( + database_id = '<DATABASE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: BackupPolicyList = mongo.list_backup_policies( - database_id = '<DATABASE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/list-backups.md b/docs/examples/mongo/list-backups.md index 86b6bc3f..9a9ea2a0 100644 --- a/docs/examples/mongo/list-backups.md +++ b/docs/examples/mongo/list-backups.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseBackupList -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseBackupList = await mongo.list_backups( + database_id = '<DATABASE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseBackupList = mongo.list_backups( - database_id = '<DATABASE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/list-branches.md b/docs/examples/mongo/list-branches.md index 4c1f1a4e..8086f349 100644 --- a/docs/examples/mongo/list-branches.md +++ b/docs/examples/mongo/list-branches.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseBranchList -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseBranchList = await mongo.list_branches( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseBranchList = mongo.list_branches( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/list-operations.md b/docs/examples/mongo/list-operations.md index 9c2f77a2..481e45e6 100644 --- a/docs/examples/mongo/list-operations.md +++ b/docs/examples/mongo/list-operations.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseOperationList -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseOperationList = await mongo.list_operations( + database_id = '<DATABASE_ID>', + status = 'queued', # optional + limit = 1, # optional + offset = 0 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseOperationList = mongo.list_operations( - database_id = '<DATABASE_ID>', - status = 'queued', # optional - limit = 1, # optional - offset = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/list-restorations.md b/docs/examples/mongo/list-restorations.md index 89bb120e..7475e24a 100644 --- a/docs/examples/mongo/list-restorations.md +++ b/docs/examples/mongo/list-restorations.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseRestorationList -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseRestorationList = await mongo.list_restorations( + database_id = '<DATABASE_ID>', + status = 'pending', # optional + type = 'backup', # optional + limit = 1, # optional + offset = 0 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseRestorationList = mongo.list_restorations( - database_id = '<DATABASE_ID>', - status = 'pending', # optional - type = 'backup', # optional - limit = 1, # optional - offset = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/list-specifications.md b/docs/examples/mongo/list-specifications.md index 6828191e..990d205e 100644 --- a/docs/examples/mongo/list-specifications.md +++ b/docs/examples/mongo/list-specifications.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseSpecificationList -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseSpecificationList = await mongo.list_specifications() + + print(result.model_dump()) -result: DedicatedDatabaseSpecificationList = mongo.list_specifications() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/list.md b/docs/examples/mongo/list.md index c31a18c3..bb1d2244 100644 --- a/docs/examples/mongo/list.md +++ b/docs/examples/mongo/list.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseList -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseList = await mongo.list( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseList = mongo.list( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/promote-restoration.md b/docs/examples/mongo/promote-restoration.md index 826eef23..b3390d5d 100644 --- a/docs/examples/mongo/promote-restoration.md +++ b/docs/examples/mongo/promote-restoration.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseRestoration -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseRestoration = await mongo.promote_restoration( + database_id = '<DATABASE_ID>', + restoration_id = '<RESTORATION_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseRestoration = mongo.promote_restoration( - database_id = '<DATABASE_ID>', - restoration_id = '<RESTORATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/update-backup-policy.md b/docs/examples/mongo/update-backup-policy.md index 5a02ffe1..b788e8a1 100644 --- a/docs/examples/mongo/update-backup-policy.md +++ b/docs/examples/mongo/update-backup-policy.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import BackupPolicy -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: BackupPolicy = await mongo.update_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>', + name = '<NAME>', # optional + schedule = '', # optional + retention = 1, # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: BackupPolicy = mongo.update_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>', - name = '<NAME>', # optional - schedule = '', # optional - retention = 1, # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/update-backup-storage.md b/docs/examples/mongo/update-backup-storage.md index 9a62d4fd..f4fba4f8 100644 --- a/docs/examples/mongo/update-backup-storage.md +++ b/docs/examples/mongo/update-backup-storage.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseBackupStorage -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 - -mongo = Mongo(client) - -result: DedicatedDatabaseBackupStorage = mongo.update_backup_storage( - database_id = '<DATABASE_ID>', - provider = 's3', - bucket = '<BUCKET>', - access_key = '<ACCESS_KEY>', - secret_key = '<SECRET_KEY>', - region = '<REGION>', # optional - prefix = '<PREFIX>', # optional - endpoint = '<ENDPOINT>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseBackupStorage = await mongo.update_backup_storage( + database_id = '<DATABASE_ID>', + provider = 's3', + bucket = '<BUCKET>', + access_key = '<ACCESS_KEY>', + secret_key = '<SECRET_KEY>', + region = '<REGION>', # optional + prefix = '<PREFIX>', # optional + endpoint = '<ENDPOINT>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/update-credentials.md b/docs/examples/mongo/update-credentials.md index 12d138c8..0220cdc2 100644 --- a/docs/examples/mongo/update-credentials.md +++ b/docs/examples/mongo/update-credentials.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabaseOperation -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabaseOperation = await mongo.update_credentials( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseOperation = mongo.update_credentials( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/update-maintenance.md b/docs/examples/mongo/update-maintenance.md index 081016ab..582c0135 100644 --- a/docs/examples/mongo/update-maintenance.md +++ b/docs/examples/mongo/update-maintenance.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabase -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 -mongo = Mongo(client) +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabase = await mongo.update_maintenance( + database_id = '<DATABASE_ID>', + day = 'sun', + hour_utc = 0 + ) + + print(result.model_dump()) -result: DedicatedDatabase = mongo.update_maintenance( - database_id = '<DATABASE_ID>', - day = 'sun', - hour_utc = 0 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mongo/update.md b/docs/examples/mongo/update.md index e14bffc7..1707dbbc 100644 --- a/docs/examples/mongo/update.md +++ b/docs/examples/mongo/update.md @@ -1,38 +1,45 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mongo import Mongo from appwrite.models import DedicatedDatabase -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 - -mongo = Mongo(client) - -result: DedicatedDatabase = mongo.update( - database_id = '<DATABASE_ID>', - name = '<NAME>', # optional - status = 'ready', # optional - specification = '<SPECIFICATION>', # optional - replicas = 0, # optional - sync_mode = 'async', # optional - network_idle_timeout_seconds = 60, # optional - network_ip_allowlist = [], # optional - idle_timeout_minutes = 5, # optional - pitr = False, # optional - pitr_retention_days = 1, # optional - storage_autoscaling = False, # optional - storage_autoscaling_threshold_percent = 50, # optional - storage_autoscaling_max_gb = 0, # optional - metrics_trace_sample_rate = None, # optional - metrics_slow_query_log_threshold_ms = 0, # optional - sql_api_enabled = False, # optional - sql_api_allowed_statements = [], # optional - sql_api_max_rows = 1, # optional - sql_api_max_bytes = 1024, # optional - sql_api_timeout_seconds = 1 # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + mongo = Mongo(client) + + result: DedicatedDatabase = await mongo.update( + database_id = '<DATABASE_ID>', + name = '<NAME>', # optional + status = 'ready', # optional + specification = '<SPECIFICATION>', # optional + replicas = 0, # optional + sync_mode = 'async', # optional + network_idle_timeout_seconds = 60, # optional + network_ip_allowlist = [], # optional + idle_timeout_minutes = 5, # optional + pitr = False, # optional + pitr_retention_days = 1, # optional + storage_autoscaling = False, # optional + storage_autoscaling_threshold_percent = 50, # optional + storage_autoscaling_max_gb = 0, # optional + metrics_trace_sample_rate = None, # optional + metrics_slow_query_log_threshold_ms = 0, # optional + sql_api_enabled = False, # optional + sql_api_allowed_statements = [], # optional + sql_api_max_rows = 1, # optional + sql_api_max_bytes = 1024, # optional + sql_api_timeout_seconds = 1 # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/create-backup-policy.md b/docs/examples/mysql/create-backup-policy.md index bb76383a..068d1496 100644 --- a/docs/examples/mysql/create-backup-policy.md +++ b/docs/examples/mysql/create-backup-policy.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import BackupPolicy -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: BackupPolicy = await mysql.create_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>', + name = '<NAME>', + schedule = '', + retention = 1, + type = 'full', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: BackupPolicy = mysql.create_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>', - name = '<NAME>', - schedule = '', - retention = 1, - type = 'full', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/create-backup.md b/docs/examples/mysql/create-backup.md index 05e98dd4..6d277405 100644 --- a/docs/examples/mysql/create-backup.md +++ b/docs/examples/mysql/create-backup.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseBackup -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseBackup = await mysql.create_backup( + database_id = '<DATABASE_ID>', + type = 'full' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseBackup = mysql.create_backup( - database_id = '<DATABASE_ID>', - type = 'full' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/create-branch.md b/docs/examples/mysql/create-branch.md index aec24a08..caab8283 100644 --- a/docs/examples/mysql/create-branch.md +++ b/docs/examples/mysql/create-branch.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabase -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabase = await mysql.create_branch( + database_id = '<DATABASE_ID>', + branch_id = '<BRANCH_ID>', # optional + ttl = 300 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = mysql.create_branch( - database_id = '<DATABASE_ID>', - branch_id = '<BRANCH_ID>', # optional - ttl = 300 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/create-execution.md b/docs/examples/mysql/create-execution.md index e4cd9772..a77869ae 100644 --- a/docs/examples/mysql/create-execution.md +++ b/docs/examples/mysql/create-execution.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseExecution -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseExecution = await mysql.create_execution( + database_id = '<DATABASE_ID>', + sql = '<SQL>', + bindings = {}, # optional + timeout_seconds = 1 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseExecution = mysql.create_execution( - database_id = '<DATABASE_ID>', - sql = '<SQL>', - bindings = {}, # optional - timeout_seconds = 1 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/create-failover.md b/docs/examples/mysql/create-failover.md index cde13f40..b0eb2969 100644 --- a/docs/examples/mysql/create-failover.md +++ b/docs/examples/mysql/create-failover.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabase -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabase = await mysql.create_failover( + database_id = '<DATABASE_ID>', + target_replica_id = '<TARGET_REPLICA_ID>' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = mysql.create_failover( - database_id = '<DATABASE_ID>', - target_replica_id = '<TARGET_REPLICA_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/create-migration.md b/docs/examples/mysql/create-migration.md index b5616780..c4a4b9a1 100644 --- a/docs/examples/mysql/create-migration.md +++ b/docs/examples/mysql/create-migration.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabase -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabase = await mysql.create_migration( + database_id = '<DATABASE_ID>', + target_type = 'shared', + specification = '<SPECIFICATION>' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = mysql.create_migration( - database_id = '<DATABASE_ID>', - target_type = 'shared', - specification = '<SPECIFICATION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index f4854228..21bf679a 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseRestoration -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 - -mysql = Mysql(client) - -result: DedicatedDatabaseRestoration = mysql.create_restoration( - database_id = '<DATABASE_ID>', - type = 'backup', # optional - backup_id = '<BACKUP_ID>', # optional - target_database_id = '<TARGET_DATABASE_ID>', # optional - target_time = '2020-10-15T06:38:00.000+00:00', # optional - restore_mode = 'in_place', # optional - target_name = '<TARGET_NAME>', # optional - auto_promote = False # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseRestoration = await mysql.create_restoration( + database_id = '<DATABASE_ID>', + type = 'backup', # optional + backup_id = '<BACKUP_ID>', # optional + target_database_id = '<TARGET_DATABASE_ID>', # optional + target_time = '2020-10-15T06:38:00.000+00:00', # optional + restore_mode = 'in_place', # optional + target_name = '<TARGET_NAME>', # optional + auto_promote = False # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/create-upgrade.md b/docs/examples/mysql/create-upgrade.md index f1e246ef..c55e37e2 100644 --- a/docs/examples/mysql/create-upgrade.md +++ b/docs/examples/mysql/create-upgrade.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabase -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabase = await mysql.create_upgrade( + database_id = '<DATABASE_ID>', + target_version = '<TARGET_VERSION>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = mysql.create_upgrade( - database_id = '<DATABASE_ID>', - target_version = '<TARGET_VERSION>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/create.md b/docs/examples/mysql/create.md index 92a7c007..f68e654b 100644 --- a/docs/examples/mysql/create.md +++ b/docs/examples/mysql/create.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabase -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 - -mysql = Mysql(client) - -result: DedicatedDatabase = mysql.create( - database_id = '<DATABASE_ID>', - name = '<NAME>', - version = '17', # optional - specification = '<SPECIFICATION>', # optional - replicas = 0, # optional - sync_mode = 'async', # optional - network_idle_timeout_seconds = 60, # optional - network_ip_allowlist = [], # optional - idle_timeout_minutes = 5, # optional - pitr = False, # optional - pitr_retention_days = 1, # optional - storage_autoscaling = False, # optional - storage_autoscaling_threshold_percent = 50, # optional - storage_autoscaling_max_gb = 0 # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabase = await mysql.create( + database_id = '<DATABASE_ID>', + name = '<NAME>', + version = '17', # optional + specification = '<SPECIFICATION>', # optional + replicas = 0, # optional + sync_mode = 'async', # optional + network_idle_timeout_seconds = 60, # optional + network_ip_allowlist = [], # optional + idle_timeout_minutes = 5, # optional + pitr = False, # optional + pitr_retention_days = 1, # optional + storage_autoscaling = False, # optional + storage_autoscaling_threshold_percent = 50, # optional + storage_autoscaling_max_gb = 0 # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/delete-backup-policy.md b/docs/examples/mysql/delete-backup-policy.md index 7f6fbf88..e646f515 100644 --- a/docs/examples/mysql/delete-backup-policy.md +++ b/docs/examples/mysql/delete-backup-policy.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result = await mysql.delete_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>' + ) + -result = mysql.delete_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/delete-backup.md b/docs/examples/mysql/delete-backup.md index cd0f7322..8d3a9c89 100644 --- a/docs/examples/mysql/delete-backup.md +++ b/docs/examples/mysql/delete-backup.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result = await mysql.delete_backup( + database_id = '<DATABASE_ID>', + backup_id = '<BACKUP_ID>' + ) + -result = mysql.delete_backup( - database_id = '<DATABASE_ID>', - backup_id = '<BACKUP_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/delete-branch.md b/docs/examples/mysql/delete-branch.md index 7e7bbbdc..2d7405e3 100644 --- a/docs/examples/mysql/delete-branch.md +++ b/docs/examples/mysql/delete-branch.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabase -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabase = await mysql.delete_branch( + database_id = '<DATABASE_ID>', + branch_id = '<BRANCH_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = mysql.delete_branch( - database_id = '<DATABASE_ID>', - branch_id = '<BRANCH_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/delete.md b/docs/examples/mysql/delete.md index 9632ba06..1d8d6470 100644 --- a/docs/examples/mysql/delete.md +++ b/docs/examples/mysql/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result = await mysql.delete( + database_id = '<DATABASE_ID>' + ) + -result = mysql.delete( - database_id = '<DATABASE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/get-backup-policy.md b/docs/examples/mysql/get-backup-policy.md index 0d3baec5..36afab55 100644 --- a/docs/examples/mysql/get-backup-policy.md +++ b/docs/examples/mysql/get-backup-policy.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import BackupPolicy -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: BackupPolicy = await mysql.get_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>' + ) + + print(result.model_dump()) -result: BackupPolicy = mysql.get_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/get-backup.md b/docs/examples/mysql/get-backup.md index eb782c5e..c2629a8f 100644 --- a/docs/examples/mysql/get-backup.md +++ b/docs/examples/mysql/get-backup.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseBackup -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseBackup = await mysql.get_backup( + database_id = '<DATABASE_ID>', + backup_id = '<BACKUP_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseBackup = mysql.get_backup( - database_id = '<DATABASE_ID>', - backup_id = '<BACKUP_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/get-pitr.md b/docs/examples/mysql/get-pitr.md index 5202ed66..4cded98f 100644 --- a/docs/examples/mysql/get-pitr.md +++ b/docs/examples/mysql/get-pitr.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabasePITRWindows -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabasePITRWindows = await mysql.get_pitr( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabasePITRWindows = mysql.get_pitr( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/get-pooler.md b/docs/examples/mysql/get-pooler.md index fc2af012..80aabc05 100644 --- a/docs/examples/mysql/get-pooler.md +++ b/docs/examples/mysql/get-pooler.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabasePooler -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabasePooler = await mysql.get_pooler( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabasePooler = mysql.get_pooler( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/get-replicas.md b/docs/examples/mysql/get-replicas.md index a35bf822..38332ba7 100644 --- a/docs/examples/mysql/get-replicas.md +++ b/docs/examples/mysql/get-replicas.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseReplicas -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseReplicas = await mysql.get_replicas( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseReplicas = mysql.get_replicas( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/get-restoration.md b/docs/examples/mysql/get-restoration.md index 0e760273..78d06fd4 100644 --- a/docs/examples/mysql/get-restoration.md +++ b/docs/examples/mysql/get-restoration.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseRestoration -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseRestoration = await mysql.get_restoration( + database_id = '<DATABASE_ID>', + restoration_id = '<RESTORATION_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseRestoration = mysql.get_restoration( - database_id = '<DATABASE_ID>', - restoration_id = '<RESTORATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/get-status.md b/docs/examples/mysql/get-status.md index 97adbe6c..a40ef8e6 100644 --- a/docs/examples/mysql/get-status.md +++ b/docs/examples/mysql/get-status.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DatabaseStatus -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DatabaseStatus = await mysql.get_status( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DatabaseStatus = mysql.get_status( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/get.md b/docs/examples/mysql/get.md index 431c72ca..d01ccdf2 100644 --- a/docs/examples/mysql/get.md +++ b/docs/examples/mysql/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabase -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabase = await mysql.get( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = mysql.get( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/list-backup-policies.md b/docs/examples/mysql/list-backup-policies.md index 0297517f..50929917 100644 --- a/docs/examples/mysql/list-backup-policies.md +++ b/docs/examples/mysql/list-backup-policies.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import BackupPolicyList -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: BackupPolicyList = await mysql.list_backup_policies( + database_id = '<DATABASE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: BackupPolicyList = mysql.list_backup_policies( - database_id = '<DATABASE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/list-backups.md b/docs/examples/mysql/list-backups.md index 0dc15e5b..ab510cc7 100644 --- a/docs/examples/mysql/list-backups.md +++ b/docs/examples/mysql/list-backups.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseBackupList -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseBackupList = await mysql.list_backups( + database_id = '<DATABASE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseBackupList = mysql.list_backups( - database_id = '<DATABASE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/list-branches.md b/docs/examples/mysql/list-branches.md index 6c05f543..7ac0253e 100644 --- a/docs/examples/mysql/list-branches.md +++ b/docs/examples/mysql/list-branches.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseBranchList -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseBranchList = await mysql.list_branches( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseBranchList = mysql.list_branches( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/list-operations.md b/docs/examples/mysql/list-operations.md index 1b4d3c97..41f20ac6 100644 --- a/docs/examples/mysql/list-operations.md +++ b/docs/examples/mysql/list-operations.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseOperationList -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseOperationList = await mysql.list_operations( + database_id = '<DATABASE_ID>', + status = 'queued', # optional + limit = 1, # optional + offset = 0 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseOperationList = mysql.list_operations( - database_id = '<DATABASE_ID>', - status = 'queued', # optional - limit = 1, # optional - offset = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/list-restorations.md b/docs/examples/mysql/list-restorations.md index efe346da..6c1d7d62 100644 --- a/docs/examples/mysql/list-restorations.md +++ b/docs/examples/mysql/list-restorations.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseRestorationList -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseRestorationList = await mysql.list_restorations( + database_id = '<DATABASE_ID>', + status = 'pending', # optional + type = 'backup', # optional + limit = 1, # optional + offset = 0 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseRestorationList = mysql.list_restorations( - database_id = '<DATABASE_ID>', - status = 'pending', # optional - type = 'backup', # optional - limit = 1, # optional - offset = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/list-specifications.md b/docs/examples/mysql/list-specifications.md index c5d48d5a..9ed45cb3 100644 --- a/docs/examples/mysql/list-specifications.md +++ b/docs/examples/mysql/list-specifications.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseSpecificationList -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseSpecificationList = await mysql.list_specifications() + + print(result.model_dump()) -result: DedicatedDatabaseSpecificationList = mysql.list_specifications() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/list.md b/docs/examples/mysql/list.md index b5aba207..d3cfa6a5 100644 --- a/docs/examples/mysql/list.md +++ b/docs/examples/mysql/list.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseList -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseList = await mysql.list( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseList = mysql.list( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/promote-restoration.md b/docs/examples/mysql/promote-restoration.md index 38a54b49..b3bacaa6 100644 --- a/docs/examples/mysql/promote-restoration.md +++ b/docs/examples/mysql/promote-restoration.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseRestoration -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseRestoration = await mysql.promote_restoration( + database_id = '<DATABASE_ID>', + restoration_id = '<RESTORATION_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseRestoration = mysql.promote_restoration( - database_id = '<DATABASE_ID>', - restoration_id = '<RESTORATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/update-backup-policy.md b/docs/examples/mysql/update-backup-policy.md index 65f9a9a3..81f41551 100644 --- a/docs/examples/mysql/update-backup-policy.md +++ b/docs/examples/mysql/update-backup-policy.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import BackupPolicy -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: BackupPolicy = await mysql.update_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>', + name = '<NAME>', # optional + schedule = '', # optional + retention = 1, # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: BackupPolicy = mysql.update_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>', - name = '<NAME>', # optional - schedule = '', # optional - retention = 1, # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/update-backup-storage.md b/docs/examples/mysql/update-backup-storage.md index ecc41eb9..90dc05b0 100644 --- a/docs/examples/mysql/update-backup-storage.md +++ b/docs/examples/mysql/update-backup-storage.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseBackupStorage -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 - -mysql = Mysql(client) - -result: DedicatedDatabaseBackupStorage = mysql.update_backup_storage( - database_id = '<DATABASE_ID>', - provider = 's3', - bucket = '<BUCKET>', - access_key = '<ACCESS_KEY>', - secret_key = '<SECRET_KEY>', - region = '<REGION>', # optional - prefix = '<PREFIX>', # optional - endpoint = '<ENDPOINT>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseBackupStorage = await mysql.update_backup_storage( + database_id = '<DATABASE_ID>', + provider = 's3', + bucket = '<BUCKET>', + access_key = '<ACCESS_KEY>', + secret_key = '<SECRET_KEY>', + region = '<REGION>', # optional + prefix = '<PREFIX>', # optional + endpoint = '<ENDPOINT>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/update-credentials.md b/docs/examples/mysql/update-credentials.md index e277a92d..3944bc72 100644 --- a/docs/examples/mysql/update-credentials.md +++ b/docs/examples/mysql/update-credentials.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabaseOperation -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabaseOperation = await mysql.update_credentials( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseOperation = mysql.update_credentials( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/update-maintenance.md b/docs/examples/mysql/update-maintenance.md index a14aa8e8..84ef9ba0 100644 --- a/docs/examples/mysql/update-maintenance.md +++ b/docs/examples/mysql/update-maintenance.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabase -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 -mysql = Mysql(client) +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabase = await mysql.update_maintenance( + database_id = '<DATABASE_ID>', + day = 'sun', + hour_utc = 0 + ) + + print(result.model_dump()) -result: DedicatedDatabase = mysql.update_maintenance( - database_id = '<DATABASE_ID>', - day = 'sun', - hour_utc = 0 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/update-pooler.md b/docs/examples/mysql/update-pooler.md index 57fde4e7..a07bab24 100644 --- a/docs/examples/mysql/update-pooler.md +++ b/docs/examples/mysql/update-pooler.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabasePooler -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 - -mysql = Mysql(client) - -result: DedicatedDatabasePooler = mysql.update_pooler( - database_id = '<DATABASE_ID>', - mode = 'transaction', # optional - max_connections = 10, # optional - default_pool_size = 1, # optional - read_write_splitting = False, # optional - pooler_cpu_request = '<POOLER_CPU_REQUEST>', # optional - pooler_cpu_limit = '<POOLER_CPU_LIMIT>', # optional - pooler_memory_request = '<POOLER_MEMORY_REQUEST>', # optional - pooler_memory_limit = '<POOLER_MEMORY_LIMIT>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabasePooler = await mysql.update_pooler( + database_id = '<DATABASE_ID>', + mode = 'transaction', # optional + max_connections = 10, # optional + default_pool_size = 1, # optional + read_write_splitting = False, # optional + pooler_cpu_request = '<POOLER_CPU_REQUEST>', # optional + pooler_cpu_limit = '<POOLER_CPU_LIMIT>', # optional + pooler_memory_request = '<POOLER_MEMORY_REQUEST>', # optional + pooler_memory_limit = '<POOLER_MEMORY_LIMIT>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/mysql/update.md b/docs/examples/mysql/update.md index e3fe2474..ba564617 100644 --- a/docs/examples/mysql/update.md +++ b/docs/examples/mysql/update.md @@ -1,38 +1,45 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.mysql import Mysql from appwrite.models import DedicatedDatabase -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 - -mysql = Mysql(client) - -result: DedicatedDatabase = mysql.update( - database_id = '<DATABASE_ID>', - name = '<NAME>', # optional - status = 'ready', # optional - specification = '<SPECIFICATION>', # optional - replicas = 0, # optional - sync_mode = 'async', # optional - network_idle_timeout_seconds = 60, # optional - network_ip_allowlist = [], # optional - idle_timeout_minutes = 5, # optional - pitr = False, # optional - pitr_retention_days = 1, # optional - storage_autoscaling = False, # optional - storage_autoscaling_threshold_percent = 50, # optional - storage_autoscaling_max_gb = 0, # optional - metrics_trace_sample_rate = None, # optional - metrics_slow_query_log_threshold_ms = 0, # optional - sql_api_enabled = False, # optional - sql_api_allowed_statements = [], # optional - sql_api_max_rows = 1, # optional - sql_api_max_bytes = 1024, # optional - sql_api_timeout_seconds = 1 # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + mysql = Mysql(client) + + result: DedicatedDatabase = await mysql.update( + database_id = '<DATABASE_ID>', + name = '<NAME>', # optional + status = 'ready', # optional + specification = '<SPECIFICATION>', # optional + replicas = 0, # optional + sync_mode = 'async', # optional + network_idle_timeout_seconds = 60, # optional + network_ip_allowlist = [], # optional + idle_timeout_minutes = 5, # optional + pitr = False, # optional + pitr_retention_days = 1, # optional + storage_autoscaling = False, # optional + storage_autoscaling_threshold_percent = 50, # optional + storage_autoscaling_max_gb = 0, # optional + metrics_trace_sample_rate = None, # optional + metrics_slow_query_log_threshold_ms = 0, # optional + sql_api_enabled = False, # optional + sql_api_allowed_statements = [], # optional + sql_api_max_rows = 1, # optional + sql_api_max_bytes = 1024, # optional + sql_api_timeout_seconds = 1 # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 31bb7317..91bd464f 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2Approve -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -oauth2 = Oauth2(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2Approve = await oauth2.approve( + grant_id = '<GRANT_ID>', + authorization_details = '<AUTHORIZATION_DETAILS>', # optional + scope = '<SCOPE>' # optional + ) + + print(result.model_dump()) -result: Oauth2Approve = oauth2.approve( - grant_id = '<GRANT_ID>', - authorization_details = '<AUTHORIZATION_DETAILS>', # optional - scope = '<SCOPE>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 8cf274b7..0cbf8d33 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2Authorize -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with - -oauth2 = Oauth2(client) - -result: Oauth2Authorize = oauth2.authorize_post( - client_id = '<CLIENT_ID>', # optional - redirect_uri = 'https://example.com', # optional - response_type = '', # optional - scope = '<SCOPE>', # optional - state = '<STATE>', # optional - nonce = '<NONCE>', # optional - code_challenge = '<CODE_CHALLENGE>', # optional - code_challenge_method = 's256', # optional - prompt = '<PROMPT>', # optional - max_age = 0, # optional - authorization_details = '<AUTHORIZATION_DETAILS>', # optional - resource = [], # optional - audience = '<AUDIENCE>', # optional - request_uri = '<REQUEST_URI>' # optional -) - -print(result.model_dump()) + +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2Authorize = await oauth2.authorize_post( + client_id = '<CLIENT_ID>', # optional + redirect_uri = 'https://example.com', # optional + response_type = '', # optional + scope = '<SCOPE>', # optional + state = '<STATE>', # optional + nonce = '<NONCE>', # optional + code_challenge = '<CODE_CHALLENGE>', # optional + code_challenge_method = 's256', # optional + prompt = '<PROMPT>', # optional + max_age = 0, # optional + authorization_details = '<AUTHORIZATION_DETAILS>', # optional + resource = [], # optional + audience = '<AUDIENCE>', # optional + request_uri = '<REQUEST_URI>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index 32fbf4b2..277e41b0 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2Authorize -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with - -oauth2 = Oauth2(client) - -result: Oauth2Authorize = oauth2.authorize( - client_id = '<CLIENT_ID>', # optional - redirect_uri = 'https://example.com', # optional - response_type = '', # optional - scope = '<SCOPE>', # optional - state = '<STATE>', # optional - nonce = '<NONCE>', # optional - code_challenge = '<CODE_CHALLENGE>', # optional - code_challenge_method = 's256', # optional - prompt = '<PROMPT>', # optional - max_age = 0, # optional - authorization_details = '<AUTHORIZATION_DETAILS>', # optional - resource = [], # optional - audience = '<AUDIENCE>', # optional - request_uri = '<REQUEST_URI>' # optional -) - -print(result.model_dump()) + +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2Authorize = await oauth2.authorize( + client_id = '<CLIENT_ID>', # optional + redirect_uri = 'https://example.com', # optional + response_type = '', # optional + scope = '<SCOPE>', # optional + state = '<STATE>', # optional + nonce = '<NONCE>', # optional + code_challenge = '<CODE_CHALLENGE>', # optional + code_challenge_method = 's256', # optional + prompt = '<PROMPT>', # optional + max_age = 0, # optional + authorization_details = '<AUTHORIZATION_DETAILS>', # optional + resource = [], # optional + audience = '<AUDIENCE>', # optional + request_uri = '<REQUEST_URI>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index f45ce70c..3cf11533 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2DeviceAuthorization -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -oauth2 = Oauth2(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2DeviceAuthorization = await oauth2.create_device_authorization( + client_id = '<CLIENT_ID>', # optional + scope = '<SCOPE>', # optional + authorization_details = '<AUTHORIZATION_DETAILS>', # optional + resource = [], # optional + audience = '<AUDIENCE>' # optional + ) + + print(result.model_dump()) -result: Oauth2DeviceAuthorization = oauth2.create_device_authorization( - client_id = '<CLIENT_ID>', # optional - scope = '<SCOPE>', # optional - authorization_details = '<AUTHORIZATION_DETAILS>', # optional - resource = [], # optional - audience = '<AUDIENCE>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 73727320..40def5fa 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2Grant -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -oauth2 = Oauth2(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2Grant = await oauth2.create_grant( + user_code = '<USER_CODE>' + ) + + print(result.model_dump()) -result: Oauth2Grant = oauth2.create_grant( - user_code = '<USER_CODE>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 32b72a9d..cffe268a 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -1,30 +1,37 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2PAR -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with - -oauth2 = Oauth2(client) - -result: Oauth2PAR = oauth2.create_par( - client_id = '<CLIENT_ID>', - redirect_uri = 'https://example.com', - response_type = 'code', - scope = '<SCOPE>', # optional - state = '<STATE>', # optional - nonce = '<NONCE>', # optional - code_challenge = '<CODE_CHALLENGE>', # optional - code_challenge_method = 's256', # optional - prompt = '<PROMPT>', # optional - max_age = 0, # optional - authorization_details = '<AUTHORIZATION_DETAILS>', # optional - resource = [], # optional - audience = '<AUDIENCE>' # optional -) - -print(result.model_dump()) + +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2PAR = await oauth2.create_par( + client_id = '<CLIENT_ID>', + redirect_uri = 'https://example.com', + response_type = 'code', + scope = '<SCOPE>', # optional + state = '<STATE>', # optional + nonce = '<NONCE>', # optional + code_challenge = '<CODE_CHALLENGE>', # optional + code_challenge_method = 's256', # optional + prompt = '<PROMPT>', # optional + max_age = 0, # optional + authorization_details = '<AUTHORIZATION_DETAILS>', # optional + resource = [], # optional + audience = '<AUDIENCE>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index 6dd3006b..79e5cc16 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2Token -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with - -oauth2 = Oauth2(client) - -result: Oauth2Token = oauth2.create_token( - grant_type = '<GRANT_TYPE>', - code = '<CODE>', # optional - refresh_token = '<REFRESH_TOKEN>', # optional - device_code = '<DEVICE_CODE>', # optional - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - code_verifier = '<CODE_VERIFIER>', # optional - redirect_uri = 'https://example.com', # optional - resource = [], # optional - audience = '<AUDIENCE>' # optional -) - -print(result.model_dump()) + +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2Token = await oauth2.create_token( + grant_type = '<GRANT_TYPE>', + code = '<CODE>', # optional + refresh_token = '<REFRESH_TOKEN>', # optional + device_code = '<DEVICE_CODE>', # optional + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + code_verifier = '<CODE_VERIFIER>', # optional + redirect_uri = 'https://example.com', # optional + resource = [], # optional + audience = '<AUDIENCE>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index 77de5ec2..8b2ad3a5 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2Grant -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -oauth2 = Oauth2(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2Grant = await oauth2.get_grant( + grant_id = '<GRANT_ID>' + ) + + print(result.model_dump()) -result: Oauth2Grant = oauth2.get_grant( - grant_id = '<GRANT_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/introspect.md b/docs/examples/oauth2/introspect.md index bde9da87..a667faa2 100644 --- a/docs/examples/oauth2/introspect.md +++ b/docs/examples/oauth2/introspect.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2Introspection -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 -oauth2 = Oauth2(client) +async def main(): + 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 + + oauth2 = Oauth2(client) + + result: Oauth2Introspection = await oauth2.introspect( + token = '<TOKEN>', + token_type_hint = 'access_token', # optional + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>' # optional + ) + + print(result.model_dump()) -result: Oauth2Introspection = oauth2.introspect( - token = '<TOKEN>', - token_type_hint = 'access_token', # optional - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index 5c429e96..bce89f18 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2OrganizationList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -oauth2 = Oauth2(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2OrganizationList = await oauth2.list_organizations( + limit = 1, # optional + offset = 0, # optional + search = '<SEARCH>' # optional + ) + + print(result.model_dump()) -result: Oauth2OrganizationList = oauth2.list_organizations( - limit = 1, # optional - offset = 0, # optional - search = '<SEARCH>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index b6b45f74..1834b535 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2ProjectList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -oauth2 = Oauth2(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2ProjectList = await oauth2.list_projects( + limit = 1, # optional + offset = 0, # optional + search = '<SEARCH>' # optional + ) + + print(result.model_dump()) -result: Oauth2ProjectList = oauth2.list_projects( - limit = 1, # optional - offset = 0, # optional - search = '<SEARCH>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index 1979d517..602b7a4f 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 from appwrite.models import Oauth2Reject -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -oauth2 = Oauth2(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result: Oauth2Reject = await oauth2.reject( + grant_id = '<GRANT_ID>' + ) + + print(result.model_dump()) -result: Oauth2Reject = oauth2.reject( - grant_id = '<GRANT_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index f351c771..1eb83a63 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.oauth2 import Oauth2 -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -oauth2 = Oauth2(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + oauth2 = Oauth2(client) + + result = await oauth2.revoke( + token = '<TOKEN>', + token_type_hint = 'access_token', # optional + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>' # optional + ) + -result = oauth2.revoke( - token = '<TOKEN>', - token_type_hint = 'access_token', # optional - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/create-ephemeral-project-key.md b/docs/examples/organization/create-ephemeral-project-key.md index 1762acd3..18b3ccb8 100644 --- a/docs/examples/organization/create-ephemeral-project-key.md +++ b/docs/examples/organization/create-ephemeral-project-key.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import EphemeralKey from appwrite.enums.project_key_scopes import ProjectKeyScopes -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: EphemeralKey = await organization.create_ephemeral_project_key( + project_id = '<PROJECT_ID>', + scopes = [ProjectKeyScopes.USERS_READ], + duration = 600 + ) + + print(result.model_dump()) -result: EphemeralKey = organization.create_ephemeral_project_key( - project_id = '<PROJECT_ID>', - scopes = [ProjectKeyScopes.USERS_READ], - duration = 600 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/create-installation.md b/docs/examples/organization/create-installation.md index c7af602a..ccfc8158 100644 --- a/docs/examples/organization/create-installation.md +++ b/docs/examples/organization/create-installation.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import AppInstallation -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -organization = Organization(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + organization = Organization(client) + + result: AppInstallation = await organization.create_installation( + app_id = '<APP_ID>', + authorization_details = '<AUTHORIZATION_DETAILS>' # optional + ) + + print(result.model_dump()) -result: AppInstallation = organization.create_installation( - app_id = '<APP_ID>', - authorization_details = '<AUTHORIZATION_DETAILS>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/create-membership.md b/docs/examples/organization/create-membership.md index 0801bdd7..735d93ff 100644 --- a/docs/examples/organization/create-membership.md +++ b/docs/examples/organization/create-membership.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Membership -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: Membership = await organization.create_membership( + roles = [], + email = 'email@example.com', # optional + user_id = '<USER_ID>', # optional + phone = '+12065550100', # optional + url = 'https://example.com', # optional + name = '<NAME>' # optional + ) + + print(result.model_dump()) -result: Membership = organization.create_membership( - roles = [], - email = 'email@example.com', # optional - user_id = '<USER_ID>', # optional - phone = '+12065550100', # optional - url = 'https://example.com', # optional - name = '<NAME>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/create-project.md b/docs/examples/organization/create-project.md index 6d66e4cc..539e9442 100644 --- a/docs/examples/organization/create-project.md +++ b/docs/examples/organization/create-project.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Project from appwrite.enums.region import Region -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: Project = await organization.create_project( + project_id = '<PROJECT_ID>', + name = '<NAME>', + region = Region.FRA # optional + ) + + print(result.model_dump()) -result: Project = organization.create_project( - project_id = '<PROJECT_ID>', - name = '<NAME>', - region = Region.FRA # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/delete-installation.md b/docs/examples/organization/delete-installation.md index 82790282..f6a28ce2 100644 --- a/docs/examples/organization/delete-installation.md +++ b/docs/examples/organization/delete-installation.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -organization = Organization(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + organization = Organization(client) + + result = await organization.delete_installation( + installation_id = '<INSTALLATION_ID>' + ) + -result = organization.delete_installation( - installation_id = '<INSTALLATION_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/delete-membership.md b/docs/examples/organization/delete-membership.md index dee81d19..699d8958 100644 --- a/docs/examples/organization/delete-membership.md +++ b/docs/examples/organization/delete-membership.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result = await organization.delete_membership( + membership_id = '<MEMBERSHIP_ID>' + ) + -result = organization.delete_membership( - membership_id = '<MEMBERSHIP_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/delete-project-key.md b/docs/examples/organization/delete-project-key.md index 060c6fd4..75d647f1 100644 --- a/docs/examples/organization/delete-project-key.md +++ b/docs/examples/organization/delete-project-key.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result = await organization.delete_project_key( + project_id = '<PROJECT_ID>', + key_id = '<KEY_ID>' + ) + -result = organization.delete_project_key( - project_id = '<PROJECT_ID>', - key_id = '<KEY_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/delete-project.md b/docs/examples/organization/delete-project.md index 024c03e8..f1920a4d 100644 --- a/docs/examples/organization/delete-project.md +++ b/docs/examples/organization/delete-project.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result = await organization.delete_project( + project_id = '<PROJECT_ID>' + ) + -result = organization.delete_project( - project_id = '<PROJECT_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/delete.md b/docs/examples/organization/delete.md index 94b7c2a7..5e6f3fbd 100644 --- a/docs/examples/organization/delete.md +++ b/docs/examples/organization/delete.md @@ -1,13 +1,20 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result = await organization.delete() + -result = organization.delete() +asyncio.run(main()) ``` diff --git a/docs/examples/organization/get-installation.md b/docs/examples/organization/get-installation.md index 0bd78a30..a18b69b1 100644 --- a/docs/examples/organization/get-installation.md +++ b/docs/examples/organization/get-installation.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import AppInstallation -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -organization = Organization(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + organization = Organization(client) + + result: AppInstallation = await organization.get_installation( + installation_id = '<INSTALLATION_ID>' + ) + + print(result.model_dump()) -result: AppInstallation = organization.get_installation( - installation_id = '<INSTALLATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/get-membership.md b/docs/examples/organization/get-membership.md index b3fcd9de..82f52dc0 100644 --- a/docs/examples/organization/get-membership.md +++ b/docs/examples/organization/get-membership.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Membership -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: Membership = await organization.get_membership( + membership_id = '<MEMBERSHIP_ID>' + ) + + print(result.model_dump()) -result: Membership = organization.get_membership( - membership_id = '<MEMBERSHIP_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/get-project-key.md b/docs/examples/organization/get-project-key.md index 841e3817..62a0cfae 100644 --- a/docs/examples/organization/get-project-key.md +++ b/docs/examples/organization/get-project-key.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Key -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: Key = await organization.get_project_key( + project_id = '<PROJECT_ID>', + key_id = '<KEY_ID>' + ) + + print(result.model_dump()) -result: Key = organization.get_project_key( - project_id = '<PROJECT_ID>', - key_id = '<KEY_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/get-project.md b/docs/examples/organization/get-project.md index f0d74fd1..e0889693 100644 --- a/docs/examples/organization/get-project.md +++ b/docs/examples/organization/get-project.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Project -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: Project = await organization.get_project( + project_id = '<PROJECT_ID>' + ) + + print(result.model_dump()) -result: Project = organization.get_project( - project_id = '<PROJECT_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/get.md b/docs/examples/organization/get.md index b99b6a7f..d6f87501 100644 --- a/docs/examples/organization/get.md +++ b/docs/examples/organization/get.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Organization as OrganizationModel -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: OrganizationModel = await organization.get() + + print(result.model_dump()) -result: OrganizationModel = organization.get() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/list-installations.md b/docs/examples/organization/list-installations.md index c2ebe4e8..36e52702 100644 --- a/docs/examples/organization/list-installations.md +++ b/docs/examples/organization/list-installations.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import AppInstallationList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -organization = Organization(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + organization = Organization(client) + + result: AppInstallationList = await organization.list_installations( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: AppInstallationList = organization.list_installations( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/list-memberships.md b/docs/examples/organization/list-memberships.md index e49e1793..208184b1 100644 --- a/docs/examples/organization/list-memberships.md +++ b/docs/examples/organization/list-memberships.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import MembershipList -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: MembershipList = await organization.list_memberships( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: MembershipList = organization.list_memberships( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/list-project-keys.md b/docs/examples/organization/list-project-keys.md index c09c02cd..47a1be63 100644 --- a/docs/examples/organization/list-project-keys.md +++ b/docs/examples/organization/list-project-keys.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import KeyList -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: KeyList = await organization.list_project_keys( + project_id = '<PROJECT_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: KeyList = organization.list_project_keys( - project_id = '<PROJECT_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/list-projects.md b/docs/examples/organization/list-projects.md index 42b902ea..4a322ebb 100644 --- a/docs/examples/organization/list-projects.md +++ b/docs/examples/organization/list-projects.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import ProjectList -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: ProjectList = await organization.list_projects( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: ProjectList = organization.list_projects( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/update-installation.md b/docs/examples/organization/update-installation.md index ab8301b2..707c6104 100644 --- a/docs/examples/organization/update-installation.md +++ b/docs/examples/organization/update-installation.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import AppInstallation -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -organization = Organization(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + organization = Organization(client) + + result: AppInstallation = await organization.update_installation( + installation_id = '<INSTALLATION_ID>', + authorization_details = '<AUTHORIZATION_DETAILS>' # optional + ) + + print(result.model_dump()) -result: AppInstallation = organization.update_installation( - installation_id = '<INSTALLATION_ID>', - authorization_details = '<AUTHORIZATION_DETAILS>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/update-membership.md b/docs/examples/organization/update-membership.md index a4f9c5a0..ed03ee31 100644 --- a/docs/examples/organization/update-membership.md +++ b/docs/examples/organization/update-membership.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Membership -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: Membership = await organization.update_membership( + membership_id = '<MEMBERSHIP_ID>', + roles = [] + ) + + print(result.model_dump()) -result: Membership = organization.update_membership( - membership_id = '<MEMBERSHIP_ID>', - roles = [] -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/update-project-key.md b/docs/examples/organization/update-project-key.md index ea537952..f43b0000 100644 --- a/docs/examples/organization/update-project-key.md +++ b/docs/examples/organization/update-project-key.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Key from appwrite.enums.project_key_scopes import ProjectKeyScopes -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: Key = await organization.update_project_key( + project_id = '<PROJECT_ID>', + key_id = '<KEY_ID>', + name = '<NAME>', + scopes = [ProjectKeyScopes.USERS_READ], + expire = '2020-10-15T06:38:00.000+00:00', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: Key = organization.update_project_key( - project_id = '<PROJECT_ID>', - key_id = '<KEY_ID>', - name = '<NAME>', - scopes = [ProjectKeyScopes.USERS_READ], - expire = '2020-10-15T06:38:00.000+00:00', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/update-project.md b/docs/examples/organization/update-project.md index c14fd0cc..1f942117 100644 --- a/docs/examples/organization/update-project.md +++ b/docs/examples/organization/update-project.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Project -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: Project = await organization.update_project( + project_id = '<PROJECT_ID>', + name = '<NAME>' + ) + + print(result.model_dump()) -result: Project = organization.update_project( - project_id = '<PROJECT_ID>', - name = '<NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/organization/update.md b/docs/examples/organization/update.md index 6d456c57..83b0dd3b 100644 --- a/docs/examples/organization/update.md +++ b/docs/examples/organization/update.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.organization import Organization from appwrite.models import Organization as OrganizationModel -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 -organization = Organization(client) +async def main(): + 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 + + organization = Organization(client) + + result: OrganizationModel = await organization.update( + name = '<NAME>' + ) + + print(result.model_dump()) -result: OrganizationModel = organization.update( - name = '<NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create-backup-policy.md b/docs/examples/postgresql/create-backup-policy.md index bb57ff35..cf12e08e 100644 --- a/docs/examples/postgresql/create-backup-policy.md +++ b/docs/examples/postgresql/create-backup-policy.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import BackupPolicy -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: BackupPolicy = await postgresql.create_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>', + name = '<NAME>', + schedule = '', + retention = 1, + type = 'full', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: BackupPolicy = postgresql.create_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>', - name = '<NAME>', - schedule = '', - retention = 1, - type = 'full', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create-backup.md b/docs/examples/postgresql/create-backup.md index 6123727a..a01ad8d1 100644 --- a/docs/examples/postgresql/create-backup.md +++ b/docs/examples/postgresql/create-backup.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseBackup -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseBackup = await postgresql.create_backup( + database_id = '<DATABASE_ID>', + type = 'full' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseBackup = postgresql.create_backup( - database_id = '<DATABASE_ID>', - type = 'full' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create-branch.md b/docs/examples/postgresql/create-branch.md index bccd70af..f2a5a1d6 100644 --- a/docs/examples/postgresql/create-branch.md +++ b/docs/examples/postgresql/create-branch.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.create_branch( + database_id = '<DATABASE_ID>', + branch_id = '<BRANCH_ID>', # optional + ttl = 300 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = postgresql.create_branch( - database_id = '<DATABASE_ID>', - branch_id = '<BRANCH_ID>', # optional - ttl = 300 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create-execution.md b/docs/examples/postgresql/create-execution.md index 4d27ed20..57330353 100644 --- a/docs/examples/postgresql/create-execution.md +++ b/docs/examples/postgresql/create-execution.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseExecution -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseExecution = await postgresql.create_execution( + database_id = '<DATABASE_ID>', + sql = '<SQL>', + bindings = {}, # optional + timeout_seconds = 1 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseExecution = postgresql.create_execution( - database_id = '<DATABASE_ID>', - sql = '<SQL>', - bindings = {}, # optional - timeout_seconds = 1 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create-extension.md b/docs/examples/postgresql/create-extension.md index 507d8968..4c3eb157 100644 --- a/docs/examples/postgresql/create-extension.md +++ b/docs/examples/postgresql/create-extension.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.create_extension( + database_id = '<DATABASE_ID>', + name = '<NAME>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = postgresql.create_extension( - database_id = '<DATABASE_ID>', - name = '<NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create-failover.md b/docs/examples/postgresql/create-failover.md index 7610a502..03958571 100644 --- a/docs/examples/postgresql/create-failover.md +++ b/docs/examples/postgresql/create-failover.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.create_failover( + database_id = '<DATABASE_ID>', + target_replica_id = '<TARGET_REPLICA_ID>' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = postgresql.create_failover( - database_id = '<DATABASE_ID>', - target_replica_id = '<TARGET_REPLICA_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create-migration.md b/docs/examples/postgresql/create-migration.md index 339e4e6e..d0efa2be 100644 --- a/docs/examples/postgresql/create-migration.md +++ b/docs/examples/postgresql/create-migration.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.create_migration( + database_id = '<DATABASE_ID>', + target_type = 'shared', + specification = '<SPECIFICATION>' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = postgresql.create_migration( - database_id = '<DATABASE_ID>', - target_type = 'shared', - specification = '<SPECIFICATION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index b3b5a076..765b7dae 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseRestoration -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 - -postgresql = Postgresql(client) - -result: DedicatedDatabaseRestoration = postgresql.create_restoration( - database_id = '<DATABASE_ID>', - type = 'backup', # optional - backup_id = '<BACKUP_ID>', # optional - target_database_id = '<TARGET_DATABASE_ID>', # optional - target_time = '2020-10-15T06:38:00.000+00:00', # optional - restore_mode = 'in_place', # optional - target_name = '<TARGET_NAME>', # optional - auto_promote = False # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseRestoration = await postgresql.create_restoration( + database_id = '<DATABASE_ID>', + type = 'backup', # optional + backup_id = '<BACKUP_ID>', # optional + target_database_id = '<TARGET_DATABASE_ID>', # optional + target_time = '2020-10-15T06:38:00.000+00:00', # optional + restore_mode = 'in_place', # optional + target_name = '<TARGET_NAME>', # optional + auto_promote = False # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create-upgrade.md b/docs/examples/postgresql/create-upgrade.md index 9bbbcb90..593a3cfe 100644 --- a/docs/examples/postgresql/create-upgrade.md +++ b/docs/examples/postgresql/create-upgrade.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.create_upgrade( + database_id = '<DATABASE_ID>', + target_version = '<TARGET_VERSION>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = postgresql.create_upgrade( - database_id = '<DATABASE_ID>', - target_version = '<TARGET_VERSION>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/create.md b/docs/examples/postgresql/create.md index 5f1fd90f..63aefb27 100644 --- a/docs/examples/postgresql/create.md +++ b/docs/examples/postgresql/create.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 - -postgresql = Postgresql(client) - -result: DedicatedDatabase = postgresql.create( - database_id = '<DATABASE_ID>', - name = '<NAME>', - version = '17', # optional - specification = '<SPECIFICATION>', # optional - replicas = 0, # optional - sync_mode = 'async', # optional - network_idle_timeout_seconds = 60, # optional - network_ip_allowlist = [], # optional - idle_timeout_minutes = 5, # optional - pitr = False, # optional - pitr_retention_days = 1, # optional - storage_autoscaling = False, # optional - storage_autoscaling_threshold_percent = 50, # optional - storage_autoscaling_max_gb = 0 # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.create( + database_id = '<DATABASE_ID>', + name = '<NAME>', + version = '17', # optional + specification = '<SPECIFICATION>', # optional + replicas = 0, # optional + sync_mode = 'async', # optional + network_idle_timeout_seconds = 60, # optional + network_ip_allowlist = [], # optional + idle_timeout_minutes = 5, # optional + pitr = False, # optional + pitr_retention_days = 1, # optional + storage_autoscaling = False, # optional + storage_autoscaling_threshold_percent = 50, # optional + storage_autoscaling_max_gb = 0 # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/delete-backup-policy.md b/docs/examples/postgresql/delete-backup-policy.md index ea285c36..84744e59 100644 --- a/docs/examples/postgresql/delete-backup-policy.md +++ b/docs/examples/postgresql/delete-backup-policy.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result = await postgresql.delete_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>' + ) + -result = postgresql.delete_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/delete-backup.md b/docs/examples/postgresql/delete-backup.md index f4092c31..26d9273d 100644 --- a/docs/examples/postgresql/delete-backup.md +++ b/docs/examples/postgresql/delete-backup.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result = await postgresql.delete_backup( + database_id = '<DATABASE_ID>', + backup_id = '<BACKUP_ID>' + ) + -result = postgresql.delete_backup( - database_id = '<DATABASE_ID>', - backup_id = '<BACKUP_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/delete-branch.md b/docs/examples/postgresql/delete-branch.md index 1c86002d..ed006c60 100644 --- a/docs/examples/postgresql/delete-branch.md +++ b/docs/examples/postgresql/delete-branch.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.delete_branch( + database_id = '<DATABASE_ID>', + branch_id = '<BRANCH_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = postgresql.delete_branch( - database_id = '<DATABASE_ID>', - branch_id = '<BRANCH_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/delete-extension.md b/docs/examples/postgresql/delete-extension.md index f6b09773..9b4fa50e 100644 --- a/docs/examples/postgresql/delete-extension.md +++ b/docs/examples/postgresql/delete-extension.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.delete_extension( + database_id = '<DATABASE_ID>', + extension_name = '<EXTENSION_NAME>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = postgresql.delete_extension( - database_id = '<DATABASE_ID>', - extension_name = '<EXTENSION_NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/delete.md b/docs/examples/postgresql/delete.md index 3b40a6ce..00031f4b 100644 --- a/docs/examples/postgresql/delete.md +++ b/docs/examples/postgresql/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result = await postgresql.delete( + database_id = '<DATABASE_ID>' + ) + -result = postgresql.delete( - database_id = '<DATABASE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/get-backup-policy.md b/docs/examples/postgresql/get-backup-policy.md index cd1b9445..cebc2aff 100644 --- a/docs/examples/postgresql/get-backup-policy.md +++ b/docs/examples/postgresql/get-backup-policy.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import BackupPolicy -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: BackupPolicy = await postgresql.get_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>' + ) + + print(result.model_dump()) -result: BackupPolicy = postgresql.get_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/get-backup.md b/docs/examples/postgresql/get-backup.md index 8f226ce4..10e7125b 100644 --- a/docs/examples/postgresql/get-backup.md +++ b/docs/examples/postgresql/get-backup.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseBackup -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseBackup = await postgresql.get_backup( + database_id = '<DATABASE_ID>', + backup_id = '<BACKUP_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseBackup = postgresql.get_backup( - database_id = '<DATABASE_ID>', - backup_id = '<BACKUP_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/get-pitr.md b/docs/examples/postgresql/get-pitr.md index 2c845234..6b989fef 100644 --- a/docs/examples/postgresql/get-pitr.md +++ b/docs/examples/postgresql/get-pitr.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabasePITRWindows -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabasePITRWindows = await postgresql.get_pitr( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabasePITRWindows = postgresql.get_pitr( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/get-pooler.md b/docs/examples/postgresql/get-pooler.md index 3cdfbffb..bf130eda 100644 --- a/docs/examples/postgresql/get-pooler.md +++ b/docs/examples/postgresql/get-pooler.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabasePooler -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabasePooler = await postgresql.get_pooler( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabasePooler = postgresql.get_pooler( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/get-replicas.md b/docs/examples/postgresql/get-replicas.md index e4401f4c..1945348b 100644 --- a/docs/examples/postgresql/get-replicas.md +++ b/docs/examples/postgresql/get-replicas.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseReplicas -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseReplicas = await postgresql.get_replicas( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseReplicas = postgresql.get_replicas( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/get-restoration.md b/docs/examples/postgresql/get-restoration.md index 1fb8c412..058e4671 100644 --- a/docs/examples/postgresql/get-restoration.md +++ b/docs/examples/postgresql/get-restoration.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseRestoration -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseRestoration = await postgresql.get_restoration( + database_id = '<DATABASE_ID>', + restoration_id = '<RESTORATION_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseRestoration = postgresql.get_restoration( - database_id = '<DATABASE_ID>', - restoration_id = '<RESTORATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/get-status.md b/docs/examples/postgresql/get-status.md index 6326f201..10b60398 100644 --- a/docs/examples/postgresql/get-status.md +++ b/docs/examples/postgresql/get-status.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DatabaseStatus -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DatabaseStatus = await postgresql.get_status( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DatabaseStatus = postgresql.get_status( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/get.md b/docs/examples/postgresql/get.md index 02c21de9..d74bebf4 100644 --- a/docs/examples/postgresql/get.md +++ b/docs/examples/postgresql/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.get( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabase = postgresql.get( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/list-backup-policies.md b/docs/examples/postgresql/list-backup-policies.md index 2c10f860..07b25afc 100644 --- a/docs/examples/postgresql/list-backup-policies.md +++ b/docs/examples/postgresql/list-backup-policies.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import BackupPolicyList -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: BackupPolicyList = await postgresql.list_backup_policies( + database_id = '<DATABASE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: BackupPolicyList = postgresql.list_backup_policies( - database_id = '<DATABASE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/list-backups.md b/docs/examples/postgresql/list-backups.md index ea05800f..2b84ac7a 100644 --- a/docs/examples/postgresql/list-backups.md +++ b/docs/examples/postgresql/list-backups.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseBackupList -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseBackupList = await postgresql.list_backups( + database_id = '<DATABASE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseBackupList = postgresql.list_backups( - database_id = '<DATABASE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/list-branches.md b/docs/examples/postgresql/list-branches.md index 84f99a84..068612d3 100644 --- a/docs/examples/postgresql/list-branches.md +++ b/docs/examples/postgresql/list-branches.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseBranchList -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseBranchList = await postgresql.list_branches( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseBranchList = postgresql.list_branches( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/list-extensions.md b/docs/examples/postgresql/list-extensions.md index c97c0e3d..19d4d082 100644 --- a/docs/examples/postgresql/list-extensions.md +++ b/docs/examples/postgresql/list-extensions.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseExtensions -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseExtensions = await postgresql.list_extensions( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseExtensions = postgresql.list_extensions( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/list-operations.md b/docs/examples/postgresql/list-operations.md index 3575a11d..a15643d5 100644 --- a/docs/examples/postgresql/list-operations.md +++ b/docs/examples/postgresql/list-operations.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseOperationList -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseOperationList = await postgresql.list_operations( + database_id = '<DATABASE_ID>', + status = 'queued', # optional + limit = 1, # optional + offset = 0 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseOperationList = postgresql.list_operations( - database_id = '<DATABASE_ID>', - status = 'queued', # optional - limit = 1, # optional - offset = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/list-restorations.md b/docs/examples/postgresql/list-restorations.md index 0e70f74b..4ef98863 100644 --- a/docs/examples/postgresql/list-restorations.md +++ b/docs/examples/postgresql/list-restorations.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseRestorationList -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseRestorationList = await postgresql.list_restorations( + database_id = '<DATABASE_ID>', + status = 'pending', # optional + type = 'backup', # optional + limit = 1, # optional + offset = 0 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseRestorationList = postgresql.list_restorations( - database_id = '<DATABASE_ID>', - status = 'pending', # optional - type = 'backup', # optional - limit = 1, # optional - offset = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/list-specifications.md b/docs/examples/postgresql/list-specifications.md index c49fdb2e..5f5ac776 100644 --- a/docs/examples/postgresql/list-specifications.md +++ b/docs/examples/postgresql/list-specifications.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseSpecificationList -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseSpecificationList = await postgresql.list_specifications() + + print(result.model_dump()) -result: DedicatedDatabaseSpecificationList = postgresql.list_specifications() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/list.md b/docs/examples/postgresql/list.md index 41d53428..a1609519 100644 --- a/docs/examples/postgresql/list.md +++ b/docs/examples/postgresql/list.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseList -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseList = await postgresql.list( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseList = postgresql.list( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/promote-restoration.md b/docs/examples/postgresql/promote-restoration.md index b280f20c..353e2f6c 100644 --- a/docs/examples/postgresql/promote-restoration.md +++ b/docs/examples/postgresql/promote-restoration.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseRestoration -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseRestoration = await postgresql.promote_restoration( + database_id = '<DATABASE_ID>', + restoration_id = '<RESTORATION_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseRestoration = postgresql.promote_restoration( - database_id = '<DATABASE_ID>', - restoration_id = '<RESTORATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/update-backup-policy.md b/docs/examples/postgresql/update-backup-policy.md index 02fac735..268740e1 100644 --- a/docs/examples/postgresql/update-backup-policy.md +++ b/docs/examples/postgresql/update-backup-policy.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import BackupPolicy -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: BackupPolicy = await postgresql.update_backup_policy( + database_id = '<DATABASE_ID>', + policy_id = '<POLICY_ID>', + name = '<NAME>', # optional + schedule = '', # optional + retention = 1, # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: BackupPolicy = postgresql.update_backup_policy( - database_id = '<DATABASE_ID>', - policy_id = '<POLICY_ID>', - name = '<NAME>', # optional - schedule = '', # optional - retention = 1, # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/update-backup-storage.md b/docs/examples/postgresql/update-backup-storage.md index d0431b4a..ded61328 100644 --- a/docs/examples/postgresql/update-backup-storage.md +++ b/docs/examples/postgresql/update-backup-storage.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseBackupStorage -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 - -postgresql = Postgresql(client) - -result: DedicatedDatabaseBackupStorage = postgresql.update_backup_storage( - database_id = '<DATABASE_ID>', - provider = 's3', - bucket = '<BUCKET>', - access_key = '<ACCESS_KEY>', - secret_key = '<SECRET_KEY>', - region = '<REGION>', # optional - prefix = '<PREFIX>', # optional - endpoint = '<ENDPOINT>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseBackupStorage = await postgresql.update_backup_storage( + database_id = '<DATABASE_ID>', + provider = 's3', + bucket = '<BUCKET>', + access_key = '<ACCESS_KEY>', + secret_key = '<SECRET_KEY>', + region = '<REGION>', # optional + prefix = '<PREFIX>', # optional + endpoint = '<ENDPOINT>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/update-credentials.md b/docs/examples/postgresql/update-credentials.md index 7f7b5990..fd97b438 100644 --- a/docs/examples/postgresql/update-credentials.md +++ b/docs/examples/postgresql/update-credentials.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabaseOperation -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabaseOperation = await postgresql.update_credentials( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseOperation = postgresql.update_credentials( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/update-maintenance.md b/docs/examples/postgresql/update-maintenance.md index 4795124e..dcd48f3c 100644 --- a/docs/examples/postgresql/update-maintenance.md +++ b/docs/examples/postgresql/update-maintenance.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 -postgresql = Postgresql(client) +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.update_maintenance( + database_id = '<DATABASE_ID>', + day = 'sun', + hour_utc = 0 + ) + + print(result.model_dump()) -result: DedicatedDatabase = postgresql.update_maintenance( - database_id = '<DATABASE_ID>', - day = 'sun', - hour_utc = 0 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/update-pooler.md b/docs/examples/postgresql/update-pooler.md index 1f46df6d..921dfe48 100644 --- a/docs/examples/postgresql/update-pooler.md +++ b/docs/examples/postgresql/update-pooler.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabasePooler -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 - -postgresql = Postgresql(client) - -result: DedicatedDatabasePooler = postgresql.update_pooler( - database_id = '<DATABASE_ID>', - mode = 'transaction', # optional - max_connections = 10, # optional - default_pool_size = 1, # optional - read_write_splitting = False, # optional - pooler_cpu_request = '<POOLER_CPU_REQUEST>', # optional - pooler_cpu_limit = '<POOLER_CPU_LIMIT>', # optional - pooler_memory_request = '<POOLER_MEMORY_REQUEST>', # optional - pooler_memory_limit = '<POOLER_MEMORY_LIMIT>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabasePooler = await postgresql.update_pooler( + database_id = '<DATABASE_ID>', + mode = 'transaction', # optional + max_connections = 10, # optional + default_pool_size = 1, # optional + read_write_splitting = False, # optional + pooler_cpu_request = '<POOLER_CPU_REQUEST>', # optional + pooler_cpu_limit = '<POOLER_CPU_LIMIT>', # optional + pooler_memory_request = '<POOLER_MEMORY_REQUEST>', # optional + pooler_memory_limit = '<POOLER_MEMORY_LIMIT>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/postgresql/update.md b/docs/examples/postgresql/update.md index b6e8ac48..8b2d8cbe 100644 --- a/docs/examples/postgresql/update.md +++ b/docs/examples/postgresql/update.md @@ -1,38 +1,45 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.postgresql import Postgresql from appwrite.models import DedicatedDatabase -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 - -postgresql = Postgresql(client) - -result: DedicatedDatabase = postgresql.update( - database_id = '<DATABASE_ID>', - name = '<NAME>', # optional - status = 'ready', # optional - specification = '<SPECIFICATION>', # optional - replicas = 0, # optional - sync_mode = 'async', # optional - network_idle_timeout_seconds = 60, # optional - network_ip_allowlist = [], # optional - idle_timeout_minutes = 5, # optional - pitr = False, # optional - pitr_retention_days = 1, # optional - storage_autoscaling = False, # optional - storage_autoscaling_threshold_percent = 50, # optional - storage_autoscaling_max_gb = 0, # optional - metrics_trace_sample_rate = None, # optional - metrics_slow_query_log_threshold_ms = 0, # optional - sql_api_enabled = False, # optional - sql_api_allowed_statements = [], # optional - sql_api_max_rows = 1, # optional - sql_api_max_bytes = 1024, # optional - sql_api_timeout_seconds = 1 # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + postgresql = Postgresql(client) + + result: DedicatedDatabase = await postgresql.update( + database_id = '<DATABASE_ID>', + name = '<NAME>', # optional + status = 'ready', # optional + specification = '<SPECIFICATION>', # optional + replicas = 0, # optional + sync_mode = 'async', # optional + network_idle_timeout_seconds = 60, # optional + network_ip_allowlist = [], # optional + idle_timeout_minutes = 5, # optional + pitr = False, # optional + pitr_retention_days = 1, # optional + storage_autoscaling = False, # optional + storage_autoscaling_threshold_percent = 50, # optional + storage_autoscaling_max_gb = 0, # optional + metrics_trace_sample_rate = None, # optional + metrics_slow_query_log_threshold_ms = 0, # optional + sql_api_enabled = False, # optional + sql_api_allowed_statements = [], # optional + sql_api_max_rows = 1, # optional + sql_api_max_bytes = 1024, # optional + sql_api_timeout_seconds = 1 # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/presences/delete.md b/docs/examples/presences/delete.md index ca4ba660..56b6b355 100644 --- a/docs/examples/presences/delete.md +++ b/docs/examples/presences/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.presences import Presences -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 -presences = Presences(client) +async def main(): + 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 + + presences = Presences(client) + + result = await presences.delete( + presence_id = '<PRESENCE_ID>' + ) + -result = presences.delete( - presence_id = '<PRESENCE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/presences/get.md b/docs/examples/presences/get.md index 2c57df09..c9452649 100644 --- a/docs/examples/presences/get.md +++ b/docs/examples/presences/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.presences import Presences from appwrite.models import Presence -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 -presences = Presences(client) +async def main(): + 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 + + presences = Presences(client) + + result: Presence = await presences.get( + presence_id = '<PRESENCE_ID>' + ) + + print(result.model_dump()) -result: Presence = presences.get( - presence_id = '<PRESENCE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/presences/list.md b/docs/examples/presences/list.md index a0349285..08f7e0fe 100644 --- a/docs/examples/presences/list.md +++ b/docs/examples/presences/list.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.presences import Presences from appwrite.models import PresenceList -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 -presences = Presences(client) +async def main(): + 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 + + presences = Presences(client) + + result: PresenceList = await presences.list( + queries = [], # optional + total = False, # optional + ttl = 0 # optional + ) + + print(result.model_dump()) -result: PresenceList = presences.list( - queries = [], # optional - total = False, # optional - ttl = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/presences/update.md b/docs/examples/presences/update.md index fd3a9ef0..b1d56cb6 100644 --- a/docs/examples/presences/update.md +++ b/docs/examples/presences/update.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.presences import Presences from appwrite.models import Presence from appwrite.permission import Permission from appwrite.role import Role -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 -presences = Presences(client) +async def main(): + 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 + + presences = Presences(client) + + result: Presence = await presences.update( + presence_id = '<PRESENCE_ID>', + user_id = '<USER_ID>', + status = '<STATUS>', # optional + expires_at = '2020-10-15T06:38:00.000+00:00', # optional + metadata = {}, # optional + permissions = [Permission.read(Role.any())], # optional + purge = False # optional + ) + + print(result.model_dump()) -result: Presence = presences.update( - presence_id = '<PRESENCE_ID>', - user_id = '<USER_ID>', - status = '<STATUS>', # optional - expires_at = '2020-10-15T06:38:00.000+00:00', # optional - metadata = {}, # optional - permissions = [Permission.read(Role.any())], # optional - purge = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/presences/upsert.md b/docs/examples/presences/upsert.md index 2750434c..ba480bfd 100644 --- a/docs/examples/presences/upsert.md +++ b/docs/examples/presences/upsert.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.presences import Presences from appwrite.models import Presence from appwrite.permission import Permission from appwrite.role import Role -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 -presences = Presences(client) +async def main(): + 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 + + presences = Presences(client) + + result: Presence = await presences.upsert( + presence_id = '<PRESENCE_ID>', + user_id = '<USER_ID>', + status = '<STATUS>', + permissions = [Permission.read(Role.any())], # optional + expires_at = '2020-10-15T06:38:00.000+00:00', # optional + metadata = {} # optional + ) + + print(result.model_dump()) -result: Presence = presences.upsert( - presence_id = '<PRESENCE_ID>', - user_id = '<USER_ID>', - status = '<STATUS>', - permissions = [Permission.read(Role.any())], # optional - expires_at = '2020-10-15T06:38:00.000+00:00', # optional - metadata = {} # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 60e7f73d..85bb28d9 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformAndroid -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformAndroid = await project.create_android_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + application_id = '<APPLICATION_ID>', + fingerprints = [] # optional + ) + + print(result.model_dump()) -result: PlatformAndroid = project.create_android_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - application_id = '<APPLICATION_ID>', - fingerprints = [] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-apple-platform.md b/docs/examples/project/create-apple-platform.md index 3e190d4c..e1b242e0 100644 --- a/docs/examples/project/create-apple-platform.md +++ b/docs/examples/project/create-apple-platform.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformApple -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformApple = await project.create_apple_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + bundle_identifier = '<BUNDLE_IDENTIFIER>' + ) + + print(result.model_dump()) -result: PlatformApple = project.create_apple_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - bundle_identifier = '<BUNDLE_IDENTIFIER>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md index 41dc4bcd..8507c371 100644 --- a/docs/examples/project/create-environment.md +++ b/docs/examples/project/create-environment.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.create_environment( + environment_id = '<ENVIRONMENT_ID>', + name = '<NAME>' + ) + + print(result.model_dump()) -result: ProjectModel = project.create_environment( - environment_id = '<ENVIRONMENT_ID>', - name = '<NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index c2b202ad..38eee439 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import EphemeralKey from appwrite.enums.project_key_scopes import ProjectKeyScopes -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: EphemeralKey = await project.create_ephemeral_key( + scopes = [ProjectKeyScopes.USERS_READ], + duration = 600 + ) + + print(result.model_dump()) -result: EphemeralKey = project.create_ephemeral_key( - scopes = [ProjectKeyScopes.USERS_READ], - duration = 600 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-linux-platform.md b/docs/examples/project/create-linux-platform.md index e1ac1da8..bc95bdf7 100644 --- a/docs/examples/project/create-linux-platform.md +++ b/docs/examples/project/create-linux-platform.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformLinux -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformLinux = await project.create_linux_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + package_name = '<PACKAGE_NAME>' + ) + + print(result.model_dump()) -result: PlatformLinux = project.create_linux_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - package_name = '<PACKAGE_NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-mock-phone.md b/docs/examples/project/create-mock-phone.md index 6ad457df..52529dba 100644 --- a/docs/examples/project/create-mock-phone.md +++ b/docs/examples/project/create-mock-phone.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import MockNumber -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: MockNumber = await project.create_mock_phone( + number = '+12065550100', + otp = '<OTP>' + ) + + print(result.model_dump()) -result: MockNumber = project.create_mock_phone( - number = '+12065550100', - otp = '<OTP>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index e46cb13e..dfeffcc6 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result = await project.create_smtp_test( + emails = ["recipient@example.com"] + ) + -result = project.create_smtp_test( - emails = ["recipient@example.com"] -) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-variable.md b/docs/examples/project/create-variable.md index 4b73077c..6347a76c 100644 --- a/docs/examples/project/create-variable.md +++ b/docs/examples/project/create-variable.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Variable -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: Variable = await project.create_variable( + variable_id = '<VARIABLE_ID>', + key = '<KEY>', + value = '<VALUE>', + secret = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: Variable = project.create_variable( - variable_id = '<VARIABLE_ID>', - key = '<KEY>', - value = '<VALUE>', - secret = False, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-web-platform.md b/docs/examples/project/create-web-platform.md index c92e167b..8ff0b4a3 100644 --- a/docs/examples/project/create-web-platform.md +++ b/docs/examples/project/create-web-platform.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformWeb -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformWeb = await project.create_web_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + hostname = 'app.example.com' + ) + + print(result.model_dump()) -result: PlatformWeb = project.create_web_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - hostname = 'app.example.com' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/create-windows-platform.md b/docs/examples/project/create-windows-platform.md index 5f782144..279b0ca7 100644 --- a/docs/examples/project/create-windows-platform.md +++ b/docs/examples/project/create-windows-platform.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformWindows -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformWindows = await project.create_windows_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + package_identifier_name = '<PACKAGE_IDENTIFIER_NAME>' + ) + + print(result.model_dump()) -result: PlatformWindows = project.create_windows_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - package_identifier_name = '<PACKAGE_IDENTIFIER_NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md index 123c2834..01b1c012 100644 --- a/docs/examples/project/delete-environment.md +++ b/docs/examples/project/delete-environment.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result = await project.delete_environment( + environment_id = '<ENVIRONMENT_ID>' + ) + -result = project.delete_environment( - environment_id = '<ENVIRONMENT_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/project/delete-key.md b/docs/examples/project/delete-key.md index 8af3c0fc..94c439d6 100644 --- a/docs/examples/project/delete-key.md +++ b/docs/examples/project/delete-key.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result = await project.delete_key( + key_id = '<KEY_ID>' + ) + -result = project.delete_key( - key_id = '<KEY_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/project/delete-mock-phone.md b/docs/examples/project/delete-mock-phone.md index 5ce79db5..998137d9 100644 --- a/docs/examples/project/delete-mock-phone.md +++ b/docs/examples/project/delete-mock-phone.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result = await project.delete_mock_phone( + number = '+12065550100' + ) + -result = project.delete_mock_phone( - number = '+12065550100' -) +asyncio.run(main()) ``` diff --git a/docs/examples/project/delete-platform.md b/docs/examples/project/delete-platform.md index 471bb838..cedc7811 100644 --- a/docs/examples/project/delete-platform.md +++ b/docs/examples/project/delete-platform.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result = await project.delete_platform( + platform_id = '<PLATFORM_ID>' + ) + -result = project.delete_platform( - platform_id = '<PLATFORM_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/project/delete-variable.md b/docs/examples/project/delete-variable.md index 89b16d21..f0055ece 100644 --- a/docs/examples/project/delete-variable.md +++ b/docs/examples/project/delete-variable.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result = await project.delete_variable( + variable_id = '<VARIABLE_ID>' + ) + -result = project.delete_variable( - variable_id = '<VARIABLE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/project/delete.md b/docs/examples/project/delete.md index 0c74d311..6fe59d73 100644 --- a/docs/examples/project/delete.md +++ b/docs/examples/project/delete.md @@ -1,13 +1,20 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result = await project.delete() + -result = project.delete() +asyncio.run(main()) ``` diff --git a/docs/examples/project/get-email-template.md b/docs/examples/project/get-email-template.md index 116cc0ae..f3866e88 100644 --- a/docs/examples/project/get-email-template.md +++ b/docs/examples/project/get-email-template.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import EmailTemplate from appwrite.enums.project_email_template_id import ProjectEmailTemplateId from appwrite.enums.project_email_template_locale import ProjectEmailTemplateLocale -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: EmailTemplate = await project.get_email_template( + template_id = ProjectEmailTemplateId.VERIFICATION, + locale = ProjectEmailTemplateLocale.AF # optional + ) + + print(result.model_dump()) -result: EmailTemplate = project.get_email_template( - template_id = ProjectEmailTemplateId.VERIFICATION, - locale = ProjectEmailTemplateLocale.AF # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md index 82082dfb..80081504 100644 --- a/docs/examples/project/get-environment.md +++ b/docs/examples/project/get-environment.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.get_environment( + environment_id = '<ENVIRONMENT_ID>' + ) + + print(result.model_dump()) -result: ProjectModel = project.get_environment( - environment_id = '<ENVIRONMENT_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/get-key.md b/docs/examples/project/get-key.md index 0165746d..1c97dcb9 100644 --- a/docs/examples/project/get-key.md +++ b/docs/examples/project/get-key.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Key -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: Key = await project.get_key( + key_id = '<KEY_ID>' + ) + + print(result.model_dump()) -result: Key = project.get_key( - key_id = '<KEY_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/get-mock-phone.md b/docs/examples/project/get-mock-phone.md index e35dffdd..a8f4af1a 100644 --- a/docs/examples/project/get-mock-phone.md +++ b/docs/examples/project/get-mock-phone.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import MockNumber -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: MockNumber = await project.get_mock_phone( + number = '+12065550100' + ) + + print(result.model_dump()) -result: MockNumber = project.get_mock_phone( - number = '+12065550100' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/get-o-auth-2-provider.md b/docs/examples/project/get-o-auth-2-provider.md index 55a01469..b0d4a557 100644 --- a/docs/examples/project/get-o-auth-2-provider.md +++ b/docs/examples/project/get-o-auth-2-provider.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Github @@ -50,16 +52,21 @@ from appwrite.models import OAuth2Kakao from typing import Union from appwrite.enums.project_o_auth_provider_id import ProjectOAuthProviderId -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2TikTok, OAuth2Kakao] = await project.get_o_auth2_provider( + provider_id = ProjectOAuthProviderId.AMAZON + ) + + print(result.model_dump()) -result: Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2TikTok, OAuth2Kakao] = project.get_o_auth2_provider( - provider_id = ProjectOAuthProviderId.AMAZON -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/get-platform.md b/docs/examples/project/get-platform.md index 2075a706..8e68de6b 100644 --- a/docs/examples/project/get-platform.md +++ b/docs/examples/project/get-platform.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformWeb @@ -8,16 +10,21 @@ from appwrite.models import PlatformWindows from appwrite.models import PlatformLinux from typing import Union -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux] = await project.get_platform( + platform_id = '<PLATFORM_ID>' + ) + + print(result.model_dump()) -result: Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux] = project.get_platform( - platform_id = '<PLATFORM_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/get-policy.md b/docs/examples/project/get-policy.md index 3e746d52..6996d693 100644 --- a/docs/examples/project/get-policy.md +++ b/docs/examples/project/get-policy.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PolicyPasswordDictionary @@ -22,16 +24,21 @@ from appwrite.models import PolicyPasskey from typing import Union from appwrite.enums.project_policy_id import ProjectPolicyId -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicyPasswordPwned, PolicyPasswordRotation, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail, PolicyPasskey] = await project.get_policy( + policy_id = ProjectPolicyId.PASSWORD_DICTIONARY + ) + + print(result.model_dump()) -result: Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicyPasswordPwned, PolicyPasswordRotation, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail, PolicyPasskey] = project.get_policy( - policy_id = ProjectPolicyId.PASSWORD_DICTIONARY -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/get-variable.md b/docs/examples/project/get-variable.md index 9771151a..67fe3797 100644 --- a/docs/examples/project/get-variable.md +++ b/docs/examples/project/get-variable.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Variable -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: Variable = await project.get_variable( + variable_id = '<VARIABLE_ID>' + ) + + print(result.model_dump()) -result: Variable = project.get_variable( - variable_id = '<VARIABLE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/get.md b/docs/examples/project/get.md index ea0046c7..6e6d1e31 100644 --- a/docs/examples/project/get.md +++ b/docs/examples/project/get.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.get() + + print(result.model_dump()) -result: ProjectModel = project.get() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/list-email-templates.md b/docs/examples/project/list-email-templates.md index 293bae73..1c0122e8 100644 --- a/docs/examples/project/list-email-templates.md +++ b/docs/examples/project/list-email-templates.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import EmailTemplateList -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: EmailTemplateList = await project.list_email_templates( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: EmailTemplateList = project.list_email_templates( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md index f414fbea..a2beeffe 100644 --- a/docs/examples/project/list-environments.md +++ b/docs/examples/project/list-environments.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import ProjectList -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectList = await project.list_environments( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: ProjectList = project.list_environments( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/list-keys.md b/docs/examples/project/list-keys.md index e72b20bd..fe324f10 100644 --- a/docs/examples/project/list-keys.md +++ b/docs/examples/project/list-keys.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import KeyList -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: KeyList = await project.list_keys( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: KeyList = project.list_keys( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/list-mock-phones.md b/docs/examples/project/list-mock-phones.md index 6a73776b..810fc5cd 100644 --- a/docs/examples/project/list-mock-phones.md +++ b/docs/examples/project/list-mock-phones.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import MockNumberList -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: MockNumberList = await project.list_mock_phones( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: MockNumberList = project.list_mock_phones( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/list-o-auth-2-providers.md b/docs/examples/project/list-o-auth-2-providers.md index fbe6791a..51a24e65 100644 --- a/docs/examples/project/list-o-auth-2-providers.md +++ b/docs/examples/project/list-o-auth-2-providers.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2ProviderList -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2ProviderList = await project.list_o_auth2_providers( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: OAuth2ProviderList = project.list_o_auth2_providers( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/list-platforms.md b/docs/examples/project/list-platforms.md index 690f7a79..5f489019 100644 --- a/docs/examples/project/list-platforms.md +++ b/docs/examples/project/list-platforms.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformList -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformList = await project.list_platforms( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: PlatformList = project.list_platforms( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/list-policies.md b/docs/examples/project/list-policies.md index e150a3f6..6868625d 100644 --- a/docs/examples/project/list-policies.md +++ b/docs/examples/project/list-policies.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PolicyList -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PolicyList = await project.list_policies( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: PolicyList = project.list_policies( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/list-variables.md b/docs/examples/project/list-variables.md index 4316f7c3..1985a25d 100644 --- a/docs/examples/project/list-variables.md +++ b/docs/examples/project/list-variables.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import VariableList -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: VariableList = await project.list_variables( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: VariableList = project.list_variables( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index 70e179c7..74596dcf 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformAndroid -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformAndroid = await project.update_android_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + application_id = '<APPLICATION_ID>', + fingerprints = [] # optional + ) + + print(result.model_dump()) -result: PlatformAndroid = project.update_android_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - application_id = '<APPLICATION_ID>', - fingerprints = [] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-apple-platform.md b/docs/examples/project/update-apple-platform.md index 33fd9c74..76827c73 100644 --- a/docs/examples/project/update-apple-platform.md +++ b/docs/examples/project/update-apple-platform.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformApple -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformApple = await project.update_apple_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + bundle_identifier = '<BUNDLE_IDENTIFIER>' + ) + + print(result.model_dump()) -result: PlatformApple = project.update_apple_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - bundle_identifier = '<BUNDLE_IDENTIFIER>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-auth-method.md b/docs/examples/project/update-auth-method.md index 4f562960..f78a8be9 100644 --- a/docs/examples/project/update-auth-method.md +++ b/docs/examples/project/update-auth-method.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel from appwrite.enums.project_auth_method_id import ProjectAuthMethodId -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_auth_method( + method_id = ProjectAuthMethodId.EMAIL_PASSWORD, + enabled = False + ) + + print(result.model_dump()) -result: ProjectModel = project.update_auth_method( - method_id = ProjectAuthMethodId.EMAIL_PASSWORD, - enabled = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-deny-aliased-email-policy.md b/docs/examples/project/update-deny-aliased-email-policy.md index 02d1f7d4..dcd31e3a 100644 --- a/docs/examples/project/update-deny-aliased-email-policy.md +++ b/docs/examples/project/update-deny-aliased-email-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_deny_aliased_email_policy( + enabled = False + ) + + print(result.model_dump()) -result: ProjectModel = project.update_deny_aliased_email_policy( - enabled = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-deny-corporate-email-policy.md b/docs/examples/project/update-deny-corporate-email-policy.md index 21f4f8a6..b2e6a4c4 100644 --- a/docs/examples/project/update-deny-corporate-email-policy.md +++ b/docs/examples/project/update-deny-corporate-email-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_deny_corporate_email_policy( + enabled = False + ) + + print(result.model_dump()) -result: ProjectModel = project.update_deny_corporate_email_policy( - enabled = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-deny-disposable-email-policy.md b/docs/examples/project/update-deny-disposable-email-policy.md index 2dbeaf5e..d9443a5c 100644 --- a/docs/examples/project/update-deny-disposable-email-policy.md +++ b/docs/examples/project/update-deny-disposable-email-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_deny_disposable_email_policy( + enabled = False + ) + + print(result.model_dump()) -result: ProjectModel = project.update_deny_disposable_email_policy( - enabled = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-deny-free-email-policy.md b/docs/examples/project/update-deny-free-email-policy.md index e9af632b..f94dd8b7 100644 --- a/docs/examples/project/update-deny-free-email-policy.md +++ b/docs/examples/project/update-deny-free-email-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_deny_free_email_policy( + enabled = False + ) + + print(result.model_dump()) -result: ProjectModel = project.update_deny_free_email_policy( - enabled = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-email-template.md b/docs/examples/project/update-email-template.md index 2c679f24..2e5a27e9 100644 --- a/docs/examples/project/update-email-template.md +++ b/docs/examples/project/update-email-template.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import EmailTemplate from appwrite.enums.project_email_template_id import ProjectEmailTemplateId from appwrite.enums.project_email_template_locale import ProjectEmailTemplateLocale -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 - -project = Project(client) - -result: EmailTemplate = project.update_email_template( - template_id = ProjectEmailTemplateId.VERIFICATION, - locale = ProjectEmailTemplateLocale.AF, # optional - subject = '<SUBJECT>', # optional - message = '<MESSAGE>', # optional - sender_name = '<SENDER_NAME>', # optional - sender_email = 'email@example.com', # optional - reply_to_email = 'email@example.com', # optional - reply_to_name = '<REPLY_TO_NAME>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + project = Project(client) + + result: EmailTemplate = await project.update_email_template( + template_id = ProjectEmailTemplateId.VERIFICATION, + locale = ProjectEmailTemplateLocale.AF, # optional + subject = '<SUBJECT>', # optional + message = '<MESSAGE>', # optional + sender_name = '<SENDER_NAME>', # optional + sender_email = 'email@example.com', # optional + reply_to_email = 'email@example.com', # optional + reply_to_name = '<REPLY_TO_NAME>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md index e4db2999..09860698 100644 --- a/docs/examples/project/update-environment.md +++ b/docs/examples/project/update-environment.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_environment( + environment_id = '<ENVIRONMENT_ID>', + name = '<NAME>' + ) + + print(result.model_dump()) -result: ProjectModel = project.update_environment( - environment_id = '<ENVIRONMENT_ID>', - name = '<NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 12faf365..5139e685 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Key from appwrite.enums.project_key_scopes import ProjectKeyScopes -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: Key = await project.update_key( + key_id = '<KEY_ID>', + name = '<NAME>', + scopes = [ProjectKeyScopes.USERS_READ], + expire = '2020-10-15T06:38:00.000+00:00', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: Key = project.update_key( - key_id = '<KEY_ID>', - name = '<NAME>', - scopes = [ProjectKeyScopes.USERS_READ], - expire = '2020-10-15T06:38:00.000+00:00', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index ed324cad..4851541c 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_labels( + labels = ["production"] + ) + + print(result.model_dump()) -result: ProjectModel = project.update_labels( - labels = ["production"] -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-linux-platform.md b/docs/examples/project/update-linux-platform.md index 66128691..57b528bb 100644 --- a/docs/examples/project/update-linux-platform.md +++ b/docs/examples/project/update-linux-platform.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformLinux -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformLinux = await project.update_linux_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + package_name = '<PACKAGE_NAME>' + ) + + print(result.model_dump()) -result: PlatformLinux = project.update_linux_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - package_name = '<PACKAGE_NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-membership-privacy-policy.md b/docs/examples/project/update-membership-privacy-policy.md index f6878ee4..e65cf368 100644 --- a/docs/examples/project/update-membership-privacy-policy.md +++ b/docs/examples/project/update-membership-privacy-policy.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_membership_privacy_policy( + user_id = False, # optional + user_email = False, # optional + user_phone = False, # optional + user_name = False, # optional + user_mfa = False, # optional + user_accessed_at = False # optional + ) + + print(result.model_dump()) -result: ProjectModel = project.update_membership_privacy_policy( - user_id = False, # optional - user_email = False, # optional - user_phone = False, # optional - user_name = False, # optional - user_mfa = False, # optional - user_accessed_at = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-mfa-factors-policy.md b/docs/examples/project/update-mfa-factors-policy.md index 67f75688..6e52d06a 100644 --- a/docs/examples/project/update-mfa-factors-policy.md +++ b/docs/examples/project/update-mfa-factors-policy.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_mfa_factors_policy( + totp = False, # optional + email = False, # optional + phone = False, # optional + custom = False # optional + ) + + print(result.model_dump()) -result: ProjectModel = project.update_mfa_factors_policy( - totp = False, # optional - email = False, # optional - phone = False, # optional - custom = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-mock-phone.md b/docs/examples/project/update-mock-phone.md index 8a9a96c3..29234549 100644 --- a/docs/examples/project/update-mock-phone.md +++ b/docs/examples/project/update-mock-phone.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import MockNumber -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: MockNumber = await project.update_mock_phone( + number = '+12065550100', + otp = '<OTP>' + ) + + print(result.model_dump()) -result: MockNumber = project.update_mock_phone( - number = '+12065550100', - otp = '<OTP>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-amazon.md b/docs/examples/project/update-o-auth-2-amazon.md index 61459693..c5f0118d 100644 --- a/docs/examples/project/update-o-auth-2-amazon.md +++ b/docs/examples/project/update-o-auth-2-amazon.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Amazon -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Amazon = await project.update_o_auth2_amazon( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Amazon = project.update_o_auth2_amazon( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 6e1a1efb..84d6ddab 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Apple -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Apple = await project.update_o_auth2_apple( + service_id = '<SERVICE_ID>', # optional + key_id = '<KEY_ID>', # optional + team_id = '<TEAM_ID>', # optional + p8_file = '<P8_FILE>', # optional + enabled = False, # optional + native_client_ids = [], # optional + native_enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Apple = project.update_o_auth2_apple( - service_id = '<SERVICE_ID>', # optional - key_id = '<KEY_ID>', # optional - team_id = '<TEAM_ID>', # optional - p8_file = '<P8_FILE>', # optional - enabled = False, # optional - native_client_ids = [], # optional - native_enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-appwrite.md b/docs/examples/project/update-o-auth-2-appwrite.md index 7b765921..be2631cb 100644 --- a/docs/examples/project/update-o-auth-2-appwrite.md +++ b/docs/examples/project/update-o-auth-2-appwrite.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Appwrite -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Appwrite = await project.update_o_auth2_appwrite( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Appwrite = project.update_o_auth2_appwrite( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index 632286f8..2f06014f 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Auth0 from appwrite.enums.project_o_auth2_auth0_prompt import ProjectOAuth2Auth0Prompt -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Auth0 = await project.update_o_auth2_auth0( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + endpoint = '<ENDPOINT>', # optional + enabled = False, # optional + prompt = [ProjectOAuth2Auth0Prompt.NONE] # optional + ) + + print(result.model_dump()) -result: OAuth2Auth0 = project.update_o_auth2_auth0( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - endpoint = '<ENDPOINT>', # optional - enabled = False, # optional - prompt = [ProjectOAuth2Auth0Prompt.NONE] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-authentik.md b/docs/examples/project/update-o-auth-2-authentik.md index 2fbc0990..abe649fc 100644 --- a/docs/examples/project/update-o-auth-2-authentik.md +++ b/docs/examples/project/update-o-auth-2-authentik.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Authentik -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Authentik = await project.update_o_auth2_authentik( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + endpoint = '<ENDPOINT>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Authentik = project.update_o_auth2_authentik( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - endpoint = '<ENDPOINT>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-autodesk.md b/docs/examples/project/update-o-auth-2-autodesk.md index cff31e1e..e90552f1 100644 --- a/docs/examples/project/update-o-auth-2-autodesk.md +++ b/docs/examples/project/update-o-auth-2-autodesk.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Autodesk -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Autodesk = await project.update_o_auth2_autodesk( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Autodesk = project.update_o_auth2_autodesk( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-bitbucket.md b/docs/examples/project/update-o-auth-2-bitbucket.md index a2099d1b..3bcf3674 100644 --- a/docs/examples/project/update-o-auth-2-bitbucket.md +++ b/docs/examples/project/update-o-auth-2-bitbucket.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Bitbucket -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Bitbucket = await project.update_o_auth2_bitbucket( + key = '<KEY>', # optional + secret = '<SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Bitbucket = project.update_o_auth2_bitbucket( - key = '<KEY>', # optional - secret = '<SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-bitly.md b/docs/examples/project/update-o-auth-2-bitly.md index 1f026038..a693105d 100644 --- a/docs/examples/project/update-o-auth-2-bitly.md +++ b/docs/examples/project/update-o-auth-2-bitly.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Bitly -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Bitly = await project.update_o_auth2_bitly( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Bitly = project.update_o_auth2_bitly( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-box.md b/docs/examples/project/update-o-auth-2-box.md index 363cd060..fb620f09 100644 --- a/docs/examples/project/update-o-auth-2-box.md +++ b/docs/examples/project/update-o-auth-2-box.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Box -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Box = await project.update_o_auth2_box( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Box = project.update_o_auth2_box( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-cloudflare.md b/docs/examples/project/update-o-auth-2-cloudflare.md index 1044a61b..90b9e897 100644 --- a/docs/examples/project/update-o-auth-2-cloudflare.md +++ b/docs/examples/project/update-o-auth-2-cloudflare.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Cloudflare -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Cloudflare = await project.update_o_auth2_cloudflare( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Cloudflare = project.update_o_auth2_cloudflare( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-dailymotion.md b/docs/examples/project/update-o-auth-2-dailymotion.md index 53449cd1..39e91e36 100644 --- a/docs/examples/project/update-o-auth-2-dailymotion.md +++ b/docs/examples/project/update-o-auth-2-dailymotion.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Dailymotion -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Dailymotion = await project.update_o_auth2_dailymotion( + api_key = '<API_KEY>', # optional + api_secret = '<API_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Dailymotion = project.update_o_auth2_dailymotion( - api_key = '<API_KEY>', # optional - api_secret = '<API_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index 9b89515d..f68c0956 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Discord from appwrite.enums.project_o_auth2_discord_prompt import ProjectOAuth2DiscordPrompt -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Discord = await project.update_o_auth2_discord( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False, # optional + prompt = [ProjectOAuth2DiscordPrompt.NONE] # optional + ) + + print(result.model_dump()) -result: OAuth2Discord = project.update_o_auth2_discord( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False, # optional - prompt = [ProjectOAuth2DiscordPrompt.NONE] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-disqus.md b/docs/examples/project/update-o-auth-2-disqus.md index f2af447f..3cd4ef11 100644 --- a/docs/examples/project/update-o-auth-2-disqus.md +++ b/docs/examples/project/update-o-auth-2-disqus.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Disqus -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Disqus = await project.update_o_auth2_disqus( + public_key = '<PUBLIC_KEY>', # optional + secret_key = '<SECRET_KEY>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Disqus = project.update_o_auth2_disqus( - public_key = '<PUBLIC_KEY>', # optional - secret_key = '<SECRET_KEY>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-dropbox.md b/docs/examples/project/update-o-auth-2-dropbox.md index 50e30119..95bd5fd8 100644 --- a/docs/examples/project/update-o-auth-2-dropbox.md +++ b/docs/examples/project/update-o-auth-2-dropbox.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Dropbox -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Dropbox = await project.update_o_auth2_dropbox( + app_key = '<APP_KEY>', # optional + app_secret = '<APP_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Dropbox = project.update_o_auth2_dropbox( - app_key = '<APP_KEY>', # optional - app_secret = '<APP_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-etsy.md b/docs/examples/project/update-o-auth-2-etsy.md index 4a0a20ea..aedb11a8 100644 --- a/docs/examples/project/update-o-auth-2-etsy.md +++ b/docs/examples/project/update-o-auth-2-etsy.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Etsy -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Etsy = await project.update_o_auth2_etsy( + key_string = '<KEY_STRING>', # optional + shared_secret = '<SHARED_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Etsy = project.update_o_auth2_etsy( - key_string = '<KEY_STRING>', # optional - shared_secret = '<SHARED_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-facebook.md b/docs/examples/project/update-o-auth-2-facebook.md index 5b536dbb..8dd61476 100644 --- a/docs/examples/project/update-o-auth-2-facebook.md +++ b/docs/examples/project/update-o-auth-2-facebook.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Facebook -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Facebook = await project.update_o_auth2_facebook( + app_id = '<APP_ID>', # optional + app_secret = '<APP_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Facebook = project.update_o_auth2_facebook( - app_id = '<APP_ID>', # optional - app_secret = '<APP_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-figma.md b/docs/examples/project/update-o-auth-2-figma.md index eb2a2d25..6643a418 100644 --- a/docs/examples/project/update-o-auth-2-figma.md +++ b/docs/examples/project/update-o-auth-2-figma.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Figma -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Figma = await project.update_o_auth2_figma( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Figma = project.update_o_auth2_figma( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-fusion-auth.md b/docs/examples/project/update-o-auth-2-fusion-auth.md index fb4d25df..37e922eb 100644 --- a/docs/examples/project/update-o-auth-2-fusion-auth.md +++ b/docs/examples/project/update-o-auth-2-fusion-auth.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2FusionAuth -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2FusionAuth = await project.update_o_auth2_fusion_auth( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + endpoint = '<ENDPOINT>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2FusionAuth = project.update_o_auth2_fusion_auth( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - endpoint = '<ENDPOINT>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index 1df4ea59..0b48d9ff 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Github from appwrite.enums.project_o_auth2_git_hub_prompt import ProjectOAuth2GitHubPrompt -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Github = await project.update_o_auth2_git_hub( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False, # optional + prompt = [ProjectOAuth2GitHubPrompt.SELECT_ACCOUNT] # optional + ) + + print(result.model_dump()) -result: OAuth2Github = project.update_o_auth2_git_hub( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False, # optional - prompt = [ProjectOAuth2GitHubPrompt.SELECT_ACCOUNT] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-gitlab.md b/docs/examples/project/update-o-auth-2-gitlab.md index 05905fdc..293c83f8 100644 --- a/docs/examples/project/update-o-auth-2-gitlab.md +++ b/docs/examples/project/update-o-auth-2-gitlab.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Gitlab -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Gitlab = await project.update_o_auth2_gitlab( + application_id = '<APPLICATION_ID>', # optional + secret = '<SECRET>', # optional + endpoint = 'https://example.com', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Gitlab = project.update_o_auth2_gitlab( - application_id = '<APPLICATION_ID>', # optional - secret = '<SECRET>', # optional - endpoint = 'https://example.com', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 5c3e3797..4cf2de44 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Google from appwrite.enums.project_o_auth2_google_prompt import ProjectOAuth2GooglePrompt -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Google = await project.update_o_auth2_google( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + prompt = [ProjectOAuth2GooglePrompt.NONE], # optional + enabled = False, # optional + native_client_ids = [], # optional + native_enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Google = project.update_o_auth2_google( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - prompt = [ProjectOAuth2GooglePrompt.NONE], # optional - enabled = False, # optional - native_client_ids = [], # optional - native_enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-hugging-face.md b/docs/examples/project/update-o-auth-2-hugging-face.md index 932d4af8..e8e2ab79 100644 --- a/docs/examples/project/update-o-auth-2-hugging-face.md +++ b/docs/examples/project/update-o-auth-2-hugging-face.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2HuggingFace -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2HuggingFace = await project.update_o_auth2_hugging_face( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2HuggingFace = project.update_o_auth2_hugging_face( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index e03afc3f..24395055 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Kakao from appwrite.enums.project_o_auth2_kakao_prompt import ProjectOAuth2KakaoPrompt -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Kakao = await project.update_o_auth2_kakao( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False, # optional + prompt = [ProjectOAuth2KakaoPrompt.NONE] # optional + ) + + print(result.model_dump()) -result: OAuth2Kakao = project.update_o_auth2_kakao( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False, # optional - prompt = [ProjectOAuth2KakaoPrompt.NONE] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-keycloak.md b/docs/examples/project/update-o-auth-2-keycloak.md index 11a0defb..12b251ad 100644 --- a/docs/examples/project/update-o-auth-2-keycloak.md +++ b/docs/examples/project/update-o-auth-2-keycloak.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Keycloak -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Keycloak = await project.update_o_auth2_keycloak( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + endpoint = '<ENDPOINT>', # optional + realm_name = '<REALM_NAME>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Keycloak = project.update_o_auth2_keycloak( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - endpoint = '<ENDPOINT>', # optional - realm_name = '<REALM_NAME>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-kick.md b/docs/examples/project/update-o-auth-2-kick.md index bc73e063..3fc25433 100644 --- a/docs/examples/project/update-o-auth-2-kick.md +++ b/docs/examples/project/update-o-auth-2-kick.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Kick -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Kick = await project.update_o_auth2_kick( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Kick = project.update_o_auth2_kick( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-linkedin.md b/docs/examples/project/update-o-auth-2-linkedin.md index 4b6eec3b..afdbac3f 100644 --- a/docs/examples/project/update-o-auth-2-linkedin.md +++ b/docs/examples/project/update-o-auth-2-linkedin.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Linkedin -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Linkedin = await project.update_o_auth2_linkedin( + client_id = '<CLIENT_ID>', # optional + primary_client_secret = '<PRIMARY_CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Linkedin = project.update_o_auth2_linkedin( - client_id = '<CLIENT_ID>', # optional - primary_client_secret = '<PRIMARY_CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index c681a42f..0963a5e6 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Microsoft from appwrite.enums.project_o_auth2_microsoft_prompt import ProjectOAuth2MicrosoftPrompt -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Microsoft = await project.update_o_auth2_microsoft( + application_id = '<APPLICATION_ID>', # optional + application_secret = '<APPLICATION_SECRET>', # optional + tenant = '<TENANT>', # optional + enabled = False, # optional + prompt = [ProjectOAuth2MicrosoftPrompt.NONE] # optional + ) + + print(result.model_dump()) -result: OAuth2Microsoft = project.update_o_auth2_microsoft( - application_id = '<APPLICATION_ID>', # optional - application_secret = '<APPLICATION_SECRET>', # optional - tenant = '<TENANT>', # optional - enabled = False, # optional - prompt = [ProjectOAuth2MicrosoftPrompt.NONE] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-notion.md b/docs/examples/project/update-o-auth-2-notion.md index 0ba765ea..45858c8e 100644 --- a/docs/examples/project/update-o-auth-2-notion.md +++ b/docs/examples/project/update-o-auth-2-notion.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Notion -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Notion = await project.update_o_auth2_notion( + oauth_client_id = '<OAUTH_CLIENT_ID>', # optional + oauth_client_secret = '<OAUTH_CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Notion = project.update_o_auth2_notion( - oauth_client_id = '<OAUTH_CLIENT_ID>', # optional - oauth_client_secret = '<OAUTH_CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-oidc.md b/docs/examples/project/update-o-auth-2-oidc.md index de01460f..4fb7a65b 100644 --- a/docs/examples/project/update-o-auth-2-oidc.md +++ b/docs/examples/project/update-o-auth-2-oidc.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Oidc from appwrite.enums.project_o_auth2_oidc_prompt import ProjectOAuth2OidcPrompt -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 - -project = Project(client) - -result: OAuth2Oidc = project.update_o_auth2_oidc( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - well_known_url = 'https://example.com', # optional - authorization_url = 'https://example.com', # optional - token_url = 'https://example.com', # optional - user_info_url = 'https://example.com', # optional - prompt = [ProjectOAuth2OidcPrompt.NONE], # optional - max_age = 0, # optional - enabled = False # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + project = Project(client) + + result: OAuth2Oidc = await project.update_o_auth2_oidc( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + well_known_url = 'https://example.com', # optional + authorization_url = 'https://example.com', # optional + token_url = 'https://example.com', # optional + user_info_url = 'https://example.com', # optional + prompt = [ProjectOAuth2OidcPrompt.NONE], # optional + max_age = 0, # optional + enabled = False # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 05cb4529..c9da8cec 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Okta from appwrite.enums.project_o_auth2_okta_prompt import ProjectOAuth2OktaPrompt -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Okta = await project.update_o_auth2_okta( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + domain = 'example.com', # optional + authorization_server_id = '<AUTHORIZATION_SERVER_ID>', # optional + enabled = False, # optional + prompt = [ProjectOAuth2OktaPrompt.NONE] # optional + ) + + print(result.model_dump()) -result: OAuth2Okta = project.update_o_auth2_okta( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - domain = 'example.com', # optional - authorization_server_id = '<AUTHORIZATION_SERVER_ID>', # optional - enabled = False, # optional - prompt = [ProjectOAuth2OktaPrompt.NONE] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-paypal-sandbox.md b/docs/examples/project/update-o-auth-2-paypal-sandbox.md index f31dc285..f0da253a 100644 --- a/docs/examples/project/update-o-auth-2-paypal-sandbox.md +++ b/docs/examples/project/update-o-auth-2-paypal-sandbox.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Paypal -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Paypal = await project.update_o_auth2_paypal_sandbox( + client_id = '<CLIENT_ID>', # optional + secret_key = '<SECRET_KEY>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Paypal = project.update_o_auth2_paypal_sandbox( - client_id = '<CLIENT_ID>', # optional - secret_key = '<SECRET_KEY>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-paypal.md b/docs/examples/project/update-o-auth-2-paypal.md index 450e9592..39392c41 100644 --- a/docs/examples/project/update-o-auth-2-paypal.md +++ b/docs/examples/project/update-o-auth-2-paypal.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Paypal -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Paypal = await project.update_o_auth2_paypal( + client_id = '<CLIENT_ID>', # optional + secret_key = '<SECRET_KEY>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Paypal = project.update_o_auth2_paypal( - client_id = '<CLIENT_ID>', # optional - secret_key = '<SECRET_KEY>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-podio.md b/docs/examples/project/update-o-auth-2-podio.md index 992ecdce..1dd61c8a 100644 --- a/docs/examples/project/update-o-auth-2-podio.md +++ b/docs/examples/project/update-o-auth-2-podio.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Podio -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Podio = await project.update_o_auth2_podio( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Podio = project.update_o_auth2_podio( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-resend.md b/docs/examples/project/update-o-auth-2-resend.md index 8ce17418..f5430deb 100644 --- a/docs/examples/project/update-o-auth-2-resend.md +++ b/docs/examples/project/update-o-auth-2-resend.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Resend -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Resend = await project.update_o_auth2_resend( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Resend = project.update_o_auth2_resend( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 275462ef..e60f38c1 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Salesforce from appwrite.enums.project_o_auth2_salesforce_prompt import ProjectOAuth2SalesforcePrompt -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Salesforce = await project.update_o_auth2_salesforce( + customer_key = '<CUSTOMER_KEY>', # optional + customer_secret = '<CUSTOMER_SECRET>', # optional + enabled = False, # optional + prompt = [ProjectOAuth2SalesforcePrompt.LOGIN] # optional + ) + + print(result.model_dump()) -result: OAuth2Salesforce = project.update_o_auth2_salesforce( - customer_key = '<CUSTOMER_KEY>', # optional - customer_secret = '<CUSTOMER_SECRET>', # optional - enabled = False, # optional - prompt = [ProjectOAuth2SalesforcePrompt.LOGIN] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-server.md b/docs/examples/project/update-o-auth-2-server.md index 338ebf33..51fa9b88 100644 --- a/docs/examples/project/update-o-auth-2-server.md +++ b/docs/examples/project/update-o-auth-2-server.md @@ -1,33 +1,40 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 - -project = Project(client) - -result: ProjectModel = project.update_o_auth2_server( - enabled = False, - authorization_url = 'https://example.com', - scopes = [], # optional - authorization_details_types = [], # optional - access_token_duration = 60, # optional - refresh_token_duration = 60, # optional - public_access_token_duration = 60, # optional - public_refresh_token_duration = 60, # optional - installation_access_token_duration = 60, # optional - confidential_pkce = False, # optional - verification_url = 'https://example.com', # optional - user_code_length = 6, # optional - user_code_format = 'numeric', # optional - device_code_duration = 60, # optional - default_scopes = [], # optional - installation_scopes = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_o_auth2_server( + enabled = False, + authorization_url = 'https://example.com', + scopes = [], # optional + authorization_details_types = [], # optional + access_token_duration = 60, # optional + refresh_token_duration = 60, # optional + public_access_token_duration = 60, # optional + public_refresh_token_duration = 60, # optional + installation_access_token_duration = 60, # optional + confidential_pkce = False, # optional + verification_url = 'https://example.com', # optional + user_code_length = 6, # optional + user_code_format = 'numeric', # optional + device_code_duration = 60, # optional + default_scopes = [], # optional + installation_scopes = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-slack.md b/docs/examples/project/update-o-auth-2-slack.md index 65cc3099..eb8d0da3 100644 --- a/docs/examples/project/update-o-auth-2-slack.md +++ b/docs/examples/project/update-o-auth-2-slack.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Slack -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Slack = await project.update_o_auth2_slack( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Slack = project.update_o_auth2_slack( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-spotify.md b/docs/examples/project/update-o-auth-2-spotify.md index 257f45d0..523be7db 100644 --- a/docs/examples/project/update-o-auth-2-spotify.md +++ b/docs/examples/project/update-o-auth-2-spotify.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Spotify -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Spotify = await project.update_o_auth2_spotify( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Spotify = project.update_o_auth2_spotify( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-stripe.md b/docs/examples/project/update-o-auth-2-stripe.md index 7207a897..36b95708 100644 --- a/docs/examples/project/update-o-auth-2-stripe.md +++ b/docs/examples/project/update-o-auth-2-stripe.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Stripe -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Stripe = await project.update_o_auth2_stripe( + client_id = '<CLIENT_ID>', # optional + api_secret_key = '<API_SECRET_KEY>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Stripe = project.update_o_auth2_stripe( - client_id = '<CLIENT_ID>', # optional - api_secret_key = '<API_SECRET_KEY>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-tik-tok.md b/docs/examples/project/update-o-auth-2-tik-tok.md index 3a7c9cb7..37ac4f8d 100644 --- a/docs/examples/project/update-o-auth-2-tik-tok.md +++ b/docs/examples/project/update-o-auth-2-tik-tok.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2TikTok -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2TikTok = await project.update_o_auth2_tik_tok( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2TikTok = project.update_o_auth2_tik_tok( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md index 2aaf7e64..76738d84 100644 --- a/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md +++ b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Tradeshift -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Tradeshift = await project.update_o_auth2_tradeshift_sandbox( + oauth2_client_id = '<OAUTH2_CLIENT_ID>', # optional + oauth2_client_secret = '<OAUTH2_CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Tradeshift = project.update_o_auth2_tradeshift_sandbox( - oauth2_client_id = '<OAUTH2_CLIENT_ID>', # optional - oauth2_client_secret = '<OAUTH2_CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift.md b/docs/examples/project/update-o-auth-2-tradeshift.md index 6ed5bacc..cfde0e60 100644 --- a/docs/examples/project/update-o-auth-2-tradeshift.md +++ b/docs/examples/project/update-o-auth-2-tradeshift.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Tradeshift -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Tradeshift = await project.update_o_auth2_tradeshift( + oauth2_client_id = '<OAUTH2_CLIENT_ID>', # optional + oauth2_client_secret = '<OAUTH2_CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Tradeshift = project.update_o_auth2_tradeshift( - oauth2_client_id = '<OAUTH2_CLIENT_ID>', # optional - oauth2_client_secret = '<OAUTH2_CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-twitch.md b/docs/examples/project/update-o-auth-2-twitch.md index 7c402789..45917e53 100644 --- a/docs/examples/project/update-o-auth-2-twitch.md +++ b/docs/examples/project/update-o-auth-2-twitch.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Twitch -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Twitch = await project.update_o_auth2_twitch( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Twitch = project.update_o_auth2_twitch( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-webflow.md b/docs/examples/project/update-o-auth-2-webflow.md index 5edfea64..bdf8a1c6 100644 --- a/docs/examples/project/update-o-auth-2-webflow.md +++ b/docs/examples/project/update-o-auth-2-webflow.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Webflow -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Webflow = await project.update_o_auth2_webflow( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Webflow = project.update_o_auth2_webflow( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-word-press.md b/docs/examples/project/update-o-auth-2-word-press.md index c7b406b9..b72c778a 100644 --- a/docs/examples/project/update-o-auth-2-word-press.md +++ b/docs/examples/project/update-o-auth-2-word-press.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2WordPress -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2WordPress = await project.update_o_auth2_word_press( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2WordPress = project.update_o_auth2_word_press( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-yahoo.md b/docs/examples/project/update-o-auth-2-yahoo.md index 6ea825b5..1e0b0217 100644 --- a/docs/examples/project/update-o-auth-2-yahoo.md +++ b/docs/examples/project/update-o-auth-2-yahoo.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Yahoo -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Yahoo = await project.update_o_auth2_yahoo( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Yahoo = project.update_o_auth2_yahoo( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-yandex.md b/docs/examples/project/update-o-auth-2-yandex.md index c8604ede..83c014a7 100644 --- a/docs/examples/project/update-o-auth-2-yandex.md +++ b/docs/examples/project/update-o-auth-2-yandex.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Yandex -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Yandex = await project.update_o_auth2_yandex( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Yandex = project.update_o_auth2_yandex( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index 712bcd96..2ce84d35 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Zoho from appwrite.enums.project_o_auth2_zoho_prompt import ProjectOAuth2ZohoPrompt -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Zoho = await project.update_o_auth2_zoho( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False, # optional + prompt = [ProjectOAuth2ZohoPrompt.CONSENT] # optional + ) + + print(result.model_dump()) -result: OAuth2Zoho = project.update_o_auth2_zoho( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False, # optional - prompt = [ProjectOAuth2ZohoPrompt.CONSENT] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2-zoom.md b/docs/examples/project/update-o-auth-2-zoom.md index e779a0c0..8c59077c 100644 --- a/docs/examples/project/update-o-auth-2-zoom.md +++ b/docs/examples/project/update-o-auth-2-zoom.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2Zoom -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2Zoom = await project.update_o_auth2_zoom( + client_id = '<CLIENT_ID>', # optional + client_secret = '<CLIENT_SECRET>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2Zoom = project.update_o_auth2_zoom( - client_id = '<CLIENT_ID>', # optional - client_secret = '<CLIENT_SECRET>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-o-auth-2x.md b/docs/examples/project/update-o-auth-2x.md index 5637fd6a..50557055 100644 --- a/docs/examples/project/update-o-auth-2x.md +++ b/docs/examples/project/update-o-auth-2x.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import OAuth2X -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: OAuth2X = await project.update_o_auth2_x( + customer_key = '<CUSTOMER_KEY>', # optional + secret_key = '<SECRET_KEY>', # optional + enabled = False # optional + ) + + print(result.model_dump()) -result: OAuth2X = project.update_o_auth2_x( - customer_key = '<CUSTOMER_KEY>', # optional - secret_key = '<SECRET_KEY>', # optional - enabled = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-passkey-policy.md b/docs/examples/project/update-passkey-policy.md index 08e2f41b..e304fffd 100644 --- a/docs/examples/project/update-passkey-policy.md +++ b/docs/examples/project/update-passkey-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_passkey_policy( + rp_id = '<RP_ID>' + ) + + print(result.model_dump()) -result: ProjectModel = project.update_passkey_policy( - rp_id = '<RP_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-password-dictionary-policy.md b/docs/examples/project/update-password-dictionary-policy.md index 53a8d71e..18772daa 100644 --- a/docs/examples/project/update-password-dictionary-policy.md +++ b/docs/examples/project/update-password-dictionary-policy.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_password_dictionary_policy( + enabled = False, + deny_list = [] # optional + ) + + print(result.model_dump()) -result: ProjectModel = project.update_password_dictionary_policy( - enabled = False, - deny_list = [] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-password-history-policy.md b/docs/examples/project/update-password-history-policy.md index 5e3c1406..9cfc9d5b 100644 --- a/docs/examples/project/update-password-history-policy.md +++ b/docs/examples/project/update-password-history-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_password_history_policy( + total = 1 + ) + + print(result.model_dump()) -result: ProjectModel = project.update_password_history_policy( - total = 1 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-password-personal-data-policy.md b/docs/examples/project/update-password-personal-data-policy.md index d9587b6a..e708750b 100644 --- a/docs/examples/project/update-password-personal-data-policy.md +++ b/docs/examples/project/update-password-personal-data-policy.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_password_personal_data_policy( + enabled = False, + deny_list = [] # optional + ) + + print(result.model_dump()) -result: ProjectModel = project.update_password_personal_data_policy( - enabled = False, - deny_list = [] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-password-pwned-policy.md b/docs/examples/project/update-password-pwned-policy.md index 53d2130c..2db1238e 100644 --- a/docs/examples/project/update-password-pwned-policy.md +++ b/docs/examples/project/update-password-pwned-policy.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_password_pwned_policy( + enabled = False, # optional + sessions = False, # optional + users = False # optional + ) + + print(result.model_dump()) -result: ProjectModel = project.update_password_pwned_policy( - enabled = False, # optional - sessions = False, # optional - users = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md index 68d69221..3ac67df4 100644 --- a/docs/examples/project/update-password-rotation-policy.md +++ b/docs/examples/project/update-password-rotation-policy.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_password_rotation_policy( + enabled = False, # optional + max_age = 86400 # optional + ) + + print(result.model_dump()) -result: ProjectModel = project.update_password_rotation_policy( - enabled = False, # optional - max_age = 86400 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-password-strength-policy.md b/docs/examples/project/update-password-strength-policy.md index c87aeaf3..adad1e23 100644 --- a/docs/examples/project/update-password-strength-policy.md +++ b/docs/examples/project/update-password-strength-policy.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PolicyPasswordStrength -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PolicyPasswordStrength = await project.update_password_strength_policy( + min = 8, # optional + uppercase = False, # optional + lowercase = False, # optional + number = False, # optional + symbols = False # optional + ) + + print(result.model_dump()) -result: PolicyPasswordStrength = project.update_password_strength_policy( - min = 8, # optional - uppercase = False, # optional - lowercase = False, # optional - number = False, # optional - symbols = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-protocol.md b/docs/examples/project/update-protocol.md index e3d7afc8..e77f82ea 100644 --- a/docs/examples/project/update-protocol.md +++ b/docs/examples/project/update-protocol.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel from appwrite.enums.project_protocol_id import ProjectProtocolId -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_protocol( + protocol_id = ProjectProtocolId.REST, + enabled = False + ) + + print(result.model_dump()) -result: ProjectModel = project.update_protocol( - protocol_id = ProjectProtocolId.REST, - enabled = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-service.md b/docs/examples/project/update-service.md index 61b490a6..e87275ef 100644 --- a/docs/examples/project/update-service.md +++ b/docs/examples/project/update-service.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel from appwrite.enums.project_service_id import ProjectServiceId -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_service( + service_id = ProjectServiceId.ACCOUNT, + enabled = False + ) + + print(result.model_dump()) -result: ProjectModel = project.update_service( - service_id = ProjectServiceId.ACCOUNT, - enabled = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-session-alert-policy.md b/docs/examples/project/update-session-alert-policy.md index 382f694d..8f254d25 100644 --- a/docs/examples/project/update-session-alert-policy.md +++ b/docs/examples/project/update-session-alert-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_session_alert_policy( + enabled = False + ) + + print(result.model_dump()) -result: ProjectModel = project.update_session_alert_policy( - enabled = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-session-duration-policy.md b/docs/examples/project/update-session-duration-policy.md index 817947e4..d14694f0 100644 --- a/docs/examples/project/update-session-duration-policy.md +++ b/docs/examples/project/update-session-duration-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_session_duration_policy( + duration = 60 + ) + + print(result.model_dump()) -result: ProjectModel = project.update_session_duration_policy( - duration = 60 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-session-invalidation-policy.md b/docs/examples/project/update-session-invalidation-policy.md index 6e8417d3..d6989ea0 100644 --- a/docs/examples/project/update-session-invalidation-policy.md +++ b/docs/examples/project/update-session-invalidation-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_session_invalidation_policy( + enabled = False + ) + + print(result.model_dump()) -result: ProjectModel = project.update_session_invalidation_policy( - enabled = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-session-limit-policy.md b/docs/examples/project/update-session-limit-policy.md index bcfd671a..a62ff3c7 100644 --- a/docs/examples/project/update-session-limit-policy.md +++ b/docs/examples/project/update-session-limit-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_session_limit_policy( + total = 1 + ) + + print(result.model_dump()) -result: ProjectModel = project.update_session_limit_policy( - total = 1 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-smtp.md b/docs/examples/project/update-smtp.md index ae8b2c9f..4e8e691e 100644 --- a/docs/examples/project/update-smtp.md +++ b/docs/examples/project/update-smtp.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel from appwrite.enums.project_smtp_secure import ProjectSMTPSecure -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 - -project = Project(client) - -result: ProjectModel = project.update_smtp( - host = 'example.com', # optional - port = 587, # optional - username = '<USERNAME>', # optional - password = 'password', # optional - sender_email = 'email@example.com', # optional - sender_name = '<SENDER_NAME>', # optional - reply_to_email = 'email@example.com', # optional - reply_to_name = '<REPLY_TO_NAME>', # optional - secure = ProjectSMTPSecure.TLS, # optional - enabled = False # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_smtp( + host = 'example.com', # optional + port = 587, # optional + username = '<USERNAME>', # optional + password = 'password', # optional + sender_email = 'email@example.com', # optional + sender_name = '<SENDER_NAME>', # optional + reply_to_email = 'email@example.com', # optional + reply_to_name = '<REPLY_TO_NAME>', # optional + secure = ProjectSMTPSecure.TLS, # optional + enabled = False # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-user-limit-policy.md b/docs/examples/project/update-user-limit-policy.md index 42d66de3..b450e924 100644 --- a/docs/examples/project/update-user-limit-policy.md +++ b/docs/examples/project/update-user-limit-policy.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Project as ProjectModel -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: ProjectModel = await project.update_user_limit_policy( + total = 0 + ) + + print(result.model_dump()) -result: ProjectModel = project.update_user_limit_policy( - total = 0 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-variable.md b/docs/examples/project/update-variable.md index abe4ae74..f79d9280 100644 --- a/docs/examples/project/update-variable.md +++ b/docs/examples/project/update-variable.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import Variable -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: Variable = await project.update_variable( + variable_id = '<VARIABLE_ID>', + key = '<KEY>', # optional + value = '<VALUE>', # optional + secret = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: Variable = project.update_variable( - variable_id = '<VARIABLE_ID>', - key = '<KEY>', # optional - value = '<VALUE>', # optional - secret = False, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-web-platform.md b/docs/examples/project/update-web-platform.md index 19f10b4b..e12b199c 100644 --- a/docs/examples/project/update-web-platform.md +++ b/docs/examples/project/update-web-platform.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformWeb -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformWeb = await project.update_web_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + hostname = 'app.example.com' + ) + + print(result.model_dump()) -result: PlatformWeb = project.update_web_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - hostname = 'app.example.com' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/project/update-windows-platform.md b/docs/examples/project/update-windows-platform.md index cf154e04..77d2f9fa 100644 --- a/docs/examples/project/update-windows-platform.md +++ b/docs/examples/project/update-windows-platform.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.project import Project from appwrite.models import PlatformWindows -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 -project = Project(client) +async def main(): + 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 + + project = Project(client) + + result: PlatformWindows = await project.update_windows_platform( + platform_id = '<PLATFORM_ID>', + name = '<NAME>', + package_identifier_name = '<PACKAGE_IDENTIFIER_NAME>' + ) + + print(result.model_dump()) -result: PlatformWindows = project.update_windows_platform( - platform_id = '<PLATFORM_ID>', - name = '<NAME>', - package_identifier_name = '<PACKAGE_IDENTIFIER_NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/create-api-rule.md b/docs/examples/proxy/create-api-rule.md index 7baf360c..78148e11 100644 --- a/docs/examples/proxy/create-api-rule.md +++ b/docs/examples/proxy/create-api-rule.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy from appwrite.models import ProxyRule -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result: ProxyRule = await proxy.create_api_rule( + domain = 'example.com' + ) + + print(result.model_dump()) -result: ProxyRule = proxy.create_api_rule( - domain = 'example.com' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/create-function-rule.md b/docs/examples/proxy/create-function-rule.md index 0abc5926..7286ea53 100644 --- a/docs/examples/proxy/create-function-rule.md +++ b/docs/examples/proxy/create-function-rule.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy from appwrite.models import ProxyRule -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result: ProxyRule = await proxy.create_function_rule( + domain = 'example.com', + function_id = '<FUNCTION_ID>', + branch = '<BRANCH>' # optional + ) + + print(result.model_dump()) -result: ProxyRule = proxy.create_function_rule( - domain = 'example.com', - function_id = '<FUNCTION_ID>', - branch = '<BRANCH>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/create-invalidation.md b/docs/examples/proxy/create-invalidation.md index 365de03e..4be2a735 100644 --- a/docs/examples/proxy/create-invalidation.md +++ b/docs/examples/proxy/create-invalidation.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy from appwrite.models import ProxyInvalidation from appwrite.enums.invalidation_type import InvalidationType -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result: ProxyInvalidation = await proxy.create_invalidation( + domain = 'example.com', + type = InvalidationType.TAG, + reference = '<REFERENCE>' # optional + ) + + print(result.model_dump()) -result: ProxyInvalidation = proxy.create_invalidation( - domain = 'example.com', - type = InvalidationType.TAG, - reference = '<REFERENCE>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/create-redirect-rule.md b/docs/examples/proxy/create-redirect-rule.md index 2b4c1934..7e328357 100644 --- a/docs/examples/proxy/create-redirect-rule.md +++ b/docs/examples/proxy/create-redirect-rule.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy from appwrite.models import ProxyRule from appwrite.enums.status_code import StatusCode from appwrite.enums.proxy_resource_type import ProxyResourceType -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result: ProxyRule = await proxy.create_redirect_rule( + domain = 'example.com', + url = 'https://example.com', + status_code = StatusCode.MOVEDPERMANENTLY, + resource_id = '<RESOURCE_ID>', + resource_type = ProxyResourceType.SITE + ) + + print(result.model_dump()) -result: ProxyRule = proxy.create_redirect_rule( - domain = 'example.com', - url = 'https://example.com', - status_code = StatusCode.MOVEDPERMANENTLY, - resource_id = '<RESOURCE_ID>', - resource_type = ProxyResourceType.SITE -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/create-site-rule.md b/docs/examples/proxy/create-site-rule.md index c108dca6..940c9886 100644 --- a/docs/examples/proxy/create-site-rule.md +++ b/docs/examples/proxy/create-site-rule.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy from appwrite.models import ProxyRule -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result: ProxyRule = await proxy.create_site_rule( + domain = 'example.com', + site_id = '<SITE_ID>', + branch = '<BRANCH>' # optional + ) + + print(result.model_dump()) -result: ProxyRule = proxy.create_site_rule( - domain = 'example.com', - site_id = '<SITE_ID>', - branch = '<BRANCH>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/create-smtp-rule.md b/docs/examples/proxy/create-smtp-rule.md index c1071fbe..bbd62858 100644 --- a/docs/examples/proxy/create-smtp-rule.md +++ b/docs/examples/proxy/create-smtp-rule.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy from appwrite.models import ProxyRule -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result: ProxyRule = await proxy.create_smtp_rule( + domain = 'example.com', + function_id = '<FUNCTION_ID>', + branch = '<BRANCH>' # optional + ) + + print(result.model_dump()) -result: ProxyRule = proxy.create_smtp_rule( - domain = 'example.com', - function_id = '<FUNCTION_ID>', - branch = '<BRANCH>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/delete-rule.md b/docs/examples/proxy/delete-rule.md index c5a76ee5..2709f83b 100644 --- a/docs/examples/proxy/delete-rule.md +++ b/docs/examples/proxy/delete-rule.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result = await proxy.delete_rule( + rule_id = '<RULE_ID>' + ) + -result = proxy.delete_rule( - rule_id = '<RULE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/get-rule.md b/docs/examples/proxy/get-rule.md index becc4c36..5baa28dd 100644 --- a/docs/examples/proxy/get-rule.md +++ b/docs/examples/proxy/get-rule.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy from appwrite.models import ProxyRule -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result: ProxyRule = await proxy.get_rule( + rule_id = '<RULE_ID>' + ) + + print(result.model_dump()) -result: ProxyRule = proxy.get_rule( - rule_id = '<RULE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/list-rules.md b/docs/examples/proxy/list-rules.md index 4cf085f4..b307c7f4 100644 --- a/docs/examples/proxy/list-rules.md +++ b/docs/examples/proxy/list-rules.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy from appwrite.models import ProxyRuleList -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result: ProxyRuleList = await proxy.list_rules( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: ProxyRuleList = proxy.list_rules( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/proxy/update-rule-status.md b/docs/examples/proxy/update-rule-status.md index f317926d..ea903d6e 100644 --- a/docs/examples/proxy/update-rule-status.md +++ b/docs/examples/proxy/update-rule-status.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.proxy import Proxy from appwrite.models import ProxyRule -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 -proxy = Proxy(client) +async def main(): + 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 + + proxy = Proxy(client) + + result: ProxyRule = await proxy.update_rule_status( + rule_id = '<RULE_ID>' + ) + + print(result.model_dump()) -result: ProxyRule = proxy.update_rule_status( - rule_id = '<RULE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md index 8abb038e..59288e6a 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.input_file import InputFile from appwrite.models import Deployment -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) +async def main(): + 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: Deployment = await sites.create_deployment( + site_id = '<SITE_ID>', + code = InputFile.from_path('file.png'), + install_command = '<INSTALL_COMMAND>', # optional + build_command = '<BUILD_COMMAND>', # optional + output_directory = '<OUTPUT_DIRECTORY>', # optional + activate = False # optional + ) + + print(result.model_dump()) -result: Deployment = sites.create_deployment( - site_id = '<SITE_ID>', - code = InputFile.from_path('file.png'), - install_command = '<INSTALL_COMMAND>', # optional - build_command = '<BUILD_COMMAND>', # optional - output_directory = '<OUTPUT_DIRECTORY>', # optional - activate = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/create-duplicate-deployment.md b/docs/examples/sites/create-duplicate-deployment.md index 35b52564..de980a18 100644 --- a/docs/examples/sites/create-duplicate-deployment.md +++ b/docs/examples/sites/create-duplicate-deployment.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Deployment -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) +async def main(): + 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: Deployment = await sites.create_duplicate_deployment( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' + ) + + print(result.model_dump()) -result: Deployment = sites.create_duplicate_deployment( - site_id = '<SITE_ID>', - deployment_id = '<DEPLOYMENT_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md index 7be43234..a16f156d 100644 --- a/docs/examples/sites/create-template-deployment.md +++ b/docs/examples/sites/create-template-deployment.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Deployment from appwrite.enums.template_reference_type import TemplateReferenceType -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) +async def main(): + 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: Deployment = await sites.create_template_deployment( + site_id = '<SITE_ID>', + repository = '<REPOSITORY>', + owner = '<OWNER>', + root_directory = '<ROOT_DIRECTORY>', + type = TemplateReferenceType.BRANCH, + reference = '<REFERENCE>', + activate = False # optional + ) + + print(result.model_dump()) -result: Deployment = sites.create_template_deployment( - site_id = '<SITE_ID>', - repository = '<REPOSITORY>', - owner = '<OWNER>', - root_directory = '<ROOT_DIRECTORY>', - type = TemplateReferenceType.BRANCH, - reference = '<REFERENCE>', - activate = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md index 7174c1d1..fedc9854 100644 --- a/docs/examples/sites/create-variable.md +++ b/docs/examples/sites/create-variable.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Variable -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) +async def main(): + 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: Variable = await sites.create_variable( + site_id = '<SITE_ID>', + variable_id = '<VARIABLE_ID>', + key = '<KEY>', + value = '<VALUE>', + secret = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: Variable = sites.create_variable( - site_id = '<SITE_ID>', - variable_id = '<VARIABLE_ID>', - key = '<KEY>', - value = '<VALUE>', - secret = False, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/create-vcs-deployment.md b/docs/examples/sites/create-vcs-deployment.md index 3b97fa75..b311c290 100644 --- a/docs/examples/sites/create-vcs-deployment.md +++ b/docs/examples/sites/create-vcs-deployment.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Deployment from appwrite.enums.vcs_reference_type import VCSReferenceType -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) +async def main(): + 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: Deployment = await sites.create_vcs_deployment( + site_id = '<SITE_ID>', + type = VCSReferenceType.BRANCH, + reference = '<REFERENCE>', + activate = False # optional + ) + + print(result.model_dump()) -result: Deployment = sites.create_vcs_deployment( - site_id = '<SITE_ID>', - type = VCSReferenceType.BRANCH, - reference = '<REFERENCE>', - activate = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index c993e6fb..991be9d5 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Site @@ -7,40 +9,45 @@ from appwrite.enums.build_runtime import BuildRuntime from appwrite.enums.adapter import Adapter from appwrite.enums.project_key_scopes import ProjectKeyScopes -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: Site = sites.create( - site_id = '<SITE_ID>', - name = '<NAME>', - framework = Framework.ANALOG, - build_runtime = BuildRuntime.NODE_14_5, - enabled = False, # optional - logging = False, # optional - timeout = 1, # optional - install_command = '<INSTALL_COMMAND>', # optional - build_command = '<BUILD_COMMAND>', # optional - start_command = '<START_COMMAND>', # optional - output_directory = '<OUTPUT_DIRECTORY>', # optional - adapter = 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 - provider_branches = [], # optional - provider_paths = [], # optional - build_specification = 's-1vcpu-512mb', # optional - runtime_specification = 's-1vcpu-512mb', # optional - deployment_retention = 0, # optional - scopes = [ProjectKeyScopes.PROJECT_READ], # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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: Site = await sites.create( + site_id = '<SITE_ID>', + name = '<NAME>', + framework = Framework.ANALOG, + build_runtime = BuildRuntime.NODE_14_5, + enabled = False, # optional + logging = False, # optional + timeout = 1, # optional + install_command = '<INSTALL_COMMAND>', # optional + build_command = '<BUILD_COMMAND>', # optional + start_command = '<START_COMMAND>', # optional + output_directory = '<OUTPUT_DIRECTORY>', # optional + adapter = 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 + provider_branches = [], # optional + provider_paths = [], # optional + build_specification = 's-1vcpu-512mb', # optional + runtime_specification = 's-1vcpu-512mb', # optional + deployment_retention = 0, # optional + scopes = [ProjectKeyScopes.PROJECT_READ], # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/sites/delete-deployment.md b/docs/examples/sites/delete-deployment.md index ee2f1491..f7256b4d 100644 --- a/docs/examples/sites/delete-deployment.md +++ b/docs/examples/sites/delete-deployment.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await sites.delete_deployment( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' + ) + -result = sites.delete_deployment( - site_id = '<SITE_ID>', - deployment_id = '<DEPLOYMENT_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md index 26c63124..020f5199 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await sites.delete_log( + site_id = '<SITE_ID>', + log_id = '<LOG_ID>' + ) + -result = sites.delete_log( - site_id = '<SITE_ID>', - log_id = '<LOG_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/delete-variable.md b/docs/examples/sites/delete-variable.md index 97e77cd6..68a1ce96 100644 --- a/docs/examples/sites/delete-variable.md +++ b/docs/examples/sites/delete-variable.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await sites.delete_variable( + site_id = '<SITE_ID>', + variable_id = '<VARIABLE_ID>' + ) + -result = sites.delete_variable( - site_id = '<SITE_ID>', - variable_id = '<VARIABLE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/delete.md b/docs/examples/sites/delete.md index 41e3eafb..ab9acc03 100644 --- a/docs/examples/sites/delete.md +++ b/docs/examples/sites/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await sites.delete( + site_id = '<SITE_ID>' + ) + -result = sites.delete( - site_id = '<SITE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md index 0e9ea18a..a08e872a 100644 --- a/docs/examples/sites/get-deployment-download.md +++ b/docs/examples/sites/get-deployment-download.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.enums.deployment_download_type import DeploymentDownloadType -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) +async def main(): + 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: bytes = await sites.get_deployment_download( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>', + type = DeploymentDownloadType.SOURCE, # optional + token = '<TOKEN>' # optional + ) + -result: bytes = sites.get_deployment_download( - site_id = '<SITE_ID>', - deployment_id = '<DEPLOYMENT_ID>', - type = DeploymentDownloadType.SOURCE, # optional - token = '<TOKEN>' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/get-deployment.md b/docs/examples/sites/get-deployment.md index 5291928c..58880c28 100644 --- a/docs/examples/sites/get-deployment.md +++ b/docs/examples/sites/get-deployment.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Deployment -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) +async def main(): + 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: Deployment = await sites.get_deployment( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' + ) + + print(result.model_dump()) -result: Deployment = sites.get_deployment( - site_id = '<SITE_ID>', - deployment_id = '<DEPLOYMENT_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/get-log.md b/docs/examples/sites/get-log.md index aa718daa..7367c1ce 100644 --- a/docs/examples/sites/get-log.md +++ b/docs/examples/sites/get-log.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Execution -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) +async def main(): + 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: Execution = await sites.get_log( + site_id = '<SITE_ID>', + log_id = '<LOG_ID>' + ) + + print(result.model_dump()) -result: Execution = sites.get_log( - site_id = '<SITE_ID>', - log_id = '<LOG_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/get-variable.md b/docs/examples/sites/get-variable.md index 9eb30dd9..0e70943e 100644 --- a/docs/examples/sites/get-variable.md +++ b/docs/examples/sites/get-variable.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Variable -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) +async def main(): + 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: Variable = await sites.get_variable( + site_id = '<SITE_ID>', + variable_id = '<VARIABLE_ID>' + ) + + print(result.model_dump()) -result: Variable = sites.get_variable( - site_id = '<SITE_ID>', - variable_id = '<VARIABLE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/get.md b/docs/examples/sites/get.md index c792987a..5780c069 100644 --- a/docs/examples/sites/get.md +++ b/docs/examples/sites/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Site -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) +async def main(): + 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: Site = await sites.get( + site_id = '<SITE_ID>' + ) + + print(result.model_dump()) -result: Site = sites.get( - site_id = '<SITE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md index 70b2a0b3..3f719648 100644 --- a/docs/examples/sites/list-deployments.md +++ b/docs/examples/sites/list-deployments.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import DeploymentList -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) +async def main(): + 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: DeploymentList = await sites.list_deployments( + site_id = '<SITE_ID>', + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: DeploymentList = sites.list_deployments( - site_id = '<SITE_ID>', - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md index 2edd3b35..fe60f13e 100644 --- a/docs/examples/sites/list-frameworks.md +++ b/docs/examples/sites/list-frameworks.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import FrameworkList -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) +async def main(): + 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: FrameworkList = await sites.list_frameworks( + total = False # optional + ) + + print(result.model_dump()) -result: FrameworkList = sites.list_frameworks( - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md index 4543f232..23706977 100644 --- a/docs/examples/sites/list-logs.md +++ b/docs/examples/sites/list-logs.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import ExecutionList -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) +async def main(): + 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: ExecutionList = await sites.list_logs( + site_id = '<SITE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: ExecutionList = sites.list_logs( - site_id = '<SITE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 88c3402b..44887caf 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import SpecificationList -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) +async def main(): + 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: SpecificationList = await sites.list_specifications( + type = 'runtimes', # optional + total = False # optional + ) + + print(result.model_dump()) -result: SpecificationList = sites.list_specifications( - type = 'runtimes', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md index 4a2c2c5a..b845d4d2 100644 --- a/docs/examples/sites/list-variables.md +++ b/docs/examples/sites/list-variables.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import VariableList -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) +async def main(): + 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: VariableList = await sites.list_variables( + site_id = '<SITE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: VariableList = sites.list_variables( - site_id = '<SITE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md index 0a564827..bd81c44d 100644 --- a/docs/examples/sites/list.md +++ b/docs/examples/sites/list.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import SiteList -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) +async def main(): + 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: SiteList = await sites.list( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: SiteList = sites.list( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/update-deployment-status.md b/docs/examples/sites/update-deployment-status.md index 8ab82d4a..47b0d853 100644 --- a/docs/examples/sites/update-deployment-status.md +++ b/docs/examples/sites/update-deployment-status.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Deployment -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) +async def main(): + 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: Deployment = await sites.update_deployment_status( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' + ) + + print(result.model_dump()) -result: Deployment = sites.update_deployment_status( - site_id = '<SITE_ID>', - deployment_id = '<DEPLOYMENT_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/update-site-deployment.md b/docs/examples/sites/update-site-deployment.md index 507923e9..2c4da2ec 100644 --- a/docs/examples/sites/update-site-deployment.md +++ b/docs/examples/sites/update-site-deployment.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Site -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) +async def main(): + 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: Site = await sites.update_site_deployment( + site_id = '<SITE_ID>', + deployment_id = '<DEPLOYMENT_ID>' + ) + + print(result.model_dump()) -result: Site = sites.update_site_deployment( - site_id = '<SITE_ID>', - deployment_id = '<DEPLOYMENT_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md index 9293b47d..eac3f784 100644 --- a/docs/examples/sites/update-variable.md +++ b/docs/examples/sites/update-variable.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Variable -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) +async def main(): + 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: Variable = await sites.update_variable( + site_id = '<SITE_ID>', + variable_id = '<VARIABLE_ID>', + key = '<KEY>', # optional + value = '<VALUE>', # optional + secret = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: Variable = sites.update_variable( - site_id = '<SITE_ID>', - variable_id = '<VARIABLE_ID>', - key = '<KEY>', # optional - value = '<VALUE>', # optional - secret = False, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index f6f5bbdd..88fe7889 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.models import Site @@ -7,40 +9,45 @@ from appwrite.enums.build_runtime import BuildRuntime from appwrite.enums.adapter import Adapter from appwrite.enums.project_key_scopes import ProjectKeyScopes -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: Site = sites.update( - site_id = '<SITE_ID>', - name = '<NAME>', - framework = Framework.ANALOG, - enabled = False, # optional - logging = False, # optional - timeout = 1, # optional - install_command = '<INSTALL_COMMAND>', # optional - build_command = '<BUILD_COMMAND>', # optional - start_command = '<START_COMMAND>', # optional - output_directory = '<OUTPUT_DIRECTORY>', # optional - build_runtime = BuildRuntime.NODE_14_5, # optional - adapter = 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 - provider_branches = [], # optional - provider_paths = [], # optional - build_specification = 's-1vcpu-512mb', # optional - runtime_specification = 's-1vcpu-512mb', # optional - deployment_retention = 0, # optional - scopes = [ProjectKeyScopes.PROJECT_READ], # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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: Site = await sites.update( + site_id = '<SITE_ID>', + name = '<NAME>', + framework = Framework.ANALOG, + enabled = False, # optional + logging = False, # optional + timeout = 1, # optional + install_command = '<INSTALL_COMMAND>', # optional + build_command = '<BUILD_COMMAND>', # optional + start_command = '<START_COMMAND>', # optional + output_directory = '<OUTPUT_DIRECTORY>', # optional + build_runtime = BuildRuntime.NODE_14_5, # optional + adapter = 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 + provider_branches = [], # optional + provider_paths = [], # optional + build_specification = 's-1vcpu-512mb', # optional + runtime_specification = 's-1vcpu-512mb', # optional + deployment_retention = 0, # optional + scopes = [ProjectKeyScopes.PROJECT_READ], # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index 5800deee..e0a04f62 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.models import Bucket @@ -6,28 +8,33 @@ from appwrite.enums.compression import Compression from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_key('<YOUR_API_KEY>') # Your secret API key - -storage = Storage(client) - -result: Bucket = storage.create_bucket( - bucket_id = '<BUCKET_ID>', - name = '<NAME>', - permissions = [Permission.read(Role.any())], # optional - file_security = False, # optional - enabled = False, # optional - maximum_file_size = 1, # optional - allowed_file_extensions = [], # optional - compression = Compression.NONE, # optional - encryption = False, # optional - antivirus = False, # optional - transformations = False, # optional - description = '<DESCRIPTION>', # optional - strip_metadata = False # optional -) - -print(result.model_dump()) + +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_key('<YOUR_API_KEY>') # Your secret API key + + storage = Storage(client) + + result: Bucket = await storage.create_bucket( + bucket_id = '<BUCKET_ID>', + name = '<NAME>', + permissions = [Permission.read(Role.any())], # optional + file_security = False, # optional + enabled = False, # optional + maximum_file_size = 1, # optional + allowed_file_extensions = [], # optional + compression = Compression.NONE, # optional + encryption = False, # optional + antivirus = False, # optional + transformations = False, # optional + description = '<DESCRIPTION>', # optional + strip_metadata = False # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 9adb89cf..40cdc415 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.input_file import InputFile @@ -6,20 +8,25 @@ from appwrite.models import File from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + storage = Storage(client) + + result: File = await storage.create_file( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + file = InputFile.from_path('file.png'), + permissions = [Permission.read(Role.any())], # optional + folder = 'photos/2026' # optional + ) + + print(result.model_dump()) -result: File = storage.create_file( - bucket_id = '<BUCKET_ID>', - file_id = '<FILE_ID>', - file = InputFile.from_path('file.png'), - permissions = [Permission.read(Role.any())], # optional - folder = 'photos/2026' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md index ae71a793..c9c49494 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_key('<YOUR_API_KEY>') # Your secret API key -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_key('<YOUR_API_KEY>') # Your secret API key + + storage = Storage(client) + + result = await storage.delete_bucket( + bucket_id = '<BUCKET_ID>' + ) + -result = storage.delete_bucket( - bucket_id = '<BUCKET_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index ce1d2604..0456b893 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + storage = Storage(client) + + result = await storage.delete_file( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>' + ) + -result = storage.delete_file( - bucket_id = '<BUCKET_ID>', - file_id = '<FILE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md index eaa707ce..d5e47b94 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.models import Bucket -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_key('<YOUR_API_KEY>') # Your secret API key -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_key('<YOUR_API_KEY>') # Your secret API key + + storage = Storage(client) + + result: Bucket = await storage.get_bucket( + bucket_id = '<BUCKET_ID>' + ) + + print(result.model_dump()) -result: Bucket = storage.get_bucket( - bucket_id = '<BUCKET_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index ac6f9424..8971c3ed 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + storage = Storage(client) + + result: bytes = await storage.get_file_download( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + token = '<TOKEN>' # optional + ) + -result: bytes = storage.get_file_download( - bucket_id = '<BUCKET_ID>', - file_id = '<FILE_ID>', - token = '<TOKEN>' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index f5c8c9db..6c376121 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -1,30 +1,37 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.enums.image_gravity import ImageGravity from appwrite.enums.image_format import ImageFormat -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + storage = Storage(client) + + result: bytes = await storage.get_file_preview( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + width = 0, # optional + height = 0, # optional + gravity = ImageGravity.AUTO, # optional + quality = -1, # optional + border_width = 0, # optional + border_color = 'FFFFFF', # optional + border_radius = 0, # optional + opacity = 0, # optional + rotation = -360, # optional + background = 'FFFFFF', # optional + output = ImageFormat.JPG, # optional + token = '<TOKEN>' # optional + ) + -result: bytes = storage.get_file_preview( - bucket_id = '<BUCKET_ID>', - file_id = '<FILE_ID>', - width = 0, # optional - height = 0, # optional - gravity = ImageGravity.AUTO, # optional - quality = -1, # optional - border_width = 0, # optional - border_color = 'FFFFFF', # optional - border_radius = 0, # optional - opacity = 0, # optional - rotation = -360, # optional - background = 'FFFFFF', # optional - output = ImageFormat.JPG, # optional - token = '<TOKEN>' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 5cceef6f..44d30c99 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + storage = Storage(client) + + result: bytes = await storage.get_file_view( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + token = '<TOKEN>' # optional + ) + -result: bytes = storage.get_file_view( - bucket_id = '<BUCKET_ID>', - file_id = '<FILE_ID>', - token = '<TOKEN>' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index fb143511..e8b8c7bc 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.models import File -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + storage = Storage(client) + + result: File = await storage.get_file( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>' + ) + + print(result.model_dump()) -result: File = storage.get_file( - bucket_id = '<BUCKET_ID>', - file_id = '<FILE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index aebd50b6..41959ce7 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.models import BucketList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_key('<YOUR_API_KEY>') # Your secret API key -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_key('<YOUR_API_KEY>') # Your secret API key + + storage = Storage(client) + + result: BucketList = await storage.list_buckets( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: BucketList = storage.list_buckets( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index a676c313..9a777fd9 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.models import FileList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + storage = Storage(client) + + result: FileList = await storage.list_files( + bucket_id = '<BUCKET_ID>', + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: FileList = storage.list_files( - bucket_id = '<BUCKET_ID>', - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index b7906a36..2a83d7c8 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.models import Bucket @@ -6,28 +8,33 @@ from appwrite.enums.compression import Compression from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_key('<YOUR_API_KEY>') # Your secret API key - -storage = Storage(client) - -result: Bucket = storage.update_bucket( - bucket_id = '<BUCKET_ID>', - name = '<NAME>', - permissions = [Permission.read(Role.any())], # optional - file_security = False, # optional - enabled = False, # optional - maximum_file_size = 1, # optional - allowed_file_extensions = [], # optional - compression = Compression.NONE, # optional - encryption = False, # optional - antivirus = False, # optional - transformations = False, # optional - description = '<DESCRIPTION>', # optional - strip_metadata = False # optional -) - -print(result.model_dump()) + +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_key('<YOUR_API_KEY>') # Your secret API key + + storage = Storage(client) + + result: Bucket = await storage.update_bucket( + bucket_id = '<BUCKET_ID>', + name = '<NAME>', + permissions = [Permission.read(Role.any())], # optional + file_security = False, # optional + enabled = False, # optional + maximum_file_size = 1, # optional + allowed_file_extensions = [], # optional + compression = Compression.NONE, # optional + encryption = False, # optional + antivirus = False, # optional + transformations = False, # optional + description = '<DESCRIPTION>', # optional + strip_metadata = False # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index b0fad8d4..78efe1e8 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.models import File from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -storage = Storage(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + storage = Storage(client) + + result: File = await storage.update_file( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + name = '<NAME>', # optional + permissions = [Permission.read(Role.any())] # optional + ) + + print(result.model_dump()) -result: File = storage.update_file( - bucket_id = '<BUCKET_ID>', - file_id = '<FILE_ID>', - name = '<NAME>', # optional - permissions = [Permission.read(Role.any())] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-big-int-column.md b/docs/examples/tablesdb/create-big-int-column.md index 2ebb4287..a3f4e163 100644 --- a/docs/examples/tablesdb/create-big-int-column.md +++ b/docs/examples/tablesdb/create-big-int-column.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnBigint -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 - -tables_db = TablesDB(client) - -result: ColumnBigint = tables_db.create_big_int_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - min = 0, # optional - max = 1000000, # optional - default = 0, # optional - array = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnBigint = await tables_db.create_big_int_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + min = 0, # optional + max = 1000000, # optional + default = 0, # optional + array = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md index c5b62657..ef741c78 100644 --- a/docs/examples/tablesdb/create-boolean-column.md +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnBoolean -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnBoolean = await tables_db.create_boolean_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = False, # optional + array = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnBoolean = tables_db.create_boolean_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = False, # optional - array = False, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-cutover.md b/docs/examples/tablesdb/create-cutover.md index a179bb19..937d6201 100644 --- a/docs/examples/tablesdb/create-cutover.md +++ b/docs/examples/tablesdb/create-cutover.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DatabaseMigration -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DatabaseMigration = await tables_db.create_cutover( + database_id = '<DATABASE_ID>', + migration_id = '<MIGRATION_ID>' + ) + + print(result.model_dump()) -result: DatabaseMigration = tables_db.create_cutover( - database_id = '<DATABASE_ID>', - migration_id = '<MIGRATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md index 30463a6b..73444aef 100644 --- a/docs/examples/tablesdb/create-datetime-column.md +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnDatetime -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnDatetime = await tables_db.create_datetime_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = '2020-10-15T06:38:00.000+00:00', # optional + array = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnDatetime = tables_db.create_datetime_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = '2020-10-15T06:38:00.000+00:00', # optional - array = False, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md index cae71254..18cf9b6d 100644 --- a/docs/examples/tablesdb/create-email-column.md +++ b/docs/examples/tablesdb/create-email-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnEmail -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnEmail = await tables_db.create_email_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'email@example.com', # optional + array = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnEmail = tables_db.create_email_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'email@example.com', # optional - array = False, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md index 645aa8fb..c76ad02c 100644 --- a/docs/examples/tablesdb/create-enum-column.md +++ b/docs/examples/tablesdb/create-enum-column.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnEnum -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 - -tables_db = TablesDB(client) - -result: ColumnEnum = tables_db.create_enum_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - elements = ["active", "inactive"], - required = False, - default = 'active', # optional - array = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnEnum = await tables_db.create_enum_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + elements = ["active", "inactive"], + required = False, + default = 'active', # optional + array = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-failover.md b/docs/examples/tablesdb/create-failover.md index 839f8baf..ea815965 100644 --- a/docs/examples/tablesdb/create-failover.md +++ b/docs/examples/tablesdb/create-failover.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DedicatedDatabase -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DedicatedDatabase = await tables_db.create_failover( + database_id = '<DATABASE_ID>', + target_replica_id = '<TARGET_REPLICA_ID>' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = tables_db.create_failover( - database_id = '<DATABASE_ID>', - target_replica_id = '<TARGET_REPLICA_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md index b57def0a..0a650bac 100644 --- a/docs/examples/tablesdb/create-float-column.md +++ b/docs/examples/tablesdb/create-float-column.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnFloat -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 - -tables_db = TablesDB(client) - -result: ColumnFloat = tables_db.create_float_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - min = 0, # optional - max = 100, # optional - default = 10.5, # optional - array = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnFloat = await tables_db.create_float_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + min = 0, # optional + max = 100, # optional + default = 10.5, # optional + array = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index f953466f..a936ce6e 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnIndex from appwrite.enums.tables_db_index_type import TablesDBIndexType from appwrite.enums.order_by import OrderBy -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 - -tables_db = TablesDB(client) - -result: ColumnIndex = tables_db.create_index( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - type = TablesDBIndexType.KEY, - columns = ["username"], - orders = [OrderBy.ASC], # optional - lengths = [], # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnIndex = await tables_db.create_index( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + type = TablesDBIndexType.KEY, + columns = ["username"], + orders = [OrderBy.ASC], # optional + lengths = [], # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md index 8b989252..fecd73e6 100644 --- a/docs/examples/tablesdb/create-integer-column.md +++ b/docs/examples/tablesdb/create-integer-column.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnInteger -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 - -tables_db = TablesDB(client) - -result: ColumnInteger = tables_db.create_integer_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - min = 0, # optional - max = 100, # optional - default = 10, # optional - array = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnInteger = await tables_db.create_integer_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + min = 0, # optional + max = 100, # optional + default = 10, # optional + array = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md index 9c510780..fe2a3dc9 100644 --- a/docs/examples/tablesdb/create-ip-column.md +++ b/docs/examples/tablesdb/create-ip-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnIp -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnIp = await tables_db.create_ip_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = '192.0.2.0', # optional + array = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnIp = tables_db.create_ip_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = '192.0.2.0', # optional - array = False, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index e32562f8..c56be238 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnLine -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnLine = await tables_db.create_line_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = [[1, 2], [3, 4], [5, 6]], # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnLine = tables_db.create_line_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = [[1, 2], [3, 4], [5, 6]], # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-longtext-column.md b/docs/examples/tablesdb/create-longtext-column.md index 57ed86db..5bff63d5 100644 --- a/docs/examples/tablesdb/create-longtext-column.md +++ b/docs/examples/tablesdb/create-longtext-column.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnLongtext -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 - -tables_db = TablesDB(client) - -result: ColumnLongtext = tables_db.create_longtext_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnLongtext = await tables_db.create_longtext_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-mediumtext-column.md b/docs/examples/tablesdb/create-mediumtext-column.md index 261d801a..fc871e20 100644 --- a/docs/examples/tablesdb/create-mediumtext-column.md +++ b/docs/examples/tablesdb/create-mediumtext-column.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnMediumtext -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 - -tables_db = TablesDB(client) - -result: ColumnMediumtext = tables_db.create_mediumtext_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnMediumtext = await tables_db.create_mediumtext_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-migration.md b/docs/examples/tablesdb/create-migration.md index 46dd29bc..828af220 100644 --- a/docs/examples/tablesdb/create-migration.md +++ b/docs/examples/tablesdb/create-migration.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DatabaseMigration -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DatabaseMigration = await tables_db.create_migration( + database_id = '<DATABASE_ID>', + specification = 's-1vcpu-1gb', + auto_cutover = False # optional + ) + + print(result.model_dump()) -result: DatabaseMigration = tables_db.create_migration( - database_id = '<DATABASE_ID>', - specification = 's-1vcpu-1gb', - auto_cutover = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md index cb2a8c92..99aa766f 100644 --- a/docs/examples/tablesdb/create-operations.md +++ b/docs/examples/tablesdb/create-operations.md @@ -1,18 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Transaction -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) -result: Transaction = tables_db.create_operations( - transaction_id = '<TRANSACTION_ID>', - operations = [ + result: Transaction = await tables_db.create_operations( + transaction_id = '<TRANSACTION_ID>', + operations = [ { "action": "create", "databaseId": "<DATABASE_ID>", @@ -23,7 +27,10 @@ result: Transaction = tables_db.create_operations( } } ] # optional -) + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index e1fdb9e7..be4e5f3f 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnPoint -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnPoint = await tables_db.create_point_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = [1, 2], # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnPoint = tables_db.create_point_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = [1, 2], # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 08c2c1af..bf497743 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnPolygon -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnPolygon = await tables_db.create_polygon_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnPolygon = tables_db.create_polygon_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-query.md b/docs/examples/tablesdb/create-query.md index cdc0ddd5..54a9be44 100644 --- a/docs/examples/tablesdb/create-query.md +++ b/docs/examples/tablesdb/create-query.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import RowList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -tables_db = TablesDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + tables_db = TablesDB(client) + + result: RowList = await tables_db.create_query( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + queries = [], # optional + transaction_id = '<TRANSACTION_ID>', # optional + total = False, # optional + ttl = 0 # optional + ) + + print(result.model_dump()) -result: RowList = tables_db.create_query( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - queries = [], # optional - transaction_id = '<TRANSACTION_ID>', # optional - total = False, # optional - ttl = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md index 1287da28..12ac6e07 100644 --- a/docs/examples/tablesdb/create-relationship-column.md +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnRelationship from appwrite.enums.relationship_type import RelationshipType from appwrite.enums.relation_mutate import RelationMutate -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 - -tables_db = TablesDB(client) - -result: ColumnRelationship = tables_db.create_relationship_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - related_table_id = '<RELATED_TABLE_ID>', - type = RelationshipType.ONETOONE, - two_way = False, # optional - key = '<KEY>', # optional - two_way_key = '<TWO_WAY_KEY>', # optional - on_delete = RelationMutate.CASCADE, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnRelationship = await tables_db.create_relationship_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + related_table_id = '<RELATED_TABLE_ID>', + type = RelationshipType.ONETOONE, + two_way = False, # optional + key = '<KEY>', # optional + two_way_key = '<TWO_WAY_KEY>', # optional + on_delete = RelationMutate.CASCADE, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index aa8a9fe6..a52fd301 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Row from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -tables_db = TablesDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + tables_db = TablesDB(client) -result: Row = tables_db.create_row( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - row_id = '<ROW_ID>', - data = { + result: Row = await tables_db.create_row( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + row_id = '<ROW_ID>', + data = { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 30, "isAdmin": False }, - permissions = [Permission.read(Role.any())], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) + permissions = [Permission.read(Role.any())], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 6dc95621..860ede30 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -1,19 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import RowList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) -result: RowList = tables_db.create_rows( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - rows = [ + result: RowList = await tables_db.create_rows( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + rows = [ { "$id": "example1", "username": "walter.obrien", @@ -23,8 +27,11 @@ result: RowList = tables_db.create_rows( "isAdmin": false } ], - transaction_id = '<TRANSACTION_ID>' # optional -) + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md index 27a96af2..75d34755 100644 --- a/docs/examples/tablesdb/create-string-column.md +++ b/docs/examples/tablesdb/create-string-column.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnString -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 - -tables_db = TablesDB(client) - -result: ColumnString = tables_db.create_string_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - size = 1, - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnString = await tables_db.create_string_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + size = 1, + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md index 5ddf3b99..9d2e4236 100644 --- a/docs/examples/tablesdb/create-table.md +++ b/docs/examples/tablesdb/create-table.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Table from appwrite.permission import Permission from appwrite.role import Role -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 - -tables_db = TablesDB(client) - -result: Table = tables_db.create_table( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - name = '<NAME>', - permissions = [Permission.read(Role.any())], # optional - row_security = False, # optional - enabled = False, # optional - columns = [], # optional - indexes = [], # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Table = await tables_db.create_table( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + name = '<NAME>', + permissions = [Permission.read(Role.any())], # optional + row_security = False, # optional + enabled = False, # optional + columns = [], # optional + indexes = [], # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-text-column.md b/docs/examples/tablesdb/create-text-column.md index f7c63339..ebc77a9d 100644 --- a/docs/examples/tablesdb/create-text-column.md +++ b/docs/examples/tablesdb/create-text-column.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnText -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 - -tables_db = TablesDB(client) - -result: ColumnText = tables_db.create_text_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnText = await tables_db.create_text_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-transaction.md b/docs/examples/tablesdb/create-transaction.md index b48e262f..f3e23df0 100644 --- a/docs/examples/tablesdb/create-transaction.md +++ b/docs/examples/tablesdb/create-transaction.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Transaction -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Transaction = await tables_db.create_transaction( + ttl = 60 # optional + ) + + print(result.model_dump()) -result: Transaction = tables_db.create_transaction( - ttl = 60 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md index ae9a5ecc..73f9fdfd 100644 --- a/docs/examples/tablesdb/create-url-column.md +++ b/docs/examples/tablesdb/create-url-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnUrl -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnUrl = await tables_db.create_url_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'https://example.com', # optional + array = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnUrl = tables_db.create_url_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'https://example.com', # optional - array = False, # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create-varchar-column.md b/docs/examples/tablesdb/create-varchar-column.md index d181df49..a1731bbf 100644 --- a/docs/examples/tablesdb/create-varchar-column.md +++ b/docs/examples/tablesdb/create-varchar-column.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnVarchar -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 - -tables_db = TablesDB(client) - -result: ColumnVarchar = tables_db.create_varchar_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - size = 1, - required = False, - default = 'Hello World', # optional - array = False, # optional - encrypt = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnVarchar = await tables_db.create_varchar_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + size = 1, + required = False, + default = 'Hello World', # optional + array = False, # optional + encrypt = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index ff89d119..66ebc66b 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Database -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Database = await tables_db.create( + database_id = '<DATABASE_ID>', + name = '<NAME>', + enabled = False, # optional + description = '<DESCRIPTION>', # optional + specification = 'serverless', # optional + replicas = 0, # optional + sync_mode = 'async' # optional + ) + + print(result.model_dump()) -result: Database = tables_db.create( - database_id = '<DATABASE_ID>', - name = '<NAME>', - enabled = False, # optional - description = '<DESCRIPTION>', # optional - specification = 'serverless', # optional - replicas = 0, # optional - sync_mode = 'async' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index 6ee2f902..e487ca19 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Row -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -tables_db = TablesDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + tables_db = TablesDB(client) + + result: Row = await tables_db.decrement_row_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + row_id = '<ROW_ID>', + column = '<COLUMN>', + value = 1, # optional + min = 0, # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) -result: Row = tables_db.decrement_row_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - row_id = '<ROW_ID>', - column = '<COLUMN>', - value = 1, # optional - min = 0, # optional - transaction_id = '<TRANSACTION_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md index 110fb17f..a409d413 100644 --- a/docs/examples/tablesdb/delete-column.md +++ b/docs/examples/tablesdb/delete-column.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result = await tables_db.delete_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>' + ) + -result = tables_db.delete_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md index 8d9e2adf..22fa7f59 100644 --- a/docs/examples/tablesdb/delete-index.md +++ b/docs/examples/tablesdb/delete-index.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result = await tables_db.delete_index( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>' + ) + -result = tables_db.delete_index( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/delete-migration.md b/docs/examples/tablesdb/delete-migration.md index 9442ae34..035ce333 100644 --- a/docs/examples/tablesdb/delete-migration.md +++ b/docs/examples/tablesdb/delete-migration.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result = await tables_db.delete_migration( + database_id = '<DATABASE_ID>', + migration_id = '<MIGRATION_ID>' + ) + -result = tables_db.delete_migration( - database_id = '<DATABASE_ID>', - migration_id = '<MIGRATION_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md index 7615459e..8b2bdba6 100644 --- a/docs/examples/tablesdb/delete-row.md +++ b/docs/examples/tablesdb/delete-row.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -tables_db = TablesDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + tables_db = TablesDB(client) + + result = await tables_db.delete_row( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + row_id = '<ROW_ID>', + transaction_id = '<TRANSACTION_ID>' # optional + ) + -result = tables_db.delete_row( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - row_id = '<ROW_ID>', - transaction_id = '<TRANSACTION_ID>' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 9ed0672d..62295754 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import RowList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: RowList = await tables_db.delete_rows( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + queries = ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"<ROW_ID>\"]}"], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) -result: RowList = tables_db.delete_rows( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - queries = ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"<ROW_ID>\"]}"], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/delete-table.md b/docs/examples/tablesdb/delete-table.md index 59975370..ba98c975 100644 --- a/docs/examples/tablesdb/delete-table.md +++ b/docs/examples/tablesdb/delete-table.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result = await tables_db.delete_table( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>' + ) + -result = tables_db.delete_table( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/delete-transaction.md b/docs/examples/tablesdb/delete-transaction.md index cbbbc5d9..67a6a411 100644 --- a/docs/examples/tablesdb/delete-transaction.md +++ b/docs/examples/tablesdb/delete-transaction.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result = await tables_db.delete_transaction( + transaction_id = '<TRANSACTION_ID>' + ) + -result = tables_db.delete_transaction( - transaction_id = '<TRANSACTION_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/delete.md b/docs/examples/tablesdb/delete.md index 9859c1e9..fb56e6e5 100644 --- a/docs/examples/tablesdb/delete.md +++ b/docs/examples/tablesdb/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result = await tables_db.delete( + database_id = '<DATABASE_ID>' + ) + -result = tables_db.delete( - database_id = '<DATABASE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md index 1a4dd142..9e5817d7 100644 --- a/docs/examples/tablesdb/get-column.md +++ b/docs/examples/tablesdb/get-column.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnBoolean @@ -21,18 +23,23 @@ from appwrite.models import ColumnLongtext from appwrite.models import ColumnString from typing import Union -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Union[ColumnBoolean, ColumnBigint, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString] = await tables_db.get_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>' + ) + + print(result.model_dump()) -result: Union[ColumnBoolean, ColumnBigint, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString] = tables_db.get_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md index 2bce205d..029f9ec8 100644 --- a/docs/examples/tablesdb/get-index.md +++ b/docs/examples/tablesdb/get-index.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnIndex -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnIndex = await tables_db.get_index( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>' + ) + + print(result.model_dump()) -result: ColumnIndex = tables_db.get_index( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/get-migration.md b/docs/examples/tablesdb/get-migration.md index 2efe0b63..45fd9ba9 100644 --- a/docs/examples/tablesdb/get-migration.md +++ b/docs/examples/tablesdb/get-migration.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DatabaseMigration -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DatabaseMigration = await tables_db.get_migration( + database_id = '<DATABASE_ID>', + migration_id = '<MIGRATION_ID>' + ) + + print(result.model_dump()) -result: DatabaseMigration = tables_db.get_migration( - database_id = '<DATABASE_ID>', - migration_id = '<MIGRATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/get-replicas.md b/docs/examples/tablesdb/get-replicas.md index abd5df1b..c6810fa9 100644 --- a/docs/examples/tablesdb/get-replicas.md +++ b/docs/examples/tablesdb/get-replicas.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DedicatedDatabaseReplicas -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DedicatedDatabaseReplicas = await tables_db.get_replicas( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseReplicas = tables_db.get_replicas( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md index 55609e25..e7fef472 100644 --- a/docs/examples/tablesdb/get-row.md +++ b/docs/examples/tablesdb/get-row.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Row -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -tables_db = TablesDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + tables_db = TablesDB(client) + + result: Row = await tables_db.get_row( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + row_id = '<ROW_ID>', + queries = [], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) -result: Row = tables_db.get_row( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - row_id = '<ROW_ID>', - queries = [], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/get-status.md b/docs/examples/tablesdb/get-status.md index 0695da1f..ef2c6932 100644 --- a/docs/examples/tablesdb/get-status.md +++ b/docs/examples/tablesdb/get-status.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DatabaseStatus -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DatabaseStatus = await tables_db.get_status( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DatabaseStatus = tables_db.get_status( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md index da6a4bcb..d5f48b97 100644 --- a/docs/examples/tablesdb/get-table.md +++ b/docs/examples/tablesdb/get-table.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Table -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Table = await tables_db.get_table( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>' + ) + + print(result.model_dump()) -result: Table = tables_db.get_table( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/get-transaction.md b/docs/examples/tablesdb/get-transaction.md index b51fcc26..1a3b34f3 100644 --- a/docs/examples/tablesdb/get-transaction.md +++ b/docs/examples/tablesdb/get-transaction.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Transaction -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Transaction = await tables_db.get_transaction( + transaction_id = '<TRANSACTION_ID>' + ) + + print(result.model_dump()) -result: Transaction = tables_db.get_transaction( - transaction_id = '<TRANSACTION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md index 036deeec..21938346 100644 --- a/docs/examples/tablesdb/get.md +++ b/docs/examples/tablesdb/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Database -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Database = await tables_db.get( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: Database = tables_db.get( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index ae25a0b6..25951cb3 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Row -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -tables_db = TablesDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + tables_db = TablesDB(client) + + result: Row = await tables_db.increment_row_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + row_id = '<ROW_ID>', + column = '<COLUMN>', + value = 1, # optional + max = 100, # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) -result: Row = tables_db.increment_row_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - row_id = '<ROW_ID>', - column = '<COLUMN>', - value = 1, # optional - max = 100, # optional - transaction_id = '<TRANSACTION_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md index 3a450487..5b41041e 100644 --- a/docs/examples/tablesdb/list-columns.md +++ b/docs/examples/tablesdb/list-columns.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnList = await tables_db.list_columns( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: ColumnList = tables_db.list_columns( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md index b1ccf1a4..9d0872f0 100644 --- a/docs/examples/tablesdb/list-indexes.md +++ b/docs/examples/tablesdb/list-indexes.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnIndexList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnIndexList = await tables_db.list_indexes( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: ColumnIndexList = tables_db.list_indexes( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/list-migrations.md b/docs/examples/tablesdb/list-migrations.md index 99665efa..ffa2926a 100644 --- a/docs/examples/tablesdb/list-migrations.md +++ b/docs/examples/tablesdb/list-migrations.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DatabaseMigrationList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DatabaseMigrationList = await tables_db.list_migrations( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DatabaseMigrationList = tables_db.list_migrations( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/list-operations.md b/docs/examples/tablesdb/list-operations.md index aa3754a5..41a1f0c0 100644 --- a/docs/examples/tablesdb/list-operations.md +++ b/docs/examples/tablesdb/list-operations.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DedicatedDatabaseOperationList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DedicatedDatabaseOperationList = await tables_db.list_operations( + database_id = '<DATABASE_ID>', + status = 'queued', # optional + limit = 1, # optional + offset = 0 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseOperationList = tables_db.list_operations( - database_id = '<DATABASE_ID>', - status = 'queued', # optional - limit = 1, # optional - offset = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index 0ef94104..caf4a743 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import RowList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -tables_db = TablesDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + tables_db = TablesDB(client) + + result: RowList = await tables_db.list_rows( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + queries = [], # optional + transaction_id = '<TRANSACTION_ID>', # optional + total = False, # optional + ttl = 0 # optional + ) + + print(result.model_dump()) -result: RowList = tables_db.list_rows( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - queries = [], # optional - transaction_id = '<TRANSACTION_ID>', # optional - total = False, # optional - ttl = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/list-specifications.md b/docs/examples/tablesdb/list-specifications.md index c0fc0f8b..487dfee0 100644 --- a/docs/examples/tablesdb/list-specifications.md +++ b/docs/examples/tablesdb/list-specifications.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DedicatedDatabaseSpecificationList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DedicatedDatabaseSpecificationList = await tables_db.list_specifications() + + print(result.model_dump()) -result: DedicatedDatabaseSpecificationList = tables_db.list_specifications() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md index 589aaa98..5c828b19 100644 --- a/docs/examples/tablesdb/list-tables.md +++ b/docs/examples/tablesdb/list-tables.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import TableList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: TableList = await tables_db.list_tables( + database_id = '<DATABASE_ID>', + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: TableList = tables_db.list_tables( - database_id = '<DATABASE_ID>', - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md index ded73360..4f9f8a38 100644 --- a/docs/examples/tablesdb/list-transactions.md +++ b/docs/examples/tablesdb/list-transactions.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import TransactionList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: TransactionList = await tables_db.list_transactions( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: TransactionList = tables_db.list_transactions( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md index cfc352d1..b3f485ca 100644 --- a/docs/examples/tablesdb/list.md +++ b/docs/examples/tablesdb/list.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import DatabaseList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: DatabaseList = await tables_db.list( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: DatabaseList = tables_db.list( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-big-int-column.md b/docs/examples/tablesdb/update-big-int-column.md index 76343d4c..1f027d65 100644 --- a/docs/examples/tablesdb/update-big-int-column.md +++ b/docs/examples/tablesdb/update-big-int-column.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnBigint -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 - -tables_db = TablesDB(client) - -result: ColumnBigint = tables_db.update_big_int_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 0, - min = 0, # optional - max = 1000000, # optional - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnBigint = await tables_db.update_big_int_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 0, + min = 0, # optional + max = 1000000, # optional + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md index 8b2f0be8..bcb6d41c 100644 --- a/docs/examples/tablesdb/update-boolean-column.md +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnBoolean -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnBoolean = await tables_db.update_boolean_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = False, + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnBoolean = tables_db.update_boolean_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = False, - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md index 10f3146e..150b00d1 100644 --- a/docs/examples/tablesdb/update-datetime-column.md +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnDatetime -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnDatetime = await tables_db.update_datetime_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = '2020-10-15T06:38:00.000+00:00', + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnDatetime = tables_db.update_datetime_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = '2020-10-15T06:38:00.000+00:00', - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md index 272d0c00..1abaa6ad 100644 --- a/docs/examples/tablesdb/update-email-column.md +++ b/docs/examples/tablesdb/update-email-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnEmail -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnEmail = await tables_db.update_email_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'email@example.com', + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnEmail = tables_db.update_email_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'email@example.com', - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md index 41ca8bcf..f7cc8228 100644 --- a/docs/examples/tablesdb/update-enum-column.md +++ b/docs/examples/tablesdb/update-enum-column.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnEnum -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 - -tables_db = TablesDB(client) - -result: ColumnEnum = tables_db.update_enum_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - elements = ["active", "inactive"], - required = False, - default = 'active', - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnEnum = await tables_db.update_enum_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + elements = ["active", "inactive"], + required = False, + default = 'active', + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md index e851722f..9f2e92a1 100644 --- a/docs/examples/tablesdb/update-float-column.md +++ b/docs/examples/tablesdb/update-float-column.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnFloat -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 - -tables_db = TablesDB(client) - -result: ColumnFloat = tables_db.update_float_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 10.5, - min = 0, # optional - max = 100, # optional - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnFloat = await tables_db.update_float_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 10.5, + min = 0, # optional + max = 100, # optional + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md index 6f7c7916..2c6c33ea 100644 --- a/docs/examples/tablesdb/update-integer-column.md +++ b/docs/examples/tablesdb/update-integer-column.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnInteger -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 - -tables_db = TablesDB(client) - -result: ColumnInteger = tables_db.update_integer_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 10, - min = 0, # optional - max = 100, # optional - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnInteger = await tables_db.update_integer_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 10, + min = 0, # optional + max = 100, # optional + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md index f94638c3..5ae0bf2b 100644 --- a/docs/examples/tablesdb/update-ip-column.md +++ b/docs/examples/tablesdb/update-ip-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnIp -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnIp = await tables_db.update_ip_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = '192.0.2.0', + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnIp = tables_db.update_ip_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = '192.0.2.0', - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index 8ef8353a..a521fcf9 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnLine -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnLine = await tables_db.update_line_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = [[1, 2], [3, 4], [5, 6]], # optional + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnLine = tables_db.update_line_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = [[1, 2], [3, 4], [5, 6]], # optional - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-longtext-column.md b/docs/examples/tablesdb/update-longtext-column.md index 154e7b36..570688c4 100644 --- a/docs/examples/tablesdb/update-longtext-column.md +++ b/docs/examples/tablesdb/update-longtext-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnLongtext -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnLongtext = await tables_db.update_longtext_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'Hello World', + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnLongtext = tables_db.update_longtext_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'Hello World', - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-mediumtext-column.md b/docs/examples/tablesdb/update-mediumtext-column.md index 2c92bd4f..2ff29069 100644 --- a/docs/examples/tablesdb/update-mediumtext-column.md +++ b/docs/examples/tablesdb/update-mediumtext-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnMediumtext -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnMediumtext = await tables_db.update_mediumtext_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'Hello World', + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnMediumtext = tables_db.update_mediumtext_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'Hello World', - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index a232c2e1..3c108f91 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnPoint -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnPoint = await tables_db.update_point_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = [1, 2], # optional + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnPoint = tables_db.update_point_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = [1, 2], # optional - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index 1237ffe1..53b13757 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnPolygon -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnPolygon = await tables_db.update_polygon_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnPolygon = tables_db.update_polygon_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md index 3bc94157..1493949a 100644 --- a/docs/examples/tablesdb/update-relationship-column.md +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnRelationship from appwrite.enums.relation_mutate import RelationMutate -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnRelationship = await tables_db.update_relationship_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + on_delete = RelationMutate.CASCADE, # optional + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnRelationship = tables_db.update_relationship_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - on_delete = RelationMutate.CASCADE, # optional - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 30522e7b..ce2c4bd5 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Row from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -tables_db = TablesDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + tables_db = TablesDB(client) -result: Row = tables_db.update_row( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - row_id = '<ROW_ID>', - data = { + result: Row = await tables_db.update_row( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + row_id = '<ROW_ID>', + data = { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 33, "isAdmin": False }, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) + permissions = [Permission.read(Role.any())], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index dc3641b3..77830add 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import RowList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) -result: RowList = tables_db.update_rows( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - data = { + result: RowList = await tables_db.update_rows( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + data = { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 33, "isAdmin": False }, # optional - queries = [], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) + queries = [], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md index 3dddf79b..8f004e87 100644 --- a/docs/examples/tablesdb/update-string-column.md +++ b/docs/examples/tablesdb/update-string-column.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnString -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 - -tables_db = TablesDB(client) - -result: ColumnString = tables_db.update_string_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'Hello World', - size = 1, # optional - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnString = await tables_db.update_string_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'Hello World', + size = 1, # optional + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index e1d8ff90..494d2769 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Table from appwrite.permission import Permission from appwrite.role import Role -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 - -tables_db = TablesDB(client) - -result: Table = tables_db.update_table( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - name = '<NAME>', # optional - permissions = [Permission.read(Role.any())], # optional - row_security = False, # optional - enabled = False, # optional - purge = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Table = await tables_db.update_table( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + name = '<NAME>', # optional + permissions = [Permission.read(Role.any())], # optional + row_security = False, # optional + enabled = False, # optional + purge = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-text-column.md b/docs/examples/tablesdb/update-text-column.md index b7999d41..4ba0e2a1 100644 --- a/docs/examples/tablesdb/update-text-column.md +++ b/docs/examples/tablesdb/update-text-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnText -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnText = await tables_db.update_text_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'Hello World', + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnText = tables_db.update_text_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'Hello World', - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-transaction.md b/docs/examples/tablesdb/update-transaction.md index 999f53b1..6094fd69 100644 --- a/docs/examples/tablesdb/update-transaction.md +++ b/docs/examples/tablesdb/update-transaction.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Transaction -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Transaction = await tables_db.update_transaction( + transaction_id = '<TRANSACTION_ID>', + commit = False, # optional + rollback = False # optional + ) + + print(result.model_dump()) -result: Transaction = tables_db.update_transaction( - transaction_id = '<TRANSACTION_ID>', - commit = False, # optional - rollback = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md index c4fcff52..11b0ba09 100644 --- a/docs/examples/tablesdb/update-url-column.md +++ b/docs/examples/tablesdb/update-url-column.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnUrl -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnUrl = await tables_db.update_url_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'https://example.com', + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) -result: ColumnUrl = tables_db.update_url_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'https://example.com', - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update-varchar-column.md b/docs/examples/tablesdb/update-varchar-column.md index 88133183..d1f53002 100644 --- a/docs/examples/tablesdb/update-varchar-column.md +++ b/docs/examples/tablesdb/update-varchar-column.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnVarchar -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 - -tables_db = TablesDB(client) - -result: ColumnVarchar = tables_db.update_varchar_column( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - key = '<KEY>', - required = False, - default = 'Hello World', - size = 1, # optional - new_key = '<NEW_KEY>', # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + tables_db = TablesDB(client) + + result: ColumnVarchar = await tables_db.update_varchar_column( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + key = '<KEY>', + required = False, + default = 'Hello World', + size = 1, # optional + new_key = '<NEW_KEY>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 7b8b2225..a299a296 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Database -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) + + result: Database = await tables_db.update( + database_id = '<DATABASE_ID>', + name = '<NAME>', # optional + enabled = False, # optional + description = '<DESCRIPTION>', # optional + specification = 'serverless', # optional + replicas = 0, # optional + sync_mode = 'async' # optional + ) + + print(result.model_dump()) -result: Database = tables_db.update( - database_id = '<DATABASE_ID>', - name = '<NAME>', # optional - enabled = False, # optional - description = '<DESCRIPTION>', # optional - specification = 'serverless', # optional - replicas = 0, # optional - sync_mode = 'async' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index c511545c..acdd28da 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -1,31 +1,38 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import Row from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -tables_db = TablesDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + tables_db = TablesDB(client) -result: Row = tables_db.upsert_row( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - row_id = '<ROW_ID>', - data = { + result: Row = await tables_db.upsert_row( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + row_id = '<ROW_ID>', + data = { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 33, "isAdmin": False }, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) + permissions = [Permission.read(Role.any())], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 673b9a2b..98eb0687 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -1,19 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import RowList -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 -tables_db = TablesDB(client) +async def main(): + 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 + + tables_db = TablesDB(client) -result: RowList = tables_db.upsert_rows( - database_id = '<DATABASE_ID>', - table_id = '<TABLE_ID>', - rows = [ + result: RowList = await tables_db.upsert_rows( + database_id = '<DATABASE_ID>', + table_id = '<TABLE_ID>', + rows = [ { "$id": "example1", "username": "walter.obrien", @@ -23,8 +27,11 @@ result: RowList = tables_db.upsert_rows( "isAdmin": false } ], - transaction_id = '<TRANSACTION_ID>' # optional -) + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/create-installation.md b/docs/examples/teams/create-installation.md index 185e379f..6bb27918 100644 --- a/docs/examples/teams/create-installation.md +++ b/docs/examples/teams/create-installation.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import AppInstallation -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: AppInstallation = await teams.create_installation( + team_id = '<TEAM_ID>', + app_id = '<APP_ID>', + authorization_details = '<AUTHORIZATION_DETAILS>' # optional + ) + + print(result.model_dump()) -result: AppInstallation = teams.create_installation( - team_id = '<TEAM_ID>', - app_id = '<APP_ID>', - authorization_details = '<AUTHORIZATION_DETAILS>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index aa247d86..d2fb7a58 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import Membership -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with - -teams = Teams(client) - -result: Membership = teams.create_membership( - team_id = '<TEAM_ID>', - roles = ["editor"], - email = 'email@example.com', # optional - user_id = '<USER_ID>', # optional - phone = '+12065550100', # optional - url = 'https://example.com', # optional - name = '<NAME>', # optional - membership_id = '<MEMBERSHIP_ID>' # optional -) - -print(result.model_dump()) + +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: Membership = await teams.create_membership( + team_id = '<TEAM_ID>', + roles = ["editor"], + email = 'email@example.com', # optional + user_id = '<USER_ID>', # optional + phone = '+12065550100', # optional + url = 'https://example.com', # optional + name = '<NAME>', # optional + membership_id = '<MEMBERSHIP_ID>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index 965d854a..ad47eeb9 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import Team -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: Team = await teams.create( + team_id = '<TEAM_ID>', + name = '<NAME>', + roles = [] # optional + ) + + print(result.model_dump()) -result: Team = teams.create( - team_id = '<TEAM_ID>', - name = '<NAME>', - roles = [] # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/delete-installation.md b/docs/examples/teams/delete-installation.md index 912195d3..7b26d090 100644 --- a/docs/examples/teams/delete-installation.md +++ b/docs/examples/teams/delete-installation.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result = await teams.delete_installation( + team_id = '<TEAM_ID>', + installation_id = '<INSTALLATION_ID>' + ) + -result = teams.delete_installation( - team_id = '<TEAM_ID>', - installation_id = '<INSTALLATION_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 2ed97d15..cda2c3f5 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result = await teams.delete_membership( + team_id = '<TEAM_ID>', + membership_id = '<MEMBERSHIP_ID>' + ) + -result = teams.delete_membership( - team_id = '<TEAM_ID>', - membership_id = '<MEMBERSHIP_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index c9a65b37..a8815e52 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result = await teams.delete( + team_id = '<TEAM_ID>' + ) + -result = teams.delete( - team_id = '<TEAM_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/get-installation.md b/docs/examples/teams/get-installation.md index 06ad5f01..a47d6e9b 100644 --- a/docs/examples/teams/get-installation.md +++ b/docs/examples/teams/get-installation.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import AppInstallation -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: AppInstallation = await teams.get_installation( + team_id = '<TEAM_ID>', + installation_id = '<INSTALLATION_ID>' + ) + + print(result.model_dump()) -result: AppInstallation = teams.get_installation( - team_id = '<TEAM_ID>', - installation_id = '<INSTALLATION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index 54ad0cd3..88c42075 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import Membership -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: Membership = await teams.get_membership( + team_id = '<TEAM_ID>', + membership_id = '<MEMBERSHIP_ID>' + ) + + print(result.model_dump()) -result: Membership = teams.get_membership( - team_id = '<TEAM_ID>', - membership_id = '<MEMBERSHIP_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index 20ae5962..68a160ef 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import Preferences -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: Preferences = await teams.get_prefs( + team_id = '<TEAM_ID>' + ) + + print(result.model_dump()) -result: Preferences = teams.get_prefs( - team_id = '<TEAM_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index 3b5116c9..1f853447 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import Team -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: Team = await teams.get( + team_id = '<TEAM_ID>' + ) + + print(result.model_dump()) -result: Team = teams.get( - team_id = '<TEAM_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/list-installations.md b/docs/examples/teams/list-installations.md index fbc9485b..abacfd23 100644 --- a/docs/examples/teams/list-installations.md +++ b/docs/examples/teams/list-installations.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import AppInstallationList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: AppInstallationList = await teams.list_installations( + team_id = '<TEAM_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: AppInstallationList = teams.list_installations( - team_id = '<TEAM_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 8acc9d14..d68d855f 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import MembershipList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: MembershipList = await teams.list_memberships( + team_id = '<TEAM_ID>', + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: MembershipList = teams.list_memberships( - team_id = '<TEAM_ID>', - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index 9fcd1ddb..472a9198 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import TeamList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: TeamList = await teams.list( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: TeamList = teams.list( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/update-installation.md b/docs/examples/teams/update-installation.md index a5df1213..6d78ffeb 100644 --- a/docs/examples/teams/update-installation.md +++ b/docs/examples/teams/update-installation.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import AppInstallation -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: AppInstallation = await teams.update_installation( + team_id = '<TEAM_ID>', + installation_id = '<INSTALLATION_ID>', + authorization_details = '<AUTHORIZATION_DETAILS>' # optional + ) + + print(result.model_dump()) -result: AppInstallation = teams.update_installation( - team_id = '<TEAM_ID>', - installation_id = '<INSTALLATION_ID>', - authorization_details = '<AUTHORIZATION_DETAILS>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index b836d820..0c53472d 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import Membership -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: Membership = await teams.update_membership_status( + team_id = '<TEAM_ID>', + membership_id = '<MEMBERSHIP_ID>', + user_id = '<USER_ID>', + secret = '<SECRET>' + ) + + print(result.model_dump()) -result: Membership = teams.update_membership_status( - team_id = '<TEAM_ID>', - membership_id = '<MEMBERSHIP_ID>', - user_id = '<USER_ID>', - secret = '<SECRET>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index e6db1a04..be01e0b7 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import Membership -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: Membership = await teams.update_membership( + team_id = '<TEAM_ID>', + membership_id = '<MEMBERSHIP_ID>', + roles = ["editor"] + ) + + print(result.model_dump()) -result: Membership = teams.update_membership( - team_id = '<TEAM_ID>', - membership_id = '<MEMBERSHIP_ID>', - roles = ["editor"] -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index 376d6c3f..565f9b98 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import Team -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: Team = await teams.update_name( + team_id = '<TEAM_ID>', + name = '<NAME>' + ) + + print(result.model_dump()) -result: Team = teams.update_name( - team_id = '<TEAM_ID>', - name = '<NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index 23f48789..9cc6705f 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.teams import Teams from appwrite.models import Preferences -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -teams = Teams(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + teams = Teams(client) + + result: Preferences = await teams.update_prefs( + team_id = '<TEAM_ID>', + prefs = {} + ) + + print(result.model_dump()) -result: Preferences = teams.update_prefs( - team_id = '<TEAM_ID>', - prefs = {} -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md index 73ad1355..94e82cab 100644 --- a/docs/examples/tokens/create-file-token.md +++ b/docs/examples/tokens/create-file-token.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tokens import Tokens from appwrite.models import ResourceToken -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) +async def main(): + 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: ResourceToken = await tokens.create_file_token( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + expire = '2020-10-15T06:38:00.000+00:00' # optional + ) + + print(result.model_dump()) -result: ResourceToken = tokens.create_file_token( - bucket_id = '<BUCKET_ID>', - file_id = '<FILE_ID>', - expire = '2020-10-15T06:38:00.000+00:00' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tokens/delete.md b/docs/examples/tokens/delete.md index 80777fd0..22ee9241 100644 --- a/docs/examples/tokens/delete.md +++ b/docs/examples/tokens/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await tokens.delete( + token_id = '<TOKEN_ID>' + ) + -result = tokens.delete( - token_id = '<TOKEN_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/tokens/get.md b/docs/examples/tokens/get.md index 83a9649a..1a978725 100644 --- a/docs/examples/tokens/get.md +++ b/docs/examples/tokens/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tokens import Tokens from appwrite.models import ResourceToken -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) +async def main(): + 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: ResourceToken = await tokens.get( + token_id = '<TOKEN_ID>' + ) + + print(result.model_dump()) -result: ResourceToken = tokens.get( - token_id = '<TOKEN_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md index d5700165..6405329c 100644 --- a/docs/examples/tokens/list.md +++ b/docs/examples/tokens/list.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tokens import Tokens from appwrite.models import ResourceTokenList -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) +async def main(): + 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: ResourceTokenList = await tokens.list( + bucket_id = '<BUCKET_ID>', + file_id = '<FILE_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: ResourceTokenList = tokens.list( - bucket_id = '<BUCKET_ID>', - file_id = '<FILE_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md index 6b5ad4b4..2c6b8842 100644 --- a/docs/examples/tokens/update.md +++ b/docs/examples/tokens/update.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.tokens import Tokens from appwrite.models import ResourceToken -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) +async def main(): + 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: ResourceToken = await tokens.update( + token_id = '<TOKEN_ID>', + expire = '2020-10-15T06:38:00.000+00:00' # optional + ) + + print(result.model_dump()) -result: ResourceToken = tokens.update( - token_id = '<TOKEN_ID>', - expire = '2020-10-15T06:38:00.000+00:00' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-argon-2-user.md b/docs/examples/users/create-argon-2-user.md index cd3e2bc9..602085f1 100644 --- a/docs/examples/users/create-argon-2-user.md +++ b/docs/examples/users/create-argon-2-user.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.create_argon2_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + name = '<NAME>' # optional + ) + + print(result.model_dump()) -result: User = users.create_argon2_user( - user_id = '<USER_ID>', - email = 'email@example.com', - password = 'password', - name = '<NAME>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md index d3ab13e6..b7fcd71c 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.create_bcrypt_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + name = '<NAME>' # optional + ) + + print(result.model_dump()) -result: User = users.create_bcrypt_user( - user_id = '<USER_ID>', - email = 'email@example.com', - password = 'password', - name = '<NAME>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-jwt.md b/docs/examples/users/create-jwt.md index 109ad50a..7bcb7c02 100644 --- a/docs/examples/users/create-jwt.md +++ b/docs/examples/users/create-jwt.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Jwt -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) +async def main(): + 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: Jwt = await users.create_jwt( + user_id = '<USER_ID>', + session_id = 'recent()', # optional + duration = 0 # optional + ) + + print(result.model_dump()) -result: Jwt = users.create_jwt( - user_id = '<USER_ID>', - session_id = 'recent()', # optional - duration = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-md-5-user.md b/docs/examples/users/create-md-5-user.md index 53b45bfe..13bcc239 100644 --- a/docs/examples/users/create-md-5-user.md +++ b/docs/examples/users/create-md-5-user.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.create_md5_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + name = '<NAME>' # optional + ) + + print(result.model_dump()) -result: User = users.create_md5_user( - user_id = '<USER_ID>', - email = 'email@example.com', - password = 'password', - name = '<NAME>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index 0c83df49..770145e6 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import MfaRecoveryCodes -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) +async def main(): + 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: MfaRecoveryCodes = await users.create_mfa_recovery_codes( + user_id = '<USER_ID>' + ) + + print(result.model_dump()) -result: MfaRecoveryCodes = users.create_mfa_recovery_codes( - user_id = '<USER_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-ph-pass-user.md b/docs/examples/users/create-ph-pass-user.md index 456a04b0..16b5672b 100644 --- a/docs/examples/users/create-ph-pass-user.md +++ b/docs/examples/users/create-ph-pass-user.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.create_ph_pass_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + name = '<NAME>' # optional + ) + + print(result.model_dump()) -result: User = users.create_ph_pass_user( - user_id = '<USER_ID>', - email = 'email@example.com', - password = 'password', - name = '<NAME>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index e802270b..10a239f4 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await 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 + ) + + print(result.model_dump()) -result: User = 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 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index ecfa6029..179d7086 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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: User = users.create_scrypt_user( - user_id = '<USER_ID>', - email = 'email@example.com', - password = 'password', - password_salt = '<PASSWORD_SALT>', - password_cpu = 8, - password_memory = 65536, - password_parallel = 1, - password_length = 64, - name = '<NAME>' # optional -) - -print(result.model_dump()) + +async def main(): + 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: User = await users.create_scrypt_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + password_salt = '<PASSWORD_SALT>', + password_cpu = 8, + password_memory = 65536, + password_parallel = 1, + password_length = 64, + name = '<NAME>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md index 38a6dbcc..509c0c09 100644 --- a/docs/examples/users/create-session.md +++ b/docs/examples/users/create-session.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Session -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) +async def main(): + 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: Session = await users.create_session( + user_id = '<USER_ID>' + ) + + print(result.model_dump()) -result: Session = users.create_session( - user_id = '<USER_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-sha-user.md b/docs/examples/users/create-sha-user.md index 9b7ef7d3..43c8c892 100644 --- a/docs/examples/users/create-sha-user.md +++ b/docs/examples/users/create-sha-user.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User from appwrite.enums.password_hash import PasswordHash -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) +async def main(): + 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: User = await users.create_sha_user( + user_id = '<USER_ID>', + email = 'email@example.com', + password = 'password', + password_version = PasswordHash.SHA1, # optional + name = '<NAME>' # optional + ) + + print(result.model_dump()) -result: User = users.create_sha_user( - user_id = '<USER_ID>', - email = 'email@example.com', - password = 'password', - password_version = PasswordHash.SHA1, # optional - name = '<NAME>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md index 36ce660f..1b1d1b0a 100644 --- a/docs/examples/users/create-target.md +++ b/docs/examples/users/create-target.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Target from appwrite.enums.messaging_provider_type 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) +async def main(): + 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: Target = await 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 + ) + + print(result.model_dump()) -result: Target = 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 -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md index d7520f5e..8737b721 100644 --- a/docs/examples/users/create-token.md +++ b/docs/examples/users/create-token.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Token -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) +async def main(): + 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: Token = await users.create_token( + user_id = '<USER_ID>', + length = 4, # optional + expire = 60 # optional + ) + + print(result.model_dump()) -result: Token = users.create_token( - user_id = '<USER_ID>', - length = 4, # optional - expire = 60 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 0a7a7eee..d725ace6 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.create( + user_id = '<USER_ID>', + email = 'email@example.com', # optional + phone = '+12065550100', # optional + password = 'password', # optional + name = '<NAME>' # optional + ) + + print(result.model_dump()) -result: User = users.create( - user_id = '<USER_ID>', - email = 'email@example.com', # optional - phone = '+12065550100', # optional - password = 'password', # optional - name = '<NAME>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md index 06af6681..aa78f1ea 100644 --- a/docs/examples/users/delete-identity.md +++ b/docs/examples/users/delete-identity.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await users.delete_identity( + identity_id = '<IDENTITY_ID>' + ) + -result = users.delete_identity( - identity_id = '<IDENTITY_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md index b7cc38c0..dc9ef722 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.enums.authenticator_type 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) +async def main(): + 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 = await users.delete_mfa_authenticator( + user_id = '<USER_ID>', + type = AuthenticatorType.TOTP + ) + -result = users.delete_mfa_authenticator( - user_id = '<USER_ID>', - type = AuthenticatorType.TOTP -) +asyncio.run(main()) ``` diff --git a/docs/examples/users/delete-passkey.md b/docs/examples/users/delete-passkey.md index 060b39d4..0c28a1e2 100644 --- a/docs/examples/users/delete-passkey.md +++ b/docs/examples/users/delete-passkey.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await users.delete_passkey( + user_id = '<USER_ID>', + passkey_id = '<PASSKEY_ID>' + ) + -result = users.delete_passkey( - user_id = '<USER_ID>', - passkey_id = '<PASSKEY_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index 31ac5246..dc057c96 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await users.delete_session( + user_id = '<USER_ID>', + session_id = '<SESSION_ID>' + ) + -result = users.delete_session( - user_id = '<USER_ID>', - session_id = '<SESSION_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index c600d4c3..47272c40 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await users.delete_sessions( + user_id = '<USER_ID>' + ) + -result = users.delete_sessions( - user_id = '<USER_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md index 6dfbc7e5..1c217571 100644 --- a/docs/examples/users/delete-target.md +++ b/docs/examples/users/delete-target.md @@ -1,16 +1,23 @@ ```python +import asyncio + 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) +async def main(): + 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 = await users.delete_target( + user_id = '<USER_ID>', + target_id = '<TARGET_ID>' + ) + -result = users.delete_target( - user_id = '<USER_ID>', - target_id = '<TARGET_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index 8d236b4f..dea79270 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + 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) +async def main(): + 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 = await users.delete( + user_id = '<USER_ID>' + ) + -result = users.delete( - user_id = '<USER_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/users/get-mfa-challenge.md b/docs/examples/users/get-mfa-challenge.md index 8dde75a7..c84e093d 100644 --- a/docs/examples/users/get-mfa-challenge.md +++ b/docs/examples/users/get-mfa-challenge.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import MfaChallengeSecret -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) +async def main(): + 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: MfaChallengeSecret = await users.get_mfa_challenge( + user_id = '<USER_ID>', + challenge_id = '<CHALLENGE_ID>' + ) + + print(result.model_dump()) -result: MfaChallengeSecret = users.get_mfa_challenge( - user_id = '<USER_ID>', - challenge_id = '<CHALLENGE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md index 058aedde..11f3b14a 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import MfaRecoveryCodes -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) +async def main(): + 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: MfaRecoveryCodes = await users.get_mfa_recovery_codes( + user_id = '<USER_ID>' + ) + + print(result.model_dump()) -result: MfaRecoveryCodes = users.get_mfa_recovery_codes( - user_id = '<USER_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/get-passkey.md b/docs/examples/users/get-passkey.md index c7194bb9..ee9abcfd 100644 --- a/docs/examples/users/get-passkey.md +++ b/docs/examples/users/get-passkey.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Passkey -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) +async def main(): + 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: Passkey = await users.get_passkey( + user_id = '<USER_ID>', + passkey_id = '<PASSKEY_ID>' + ) + + print(result.model_dump()) -result: Passkey = users.get_passkey( - user_id = '<USER_ID>', - passkey_id = '<PASSKEY_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index 093b9201..0ff4b355 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Preferences -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) +async def main(): + 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: Preferences = await users.get_prefs( + user_id = '<USER_ID>' + ) + + print(result.model_dump()) -result: Preferences = users.get_prefs( - user_id = '<USER_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md index 38a7d63d..d37e8f85 100644 --- a/docs/examples/users/get-target.md +++ b/docs/examples/users/get-target.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Target -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) +async def main(): + 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: Target = await users.get_target( + user_id = '<USER_ID>', + target_id = '<TARGET_ID>' + ) + + print(result.model_dump()) -result: Target = users.get_target( - user_id = '<USER_ID>', - target_id = '<TARGET_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index 941d428a..579bb73f 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.get( + user_id = '<USER_ID>' + ) + + print(result.model_dump()) -result: User = users.get( - user_id = '<USER_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index c6e7d8dc..ba7e8c80 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import IdentityList -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) +async def main(): + 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: IdentityList = await users.list_identities( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: IdentityList = users.list_identities( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index c64d7ba5..934eb3b6 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import MembershipList -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) +async def main(): + 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: MembershipList = await users.list_memberships( + user_id = '<USER_ID>', + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: MembershipList = users.list_memberships( - user_id = '<USER_ID>', - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index 69f5a56f..08957170 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import MfaFactors -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) +async def main(): + 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: MfaFactors = await users.list_mfa_factors( + user_id = '<USER_ID>' + ) + + print(result.model_dump()) -result: MfaFactors = users.list_mfa_factors( - user_id = '<USER_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/list-passkeys.md b/docs/examples/users/list-passkeys.md index 8853711e..27555d3d 100644 --- a/docs/examples/users/list-passkeys.md +++ b/docs/examples/users/list-passkeys.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import PasskeyList -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) +async def main(): + 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: PasskeyList = await users.list_passkeys( + user_id = '<USER_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: PasskeyList = users.list_passkeys( - user_id = '<USER_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index e8abced4..a32db363 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import SessionList -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) +async def main(): + 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: SessionList = await users.list_sessions( + user_id = '<USER_ID>', + total = False # optional + ) + + print(result.model_dump()) -result: SessionList = users.list_sessions( - user_id = '<USER_ID>', - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md index e043866f..e5870abf 100644 --- a/docs/examples/users/list-targets.md +++ b/docs/examples/users/list-targets.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import TargetList -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) +async def main(): + 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: TargetList = await users.list_targets( + user_id = '<USER_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: TargetList = users.list_targets( - user_id = '<USER_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 0d623a77..59db545f 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import UserList -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) +async def main(): + 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: UserList = await users.list( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: UserList = users.list( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md index 8fd05134..d8cc2654 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_email_verification( + user_id = '<USER_ID>', + email_verification = False + ) + + print(result.model_dump()) -result: User = users.update_email_verification( - user_id = '<USER_ID>', - email_verification = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index 7dcf066f..4202f08f 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_email( + user_id = '<USER_ID>', + email = 'email@example.com' + ) + + print(result.model_dump()) -result: User = users.update_email( - user_id = '<USER_ID>', - email = 'email@example.com' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-impersonator.md b/docs/examples/users/update-impersonator.md index 38fae13c..014b503e 100644 --- a/docs/examples/users/update-impersonator.md +++ b/docs/examples/users/update-impersonator.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_impersonator( + user_id = '<USER_ID>', + impersonator = False + ) + + print(result.model_dump()) -result: User = users.update_impersonator( - user_id = '<USER_ID>', - impersonator = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 7d75293f..1ee7304a 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_labels( + user_id = '<USER_ID>', + labels = ["subscriber"] + ) + + print(result.model_dump()) -result: User = users.update_labels( - user_id = '<USER_ID>', - labels = ["subscriber"] -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md index c9090ee8..2c706320 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import MfaRecoveryCodes -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) +async def main(): + 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: MfaRecoveryCodes = await users.update_mfa_recovery_codes( + user_id = '<USER_ID>' + ) + + print(result.model_dump()) -result: MfaRecoveryCodes = users.update_mfa_recovery_codes( - user_id = '<USER_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index 4dda390c..a9639d05 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_mfa( + user_id = '<USER_ID>', + mfa = False + ) + + print(result.model_dump()) -result: User = users.update_mfa( - user_id = '<USER_ID>', - mfa = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 248411be..adc2c5d3 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_name( + user_id = '<USER_ID>', + name = '<NAME>' + ) + + print(result.model_dump()) -result: User = users.update_name( - user_id = '<USER_ID>', - name = '<NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-passkey.md b/docs/examples/users/update-passkey.md index e8a2bb1c..49e9fa37 100644 --- a/docs/examples/users/update-passkey.md +++ b/docs/examples/users/update-passkey.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Passkey -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) +async def main(): + 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: Passkey = await users.update_passkey( + user_id = '<USER_ID>', + passkey_id = '<PASSKEY_ID>', + name = '<NAME>' + ) + + print(result.model_dump()) -result: Passkey = users.update_passkey( - user_id = '<USER_ID>', - passkey_id = '<PASSKEY_ID>', - name = '<NAME>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index d0238ec3..2899075a 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_password( + user_id = '<USER_ID>', + password = 'password' + ) + + print(result.model_dump()) -result: User = users.update_password( - user_id = '<USER_ID>', - password = 'password' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md index 6b312022..00e08a4f 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_phone_verification( + user_id = '<USER_ID>', + phone_verification = False + ) + + print(result.model_dump()) -result: User = users.update_phone_verification( - user_id = '<USER_ID>', - phone_verification = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md index 82f8e15f..14fcb72d 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_phone( + user_id = '<USER_ID>', + number = '+12065550100' + ) + + print(result.model_dump()) -result: User = users.update_phone( - user_id = '<USER_ID>', - number = '+12065550100' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index 6d1f043b..6919956a 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Preferences -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) +async def main(): + 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: Preferences = await users.update_prefs( + user_id = '<USER_ID>', + prefs = {} + ) + + print(result.model_dump()) -result: Preferences = users.update_prefs( - user_id = '<USER_ID>', - prefs = {} -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index fcf8d0e5..2f643172 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import User -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) +async def main(): + 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: User = await users.update_status( + user_id = '<USER_ID>', + status = False + ) + + print(result.model_dump()) -result: User = users.update_status( - user_id = '<USER_ID>', - status = False -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md index 1a7c5f10..31a40e52 100644 --- a/docs/examples/users/update-target.md +++ b/docs/examples/users/update-target.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.users import Users from appwrite.models import Target -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) +async def main(): + 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: Target = await users.update_target( + user_id = '<USER_ID>', + target_id = '<TARGET_ID>', + identifier = '<IDENTIFIER>', # optional + provider_id = '<PROVIDER_ID>', # optional + name = '<NAME>' # optional + ) + + print(result.model_dump()) -result: Target = users.update_target( - user_id = '<USER_ID>', - target_id = '<TARGET_ID>', - identifier = '<IDENTIFIER>', # optional - provider_id = '<PROVIDER_ID>', # optional - name = '<NAME>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index 6011be07..fb5c6ff1 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import VectorsdbCollection from appwrite.permission import Permission from appwrite.role import Role -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 - -vectors_db = VectorsDB(client) - -result: VectorsdbCollection = vectors_db.create_collection( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - name = '<NAME>', - dimension = 4, - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: VectorsdbCollection = await vectors_db.create_collection( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + name = '<NAME>', + dimension = 4, + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md index d5675d86..6ec39ca5 100644 --- a/docs/examples/vectorsdb/create-document.md +++ b/docs/examples/vectorsdb/create-document.md @@ -1,22 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -vectors_db = VectorsDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + vectors_db = VectorsDB(client) -result: Document = vectors_db.create_document( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - document_id = '<DOCUMENT_ID>', - data = { + result: Document = await vectors_db.create_document( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + document_id = '<DOCUMENT_ID>', + data = { "embeddings": [ 0.12, -0.55, @@ -27,9 +31,12 @@ result: Document = vectors_db.create_document( "key": "value" } }, - permissions = [Permission.read(Role.any())], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) + permissions = [Permission.read(Role.any())], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 6191c41b..afc3870e 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -1,19 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DocumentList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) -result: DocumentList = vectors_db.create_documents( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - documents = [ + result: DocumentList = await vectors_db.create_documents( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + documents = [ { "$id": "example1", "embeddings": [ @@ -27,8 +31,11 @@ result: DocumentList = vectors_db.create_documents( } } ], - transaction_id = '<TRANSACTION_ID>' # optional -) + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/create-failover.md b/docs/examples/vectorsdb/create-failover.md index bd8fe7bb..1c1afd19 100644 --- a/docs/examples/vectorsdb/create-failover.md +++ b/docs/examples/vectorsdb/create-failover.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DedicatedDatabase -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: DedicatedDatabase = await vectors_db.create_failover( + database_id = '<DATABASE_ID>', + target_replica_id = '<TARGET_REPLICA_ID>' # optional + ) + + print(result.model_dump()) -result: DedicatedDatabase = vectors_db.create_failover( - database_id = '<DATABASE_ID>', - target_replica_id = '<TARGET_REPLICA_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index a1fcd6f7..e34a7242 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Index from appwrite.enums.vectors_db_index_type import VectorsDBIndexType from appwrite.enums.order_by import OrderBy -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 - -vectors_db = VectorsDB(client) - -result: Index = vectors_db.create_index( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - key = '<KEY>', - type = VectorsDBIndexType.HNSW_EUCLIDEAN, - attributes = ["embeddings"], - orders = [OrderBy.ASC], # optional - lengths = [], # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: Index = await vectors_db.create_index( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + key = '<KEY>', + type = VectorsDBIndexType.HNSW_EUCLIDEAN, + attributes = ["embeddings"], + orders = [OrderBy.ASC], # optional + lengths = [], # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index f4e1026d..54f70411 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -1,18 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Transaction -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) -result: Transaction = vectors_db.create_operations( - transaction_id = '<TRANSACTION_ID>', - operations = [ + result: Transaction = await vectors_db.create_operations( + transaction_id = '<TRANSACTION_ID>', + operations = [ { "action": "create", "databaseId": "<DATABASE_ID>", @@ -31,7 +35,10 @@ result: Transaction = vectors_db.create_operations( } } ] # optional -) + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/create-query.md b/docs/examples/vectorsdb/create-query.md index 093a4653..658956bf 100644 --- a/docs/examples/vectorsdb/create-query.md +++ b/docs/examples/vectorsdb/create-query.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DocumentList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -vectors_db = VectorsDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + vectors_db = VectorsDB(client) + + result: DocumentList = await vectors_db.create_query( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + queries = [], # optional + transaction_id = '<TRANSACTION_ID>', # optional + total = False, # optional + ttl = 0 # optional + ) + + print(result.model_dump()) -result: DocumentList = vectors_db.create_query( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - queries = [], # optional - transaction_id = '<TRANSACTION_ID>', # optional - total = False, # optional - ttl = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md index 6b6cd631..a289ba39 100644 --- a/docs/examples/vectorsdb/create-transaction.md +++ b/docs/examples/vectorsdb/create-transaction.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Transaction -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: Transaction = await vectors_db.create_transaction( + ttl = 60 # optional + ) + + print(result.model_dump()) -result: Transaction = vectors_db.create_transaction( - ttl = 60 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/create.md b/docs/examples/vectorsdb/create.md index b133cb18..167e9966 100644 --- a/docs/examples/vectorsdb/create.md +++ b/docs/examples/vectorsdb/create.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Database -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: Database = await vectors_db.create( + database_id = '<DATABASE_ID>', + name = '<NAME>', + enabled = False, # optional + description = '<DESCRIPTION>', # optional + specification = 'serverless', # optional + replicas = 0, # optional + sync_mode = 'async' # optional + ) + + print(result.model_dump()) -result: Database = vectors_db.create( - database_id = '<DATABASE_ID>', - name = '<NAME>', - enabled = False, # optional - description = '<DESCRIPTION>', # optional - specification = 'serverless', # optional - replicas = 0, # optional - sync_mode = 'async' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/delete-collection.md b/docs/examples/vectorsdb/delete-collection.md index b96a628b..46792e6d 100644 --- a/docs/examples/vectorsdb/delete-collection.md +++ b/docs/examples/vectorsdb/delete-collection.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result = await vectors_db.delete_collection( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>' + ) + -result = vectors_db.delete_collection( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md index 3915b937..35bcc957 100644 --- a/docs/examples/vectorsdb/delete-document.md +++ b/docs/examples/vectorsdb/delete-document.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -vectors_db = VectorsDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + vectors_db = VectorsDB(client) + + result = await vectors_db.delete_document( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + document_id = '<DOCUMENT_ID>', + transaction_id = '<TRANSACTION_ID>' # optional + ) + -result = vectors_db.delete_document( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - document_id = '<DOCUMENT_ID>', - transaction_id = '<TRANSACTION_ID>' # optional -) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index 8a36e763..19cbb604 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DocumentList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: DocumentList = await vectors_db.delete_documents( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + queries = ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"<DOCUMENT_ID>\"]}"], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) -result: DocumentList = vectors_db.delete_documents( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - queries = ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"<DOCUMENT_ID>\"]}"], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/delete-index.md b/docs/examples/vectorsdb/delete-index.md index 834b45cc..3ad861b3 100644 --- a/docs/examples/vectorsdb/delete-index.md +++ b/docs/examples/vectorsdb/delete-index.md @@ -1,17 +1,24 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result = await vectors_db.delete_index( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + key = '<KEY>' + ) + -result = vectors_db.delete_index( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - key = '<KEY>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md index 58a367f7..52cd9b85 100644 --- a/docs/examples/vectorsdb/delete-transaction.md +++ b/docs/examples/vectorsdb/delete-transaction.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result = await vectors_db.delete_transaction( + transaction_id = '<TRANSACTION_ID>' + ) + -result = vectors_db.delete_transaction( - transaction_id = '<TRANSACTION_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/delete.md b/docs/examples/vectorsdb/delete.md index da1c5a49..00ae6156 100644 --- a/docs/examples/vectorsdb/delete.md +++ b/docs/examples/vectorsdb/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result = await vectors_db.delete( + database_id = '<DATABASE_ID>' + ) + -result = vectors_db.delete( - database_id = '<DATABASE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/get-collection.md b/docs/examples/vectorsdb/get-collection.md index 2616d72a..8a680dce 100644 --- a/docs/examples/vectorsdb/get-collection.md +++ b/docs/examples/vectorsdb/get-collection.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import VectorsdbCollection -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: VectorsdbCollection = await vectors_db.get_collection( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>' + ) + + print(result.model_dump()) -result: VectorsdbCollection = vectors_db.get_collection( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md index a484c5dd..bd2bdf0b 100644 --- a/docs/examples/vectorsdb/get-document.md +++ b/docs/examples/vectorsdb/get-document.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Document -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -vectors_db = VectorsDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + vectors_db = VectorsDB(client) + + result: Document = await vectors_db.get_document( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + document_id = '<DOCUMENT_ID>', + queries = [], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) -result: Document = vectors_db.get_document( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - document_id = '<DOCUMENT_ID>', - queries = [], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/get-index.md b/docs/examples/vectorsdb/get-index.md index b7a8726b..ee3624fe 100644 --- a/docs/examples/vectorsdb/get-index.md +++ b/docs/examples/vectorsdb/get-index.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Index -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: Index = await vectors_db.get_index( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + key = '<KEY>' + ) + + print(result.model_dump()) -result: Index = vectors_db.get_index( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - key = '<KEY>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/get-replicas.md b/docs/examples/vectorsdb/get-replicas.md index af8e01ab..a6fa8d07 100644 --- a/docs/examples/vectorsdb/get-replicas.md +++ b/docs/examples/vectorsdb/get-replicas.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DedicatedDatabaseReplicas -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: DedicatedDatabaseReplicas = await vectors_db.get_replicas( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DedicatedDatabaseReplicas = vectors_db.get_replicas( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/get-status.md b/docs/examples/vectorsdb/get-status.md index 8d34903e..e2387784 100644 --- a/docs/examples/vectorsdb/get-status.md +++ b/docs/examples/vectorsdb/get-status.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DatabaseStatus -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: DatabaseStatus = await vectors_db.get_status( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: DatabaseStatus = vectors_db.get_status( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md index 601ed0b0..78d339c1 100644 --- a/docs/examples/vectorsdb/get-transaction.md +++ b/docs/examples/vectorsdb/get-transaction.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Transaction -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: Transaction = await vectors_db.get_transaction( + transaction_id = '<TRANSACTION_ID>' + ) + + print(result.model_dump()) -result: Transaction = vectors_db.get_transaction( - transaction_id = '<TRANSACTION_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/get.md b/docs/examples/vectorsdb/get.md index b251b427..2693d8b4 100644 --- a/docs/examples/vectorsdb/get.md +++ b/docs/examples/vectorsdb/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Database -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: Database = await vectors_db.get( + database_id = '<DATABASE_ID>' + ) + + print(result.model_dump()) -result: Database = vectors_db.get( - database_id = '<DATABASE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/list-collections.md b/docs/examples/vectorsdb/list-collections.md index 184c3c3f..43696243 100644 --- a/docs/examples/vectorsdb/list-collections.md +++ b/docs/examples/vectorsdb/list-collections.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import VectorsdbCollectionList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: VectorsdbCollectionList = await vectors_db.list_collections( + database_id = '<DATABASE_ID>', + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: VectorsdbCollectionList = vectors_db.list_collections( - database_id = '<DATABASE_ID>', - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md index 5ac3ab2f..df2ddcce 100644 --- a/docs/examples/vectorsdb/list-documents.md +++ b/docs/examples/vectorsdb/list-documents.md @@ -1,23 +1,30 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DocumentList -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -vectors_db = VectorsDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + vectors_db = VectorsDB(client) + + result: DocumentList = await vectors_db.list_documents( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + queries = [], # optional + transaction_id = '<TRANSACTION_ID>', # optional + total = False, # optional + ttl = 0 # optional + ) + + print(result.model_dump()) -result: DocumentList = vectors_db.list_documents( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - queries = [], # optional - transaction_id = '<TRANSACTION_ID>', # optional - total = False, # optional - ttl = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/list-indexes.md b/docs/examples/vectorsdb/list-indexes.md index c72e9800..8ecbe65e 100644 --- a/docs/examples/vectorsdb/list-indexes.md +++ b/docs/examples/vectorsdb/list-indexes.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import IndexList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: IndexList = await vectors_db.list_indexes( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: IndexList = vectors_db.list_indexes( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/list-operations.md b/docs/examples/vectorsdb/list-operations.md index 14f399b7..76441d09 100644 --- a/docs/examples/vectorsdb/list-operations.md +++ b/docs/examples/vectorsdb/list-operations.md @@ -1,21 +1,28 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DedicatedDatabaseOperationList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: DedicatedDatabaseOperationList = await vectors_db.list_operations( + database_id = '<DATABASE_ID>', + status = 'queued', # optional + limit = 1, # optional + offset = 0 # optional + ) + + print(result.model_dump()) -result: DedicatedDatabaseOperationList = vectors_db.list_operations( - database_id = '<DATABASE_ID>', - status = 'queued', # optional - limit = 1, # optional - offset = 0 # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/list-specifications.md b/docs/examples/vectorsdb/list-specifications.md index fdff8182..e1ea18dd 100644 --- a/docs/examples/vectorsdb/list-specifications.md +++ b/docs/examples/vectorsdb/list-specifications.md @@ -1,16 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DedicatedDatabaseSpecificationList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: DedicatedDatabaseSpecificationList = await vectors_db.list_specifications() + + print(result.model_dump()) -result: DedicatedDatabaseSpecificationList = vectors_db.list_specifications() -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md index 6ff6cdaa..d7d18a8b 100644 --- a/docs/examples/vectorsdb/list-transactions.md +++ b/docs/examples/vectorsdb/list-transactions.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import TransactionList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: TransactionList = await vectors_db.list_transactions( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: TransactionList = vectors_db.list_transactions( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/list.md b/docs/examples/vectorsdb/list.md index d7cd9298..a5f0fef5 100644 --- a/docs/examples/vectorsdb/list.md +++ b/docs/examples/vectorsdb/list.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DatabaseList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: DatabaseList = await vectors_db.list( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: DatabaseList = vectors_db.list( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index e4c925e1..b863f0c3 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import VectorsdbCollection from appwrite.permission import Permission from appwrite.role import Role -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 - -vectors_db = VectorsDB(client) - -result: VectorsdbCollection = vectors_db.update_collection( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - name = '<NAME>', - dimension = 4, # optional - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False, # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: VectorsdbCollection = await vectors_db.update_collection( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + name = '<NAME>', + dimension = 4, # optional + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False, # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md index c70c2bc1..9fb429ee 100644 --- a/docs/examples/vectorsdb/update-document.md +++ b/docs/examples/vectorsdb/update-document.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -vectors_db = VectorsDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + vectors_db = VectorsDB(client) + + result: Document = await vectors_db.update_document( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + document_id = '<DOCUMENT_ID>', + data = {}, # optional + permissions = [Permission.read(Role.any())], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) -result: Document = vectors_db.update_document( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - document_id = '<DOCUMENT_ID>', - data = {}, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/update-documents.md b/docs/examples/vectorsdb/update-documents.md index 5c947cd1..497fbe35 100644 --- a/docs/examples/vectorsdb/update-documents.md +++ b/docs/examples/vectorsdb/update-documents.md @@ -1,22 +1,29 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DocumentList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: DocumentList = await vectors_db.update_documents( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + data = {}, # optional + queries = [], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) -result: DocumentList = vectors_db.update_documents( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - data = {}, # optional - queries = [], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md index 276c25c8..8d4afe3e 100644 --- a/docs/examples/vectorsdb/update-transaction.md +++ b/docs/examples/vectorsdb/update-transaction.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Transaction -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: Transaction = await vectors_db.update_transaction( + transaction_id = '<TRANSACTION_ID>', + commit = False, # optional + rollback = False # optional + ) + + print(result.model_dump()) -result: Transaction = vectors_db.update_transaction( - transaction_id = '<TRANSACTION_ID>', - commit = False, # optional - rollback = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md index 25ee897b..964bf8f1 100644 --- a/docs/examples/vectorsdb/update.md +++ b/docs/examples/vectorsdb/update.md @@ -1,24 +1,31 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Database -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) + + result: Database = await vectors_db.update( + database_id = '<DATABASE_ID>', + name = '<NAME>', + enabled = False, # optional + description = '<DESCRIPTION>', # optional + specification = 'serverless', # optional + replicas = 0, # optional + sync_mode = 'async' # optional + ) + + print(result.model_dump()) -result: Database = vectors_db.update( - database_id = '<DATABASE_ID>', - name = '<NAME>', - enabled = False, # optional - description = '<DESCRIPTION>', # optional - specification = 'serverless', # optional - replicas = 0, # optional - sync_mode = 'async' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md index 95f916d3..1db65ebe 100644 --- a/docs/examples/vectorsdb/upsert-document.md +++ b/docs/examples/vectorsdb/upsert-document.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role -client = Client() -client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_session('') # The user session to authenticate with -vectors_db = VectorsDB(client) +async def main(): + client = Client() + client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + client.set_project('<YOUR_PROJECT_ID>') # Your project ID + client.set_session('') # The user session to authenticate with + + vectors_db = VectorsDB(client) + + result: Document = await vectors_db.upsert_document( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + document_id = '<DOCUMENT_ID>', + data = {}, # optional + permissions = [Permission.read(Role.any())], # optional + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) -result: Document = vectors_db.upsert_document( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - document_id = '<DOCUMENT_ID>', - data = {}, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '<TRANSACTION_ID>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index c89ed2f3..f48c3588 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -1,19 +1,23 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.vectors_db import VectorsDB from appwrite.models import DocumentList -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 -vectors_db = VectorsDB(client) +async def main(): + 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 + + vectors_db = VectorsDB(client) -result: DocumentList = vectors_db.upsert_documents( - database_id = '<DATABASE_ID>', - collection_id = '<COLLECTION_ID>', - documents = [ + result: DocumentList = await vectors_db.upsert_documents( + database_id = '<DATABASE_ID>', + collection_id = '<COLLECTION_ID>', + documents = [ { "$id": "example1", "embeddings": [ @@ -27,8 +31,11 @@ result: DocumentList = vectors_db.upsert_documents( } } ], - transaction_id = '<TRANSACTION_ID>' # optional -) + transaction_id = '<TRANSACTION_ID>' # optional + ) + + print(result.model_dump()) + -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md index 70ed9061..9d382484 100644 --- a/docs/examples/waf/create-bypass-rule.md +++ b/docs/examples/waf/create-bypass-rule.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleBypass -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 - -waf = Waf(client) - -result: WafRuleBypass = waf.create_bypass_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', - name = '<NAME>', - resource_id = '<RESOURCE_ID>', # optional - description = '<DESCRIPTION>', # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleBypass = await waf.create_bypass_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', + name = '<NAME>', + resource_id = '<RESOURCE_ID>', # optional + description = '<DESCRIPTION>', # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md index e3d2fea2..251f7655 100644 --- a/docs/examples/waf/create-challenge-rule.md +++ b/docs/examples/waf/create-challenge-rule.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleChallenge -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 - -waf = Waf(client) - -result: WafRuleChallenge = waf.create_challenge_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', - name = '<NAME>', - resource_id = '<RESOURCE_ID>', # optional - description = '<DESCRIPTION>', # optional - challenge_type = 'compute', # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [], # optional - difficulty = 1, # optional - ttl = 900 # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleChallenge = await waf.create_challenge_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', + name = '<NAME>', + resource_id = '<RESOURCE_ID>', # optional + description = '<DESCRIPTION>', # optional + challenge_type = 'compute', # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [], # optional + difficulty = 1, # optional + ttl = 900 # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md index a23ae249..b0406d5f 100644 --- a/docs/examples/waf/create-deny-rule.md +++ b/docs/examples/waf/create-deny-rule.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleDeny -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 - -waf = Waf(client) - -result: WafRuleDeny = waf.create_deny_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', - name = '<NAME>', - resource_id = '<RESOURCE_ID>', # optional - description = '<DESCRIPTION>', # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleDeny = await waf.create_deny_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', + name = '<NAME>', + resource_id = '<RESOURCE_ID>', # optional + description = '<DESCRIPTION>', # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md index e76605f8..7e58cd5e 100644 --- a/docs/examples/waf/create-rate-limit-rule.md +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -1,30 +1,37 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleRateLimit -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 - -waf = Waf(client) - -result: WafRuleRateLimit = waf.create_rate_limit_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', - name = '<NAME>', - limit = 1, - interval = 1, - resource_id = '<RESOURCE_ID>', # optional - description = '<DESCRIPTION>', # optional - key = 'ip', # optional - strategy = 'fixedWindow', # optional - max_bucket_size = 1, # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleRateLimit = await waf.create_rate_limit_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', + name = '<NAME>', + limit = 1, + interval = 1, + resource_id = '<RESOURCE_ID>', # optional + description = '<DESCRIPTION>', # optional + key = 'ip', # optional + strategy = 'fixedWindow', # optional + max_bucket_size = 1, # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md index a33a1e6c..4399137e 100644 --- a/docs/examples/waf/create-redirect-rule.md +++ b/docs/examples/waf/create-redirect-rule.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleRedirect -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 - -waf = Waf(client) - -result: WafRuleRedirect = waf.create_redirect_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', - name = '<NAME>', - location = '<LOCATION>', - status_code = 300, - resource_id = '<RESOURCE_ID>', # optional - description = '<DESCRIPTION>', # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleRedirect = await waf.create_redirect_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', + name = '<NAME>', + location = '<LOCATION>', + status_code = 300, + resource_id = '<RESOURCE_ID>', # optional + description = '<DESCRIPTION>', # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md index a2fbe6d8..22a9fca9 100644 --- a/docs/examples/waf/delete-rule.md +++ b/docs/examples/waf/delete-rule.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf -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 -waf = Waf(client) +async def main(): + 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 + + waf = Waf(client) + + result = await waf.delete_rule( + rule_id = '<RULE_ID>' + ) + -result = waf.delete_rule( - rule_id = '<RULE_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md index 3168d309..3a6f0e34 100644 --- a/docs/examples/waf/get-rule.md +++ b/docs/examples/waf/get-rule.md @@ -1,4 +1,6 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleBypass @@ -8,16 +10,21 @@ from appwrite.models import WafRuleRateLimit from appwrite.models import WafRuleRedirect from typing import Union -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 -waf = Waf(client) +async def main(): + 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 + + waf = Waf(client) + + result: Union[WafRuleBypass, WafRuleDeny, WafRuleChallenge, WafRuleRateLimit, WafRuleRedirect] = await waf.get_rule( + rule_id = '<RULE_ID>' + ) + + print(result.model_dump()) -result: Union[WafRuleBypass, WafRuleDeny, WafRuleChallenge, WafRuleRateLimit, WafRuleRedirect] = waf.get_rule( - rule_id = '<RULE_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md index d06a509e..47da31fa 100644 --- a/docs/examples/waf/list-rules.md +++ b/docs/examples/waf/list-rules.md @@ -1,20 +1,27 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleList -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 -waf = Waf(client) +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleList = await waf.list_rules( + queries = [], # optional + search = '<SEARCH>', # optional + total = False # optional + ) + + print(result.model_dump()) -result: WafRuleList = waf.list_rules( - queries = [], # optional - search = '<SEARCH>', # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md index 39ceb7f4..1f1a9f70 100644 --- a/docs/examples/waf/update-bypass-rule.md +++ b/docs/examples/waf/update-bypass-rule.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleBypass -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 - -waf = Waf(client) - -result: WafRuleBypass = waf.update_bypass_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', # optional - resource_id = '<RESOURCE_ID>', # optional - name = '<NAME>', # optional - description = '<DESCRIPTION>', # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleBypass = await waf.update_bypass_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', # optional + resource_id = '<RESOURCE_ID>', # optional + name = '<NAME>', # optional + description = '<DESCRIPTION>', # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md index 30afcd7f..7a7877c0 100644 --- a/docs/examples/waf/update-challenge-rule.md +++ b/docs/examples/waf/update-challenge-rule.md @@ -1,28 +1,35 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleChallenge -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 - -waf = Waf(client) - -result: WafRuleChallenge = waf.update_challenge_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', # optional - resource_id = '<RESOURCE_ID>', # optional - name = '<NAME>', # optional - description = '<DESCRIPTION>', # optional - challenge_type = 'compute', # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [], # optional - difficulty = 1, # optional - ttl = 900 # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleChallenge = await waf.update_challenge_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', # optional + resource_id = '<RESOURCE_ID>', # optional + name = '<NAME>', # optional + description = '<DESCRIPTION>', # optional + challenge_type = 'compute', # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [], # optional + difficulty = 1, # optional + ttl = 900 # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md index 2253e2b7..2dde16d5 100644 --- a/docs/examples/waf/update-deny-rule.md +++ b/docs/examples/waf/update-deny-rule.md @@ -1,25 +1,32 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleDeny -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 - -waf = Waf(client) - -result: WafRuleDeny = waf.update_deny_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', # optional - resource_id = '<RESOURCE_ID>', # optional - name = '<NAME>', # optional - description = '<DESCRIPTION>', # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleDeny = await waf.update_deny_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', # optional + resource_id = '<RESOURCE_ID>', # optional + name = '<NAME>', # optional + description = '<DESCRIPTION>', # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md index e413cef8..7097ddea 100644 --- a/docs/examples/waf/update-rate-limit-rule.md +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -1,29 +1,36 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleRateLimit -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 - -waf = Waf(client) - -result: WafRuleRateLimit = waf.update_rate_limit_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', # optional - resource_id = '<RESOURCE_ID>', # optional - name = '<NAME>', # optional - description = '<DESCRIPTION>', # optional - limit = 1, # optional - interval = 1, # optional - key = 'ip', # optional - max_bucket_size = 1, # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleRateLimit = await waf.update_rate_limit_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', # optional + resource_id = '<RESOURCE_ID>', # optional + name = '<NAME>', # optional + description = '<DESCRIPTION>', # optional + limit = 1, # optional + interval = 1, # optional + key = 'ip', # optional + max_bucket_size = 1, # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md index 7e294f8c..e0e95eba 100644 --- a/docs/examples/waf/update-redirect-rule.md +++ b/docs/examples/waf/update-redirect-rule.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.waf import Waf from appwrite.models import WafRuleRedirect -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 - -waf = Waf(client) - -result: WafRuleRedirect = waf.update_redirect_rule( - rule_id = '<RULE_ID>', - resource_type = 'api', # optional - resource_id = '<RESOURCE_ID>', # optional - name = '<NAME>', # optional - description = '<DESCRIPTION>', # optional - location = '<LOCATION>', # optional - status_code = 300, # optional - priority = -100000, # optional - enabled = False, # optional - conditions = [] # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + waf = Waf(client) + + result: WafRuleRedirect = await waf.update_redirect_rule( + rule_id = '<RULE_ID>', + resource_type = 'api', # optional + resource_id = '<RESOURCE_ID>', # optional + name = '<NAME>', # optional + description = '<DESCRIPTION>', # optional + location = '<LOCATION>', # optional + status_code = 300, # optional + priority = -100000, # optional + enabled = False, # optional + conditions = [] # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index fddd87eb..91a29d48 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -1,27 +1,34 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.webhooks import Webhooks from appwrite.models import Webhook -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 - -webhooks = Webhooks(client) - -result: Webhook = webhooks.create( - webhook_id = '<WEBHOOK_ID>', - url = 'https://example.com/webhook', - name = '<NAME>', - events = ["users.*.create"], - enabled = False, # optional - tls = False, # optional - auth_username = '<AUTH_USERNAME>', # optional - auth_password = 'password', # optional - secret = '<SECRET>', # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + webhooks = Webhooks(client) + + result: Webhook = await webhooks.create( + webhook_id = '<WEBHOOK_ID>', + url = 'https://example.com/webhook', + name = '<NAME>', + events = ["users.*.create"], + enabled = False, # optional + tls = False, # optional + auth_username = '<AUTH_USERNAME>', # optional + auth_password = 'password', # optional + secret = '<SECRET>', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` diff --git a/docs/examples/webhooks/delete.md b/docs/examples/webhooks/delete.md index 1b6cbdb3..52f3abe2 100644 --- a/docs/examples/webhooks/delete.md +++ b/docs/examples/webhooks/delete.md @@ -1,15 +1,22 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.webhooks import Webhooks -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 -webhooks = Webhooks(client) +async def main(): + 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 + + webhooks = Webhooks(client) + + result = await webhooks.delete( + webhook_id = '<WEBHOOK_ID>' + ) + -result = webhooks.delete( - webhook_id = '<WEBHOOK_ID>' -) +asyncio.run(main()) ``` diff --git a/docs/examples/webhooks/get.md b/docs/examples/webhooks/get.md index e24808ce..9ccd0f6e 100644 --- a/docs/examples/webhooks/get.md +++ b/docs/examples/webhooks/get.md @@ -1,18 +1,25 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.webhooks import Webhooks from appwrite.models import Webhook -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 -webhooks = Webhooks(client) +async def main(): + 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 + + webhooks = Webhooks(client) + + result: Webhook = await webhooks.get( + webhook_id = '<WEBHOOK_ID>' + ) + + print(result.model_dump()) -result: Webhook = webhooks.get( - webhook_id = '<WEBHOOK_ID>' -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/webhooks/list.md b/docs/examples/webhooks/list.md index 0bb23204..63c80e65 100644 --- a/docs/examples/webhooks/list.md +++ b/docs/examples/webhooks/list.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.webhooks import Webhooks from appwrite.models import WebhookList -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 -webhooks = Webhooks(client) +async def main(): + 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 + + webhooks = Webhooks(client) + + result: WebhookList = await webhooks.list( + queries = [], # optional + total = False # optional + ) + + print(result.model_dump()) -result: WebhookList = webhooks.list( - queries = [], # optional - total = False # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/webhooks/update-secret.md b/docs/examples/webhooks/update-secret.md index 5e38b24b..0700c5f9 100644 --- a/docs/examples/webhooks/update-secret.md +++ b/docs/examples/webhooks/update-secret.md @@ -1,19 +1,26 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.webhooks import Webhooks from appwrite.models import Webhook -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 -webhooks = Webhooks(client) +async def main(): + 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 + + webhooks = Webhooks(client) + + result: Webhook = await webhooks.update_secret( + webhook_id = '<WEBHOOK_ID>', + secret = '<SECRET>' # optional + ) + + print(result.model_dump()) -result: Webhook = webhooks.update_secret( - webhook_id = '<WEBHOOK_ID>', - secret = '<SECRET>' # optional -) -print(result.model_dump()) +asyncio.run(main()) ``` diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 7fa2311e..028a9180 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -1,26 +1,33 @@ ```python +import asyncio + from appwrite.client import Client from appwrite.services.webhooks import Webhooks from appwrite.models import Webhook -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 - -webhooks = Webhooks(client) - -result: Webhook = webhooks.update( - webhook_id = '<WEBHOOK_ID>', - name = '<NAME>', - url = 'https://example.com/webhook', - events = ["users.*.create"], - enabled = False, # optional - tls = False, # optional - auth_username = '<AUTH_USERNAME>', # optional - auth_password = 'password', # optional - description = '<DESCRIPTION>' # optional -) - -print(result.model_dump()) + +async def main(): + 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 + + webhooks = Webhooks(client) + + result: Webhook = await webhooks.update( + webhook_id = '<WEBHOOK_ID>', + name = '<NAME>', + url = 'https://example.com/webhook', + events = ["users.*.create"], + enabled = False, # optional + tls = False, # optional + auth_username = '<AUTH_USERNAME>', # optional + auth_password = 'password', # optional + description = '<DESCRIPTION>' # optional + ) + + print(result.model_dump()) + + +asyncio.run(main()) ``` From 62687bb7b57ca84bb913efd3eda9b0548b4bb484 Mon Sep 17 00:00:00 2001 From: Xharry01X <harshitsingh50621@gmail.com> Date: Wed, 28 Oct 2026 16:17:56 +0530 Subject: [PATCH 14/15] Settle siblings when progress callback fails A raising async progress callback escaped the chunk worker and cancelled in-flight sibling uploads. Capture it with the other failures so every chunk settles before the error surfaces. --- appwrite/client.py | 35 +++++++++++++------------- test/test_async_client.py | 52 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 17 deletions(-) diff --git a/appwrite/client.py b/appwrite/client.py index 6e2d748e..ccb24986 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -388,29 +388,30 @@ async def upload_chunk(chunk, current_upload_id): async def upload_remaining_chunk(chunk): nonlocal completed_count, uploaded_size, last_result, final_result - # a task group cancels siblings on the first raise, so failures are - # captured here to keep gather(return_exceptions=True) semantics. + # a task group cancels siblings on the first raise, so failures, + # including ones raised by the progress callback, are captured here + # to keep gather(return_exceptions=True) semantics. try: async with semaphore: chunk_result = await upload_chunk(chunk, upload_id_header) + completed_count = completed_count + 1 + uploaded_size = uploaded_size + (chunk['end'] - chunk['start']) + last_result = chunk_result + if is_upload_complete(chunk_result): + final_result = chunk_result + await self._report_progress( + on_progress, + { + "$id": upload_id_header, + "progress": uploaded_size / size * 100, + "sizeUploaded": uploaded_size, + "chunksTotal": total_chunks, + "chunksUploaded": completed_count, + }, + ) except BaseException as exc: failures.append(exc) return - completed_count = completed_count + 1 - uploaded_size = uploaded_size + (chunk['end'] - chunk['start']) - last_result = chunk_result - if is_upload_complete(chunk_result): - final_result = chunk_result - await self._report_progress( - on_progress, - { - "$id": upload_id_header, - "progress": uploaded_size / size * 100, - "sizeUploaded": uploaded_size, - "chunksTotal": total_chunks, - "chunksUploaded": completed_count, - }, - ) # Wait for every sibling chunk to settle before surfacing a failure, so the # caller never observes an error while other chunks are still being written. diff --git a/test/test_async_client.py b/test/test_async_client.py index f986b422..f5aee4ac 100644 --- a/test/test_async_client.py +++ b/test/test_async_client.py @@ -168,6 +168,58 @@ async def handler(request): self.assertEqual(in_flight, 0, 'sibling chunk uploads were still running when the error surfaced') self.assertEqual(completed, 3, 'sibling chunk uploads did not run to completion') + @respx.mock + async def test_chunked_upload_waits_for_siblings_when_progress_callback_fails(self): + total_chunks = 4 + in_flight = 0 + completed = 0 + + async def handler(request): + nonlocal in_flight, completed + if request.method == 'GET': + # Resume probe: the SDK asks whether an upload is already in progress. + return httpx2.Response( + 200, + json={'$id': 'file-1', 'chunksTotal': total_chunks, 'chunksUploaded': 0}, + headers={'Content-Type': 'application/json'}, + ) + in_flight += 1 + await asyncio.sleep(0.2) + in_flight -= 1 + completed += 1 + return httpx2.Response( + 200, + json={'$id': 'file-1', 'chunksTotal': total_chunks, 'chunksUploaded': 1}, + headers={'Content-Type': 'application/json'}, + ) + + respx.route().mock(side_effect=handler) + + calls = 0 + + async def on_progress(payload): + nonlocal calls + calls += 1 + if calls > 1: + # The first chunk is reported before siblings start; raising on + # the sibling reports targets the concurrent reporting path. + raise RuntimeError('progress callback failed') + + async with Client() as client: + client._chunk_size = 10 + storage = Storage(client) + with self.assertRaises(RuntimeError): + await storage.create_file( + bucket_id='bucket-1', + file_id='file-1', + file=InputFile.from_bytes(b'x' * 40, 'test.txt'), + on_progress=on_progress, + ) + + self.assertEqual(in_flight, 0, 'sibling chunk uploads were still running when the error surfaced') + self.assertEqual(completed, 4, 'sibling chunk uploads did not run to completion') + self.assertGreaterEqual(calls, 1, 'progress callback was not invoked') + @respx.mock async def test_location_response_returns_the_redirect_url(self): # httpx raises on 3xx, so a redirect is only a success when the client From 9c1ff163f4618e9ab5984f66bea0bb2dc71af055 Mon Sep 17 00:00:00 2001 From: Xharry01X <harshitsingh50621@gmail.com> Date: Wed, 28 Oct 2026 16:17:57 +0530 Subject: [PATCH 15/15] Create users service in README error example --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3acb9334..49a895f3 100644 --- a/README.md +++ b/README.md @@ -132,9 +132,12 @@ Failed requests raise `AppwriteException`, which carries `message`, `code`, `typ import asyncio from appwrite.exception import AppwriteException +from appwrite.services.users import Users async def main(): + users = Users(client) + try: user = await users.get(user_id='<USER_ID>') except AppwriteException as error: