From 924d72ac79564397e7661f7c2da4ee0c2cab3de0 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 18 Nov 2024 12:46:35 +0000 Subject: [PATCH] fix: revert multipart --- appwrite/client.py | 48 +++-- appwrite/enums/runtime.py | 11 +- appwrite/input_file.py | 21 ++ appwrite/multipart.py | 49 ----- appwrite/payload.py | 72 ------- appwrite/services/account.py | 173 +++++++++++----- appwrite/services/avatars.py | 29 ++- appwrite/services/databases.py | 169 ++++++++++++---- appwrite/services/functions.py | 110 ++++++++--- appwrite/services/graphql.py | 9 +- appwrite/services/health.py | 93 ++++++--- appwrite/services/locale.py | 33 +++- appwrite/services/messaging.py | 185 +++++++++++++----- appwrite/services/storage.py | 57 ++++-- appwrite/services/teams.py | 53 +++-- appwrite/services/users.py | 169 ++++++++++++---- .../databases/update-string-attribute.md | 2 +- docs/examples/functions/create-deployment.md | 4 +- docs/examples/functions/create-execution.md | 2 +- docs/examples/storage/create-file.md | 4 +- 20 files changed, 865 insertions(+), 428 deletions(-) create mode 100644 appwrite/input_file.py delete mode 100644 appwrite/multipart.py delete mode 100644 appwrite/payload.py diff --git a/appwrite/client.py b/appwrite/client.py index 4d5092f..ba0ed1e 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -1,7 +1,8 @@ +import io import json +import os import requests -from .payload import Payload -from .multipart import MultipartParser +from .input_file import InputFile from .exception import AppwriteException from .encoders.value_class_encoder import ValueClassEncoder @@ -90,15 +91,11 @@ def call(self, method, path='', headers=None, params=None, response_type='json') if headers['content-type'].startswith('multipart/form-data'): del headers['content-type'] - headers['accept'] = 'multipart/form-data' stringify = True for key in data.copy(): - if isinstance(data[key], Payload): - if data[key].filename: - files[key] = (data[key].filename, data[key].to_binary()) - del data[key] - else: - data[key] = data[key].to_string() + if isinstance(data[key], InputFile): + files[key] = (data[key].filename, data[key].data) + del data[key] data = self.flatten(data, stringify=stringify) response = None @@ -129,9 +126,6 @@ def call(self, method, path='', headers=None, params=None, response_type='json') if content_type.startswith('application/json'): return response.json() - if content_type.startswith('multipart/form-data'): - return MultipartParser(response.content, content_type).to_dict() - return response._content except Exception as e: if response != None: @@ -152,10 +146,20 @@ def chunked_upload( on_progress = None, upload_id = '' ): - payload = params[param_name] - size = params[param_name].size + input_file = params[param_name] + + if input_file.source_type == 'path': + size = os.stat(input_file.path).st_size + input = open(input_file.path, 'rb') + elif input_file.source_type == 'bytes': + size = len(input_file.data) + input = input_file.data + + if size < self._chunk_size: + if input_file.source_type == 'path': + input_file.data = input.read() - if size < self._chunk_size: + params[param_name] = input_file return self.call( 'post', path, @@ -178,10 +182,16 @@ def chunked_upload( input.seek(offset) while offset < size: - params[param_name] = Payload.from_binary( - payload.to_binary(offset, min(self._chunk_size, size - offset)), - payload.filename - ) + if input_file.source_type == 'path': + input_file.data = input.read(self._chunk_size) or input.read(size - offset) + elif input_file.source_type == 'bytes': + if offset + self._chunk_size < size: + end = offset + self._chunk_size + else: + end = size - offset + input_file.data = input[offset:end] + + params[param_name] = input_file headers["content-range"] = f'bytes {offset}-{min((offset + self._chunk_size) - 1, size - 1)}/{size}' result = self.call( diff --git a/appwrite/enums/runtime.py b/appwrite/enums/runtime.py index 1e0b47a..db428ef 100644 --- a/appwrite/enums/runtime.py +++ b/appwrite/enums/runtime.py @@ -7,6 +7,7 @@ class Runtime(Enum): NODE_19_0 = "node-19.0" NODE_20_0 = "node-20.0" NODE_21_0 = "node-21.0" + NODE_22 = "node-22" PHP_8_0 = "php-8.0" PHP_8_1 = "php-8.1" PHP_8_2 = "php-8.2" @@ -25,6 +26,8 @@ class Runtime(Enum): DENO_1_24 = "deno-1.24" DENO_1_35 = "deno-1.35" DENO_1_40 = "deno-1.40" + DENO_1_46 = "deno-1.46" + DENO_2_0 = "deno-2.0" DART_2_15 = "dart-2.15" DART_2_16 = "dart-2.16" DART_2_17 = "dart-2.17" @@ -32,21 +35,27 @@ class Runtime(Enum): DART_3_0 = "dart-3.0" DART_3_1 = "dart-3.1" DART_3_3 = "dart-3.3" - DOTNET_3_1 = "dotnet-3.1" + DART_3_5 = "dart-3.5" DOTNET_6_0 = "dotnet-6.0" DOTNET_7_0 = "dotnet-7.0" + DOTNET_8_0 = "dotnet-8.0" JAVA_8_0 = "java-8.0" JAVA_11_0 = "java-11.0" JAVA_17_0 = "java-17.0" JAVA_18_0 = "java-18.0" JAVA_21_0 = "java-21.0" + JAVA_22 = "java-22" SWIFT_5_5 = "swift-5.5" SWIFT_5_8 = "swift-5.8" SWIFT_5_9 = "swift-5.9" + SWIFT_5_10 = "swift-5.10" KOTLIN_1_6 = "kotlin-1.6" KOTLIN_1_8 = "kotlin-1.8" KOTLIN_1_9 = "kotlin-1.9" + KOTLIN_2_0 = "kotlin-2.0" CPP_17 = "cpp-17" CPP_20 = "cpp-20" BUN_1_0 = "bun-1.0" + BUN_1_1 = "bun-1.1" GO_1_23 = "go-1.23" + STATIC_1 = "static-1" diff --git a/appwrite/input_file.py b/appwrite/input_file.py new file mode 100644 index 0000000..33d5a77 --- /dev/null +++ b/appwrite/input_file.py @@ -0,0 +1,21 @@ +import os +import mimetypes + +class InputFile: + @classmethod + def from_path(cls, path): + instance = cls() + instance.path = path + instance.filename = os.path.basename(path) + instance.mime_type = mimetypes.guess_type(path) + instance.source_type = 'path' + return instance + + @classmethod + def from_bytes(cls, bytes, filename, mime_type = None): + instance = cls() + instance.data = bytes + instance.filename = filename + instance.mime_type = mime_type + instance.source_type = 'bytes' + return instance \ No newline at end of file diff --git a/appwrite/multipart.py b/appwrite/multipart.py deleted file mode 100644 index f2d5360..0000000 --- a/appwrite/multipart.py +++ /dev/null @@ -1,49 +0,0 @@ -from email.parser import BytesParser -from email.policy import default -from .payload import Payload -import json - -class MultipartParser: - def __init__(self, multipart_bytes, content_type): - self.multipart_bytes = multipart_bytes - self.content_type = content_type - self.parts = {} - self.parse() - - def parse(self): - # Create a message object - headers = f'Content-Type: {self.content_type}\r\n\r\n'.encode('ascii') - msg = BytesParser(policy=default).parsebytes(headers + self.multipart_bytes) - - # Process each part - for part in msg.walk(): - if part.is_multipart(): - continue - - # Get the name from Content-Disposition - content_disposition = part.get("Content-Disposition", "") - name = part.get_param("name", header="content-disposition") - if not name: - name = f"unnamed_part_{len(self.parts)}" - - # Store the parsed data - self.parts[name] = { - "contents": part.get_payload(decode=True), - "headers": dict(part.items()) - } - - def to_dict(self): - result = {} - for name, part in self.parts.items(): - if name == "responseBody": - result[name] = Payload.from_binary(part["contents"]) - elif name == "responseHeaders": - headers_str = part["contents"].decode('utf-8', errors='replace') - result[name] = json.loads(headers_str) - elif name == "responseStatusCode": - result[name] = int(part["contents"]) - elif name == "duration": - result[name] = float(part["contents"]) - else: - result[name] = part["contents"].decode('utf-8', errors='replace') - return result \ No newline at end of file diff --git a/appwrite/payload.py b/appwrite/payload.py deleted file mode 100644 index 93249b9..0000000 --- a/appwrite/payload.py +++ /dev/null @@ -1,72 +0,0 @@ -from typing import Optional, Dict, Any -import os, json - -class Payload: - filename: Optional[str] = None - - _path: Optional[str] = None - _data: Optional[bytes] = None - _size: int = 0 - - @property - def size(self) -> int: - return self._size - - def __init__(self, path: Optional[str] = None, data: Optional[bytes] = None, filename: Optional[str] = None): - if path is None and data is None: - raise ValueError("One of path or data must be provided") - - self._path = path - self._data = data - - self.filename = filename - if self._data is None: - self._size = os.path.getsize(self._path) - else: - self._size = len(self._data) - - def to_binary(self, offset: Optional[int] = 0, length: Optional[int] = None) -> bytes: - if length is None: - length = self._size - - if self._data is None: - with open(self._path, 'rb') as f: - f.seek(offset) - return f.read(length) - - return self._data[offset:offset + length] - - def to_string(self, encoding="utf-8") -> str: - return self.to_binary().decode(encoding) - - def __str__(self) -> str: - return self.to_string() - - def to_json(self) -> Dict[str, Any]: - return json.loads(self.to_string()) - - def to_file(self, path: str) -> None: - os.makedirs(os.path.dirname(path), exist_ok=True) - - with open(path, 'wb') as f: - return f.write(self.to_binary()) - - @classmethod - def from_binary(cls, data: bytes, filename: Optional[str] = None) -> 'Payload': - return cls(data=data, filename=filename) - - @classmethod - def from_string(cls, data: str) -> 'Payload': - return cls(data=data.encode()) - - @classmethod - def from_file(cls, path: str, filename: Optional[str] = None) -> 'Payload': - if not os.path.exists(path): - raise FileNotFoundError(f"File {path} not found") - if not filename: - filename = os.path.basename(path) - return cls(path=path, filename=filename) - - @classmethod - def from_json(cls, data: Dict[str, Any]) -> 'Payload': - return cls.from_string(json.dumps(data)) diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 6f40c88..10255b2 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Account, self).__init__(client) def get(self): - """Get account""" + """Get account""" + + api_path = '/account' api_params = {} @@ -16,7 +18,9 @@ def get(self): }, api_params) def create(self, user_id, email, password, name = None): - """Create account""" + """Create account""" + + api_path = '/account' api_params = {} if user_id is None: @@ -39,7 +43,9 @@ def create(self, user_id, email, password, name = None): }, api_params) def update_email(self, email, password): - """Update email""" + """Update email""" + + api_path = '/account/email' api_params = {} if email is None: @@ -57,7 +63,9 @@ def update_email(self, email, password): }, api_params) def list_identities(self, queries = None): - """List identities""" + """List identities""" + + api_path = '/account/identities' api_params = {} @@ -68,7 +76,9 @@ def list_identities(self, queries = None): }, api_params) def delete_identity(self, identity_id): - """Delete identity""" + """Delete identity""" + + api_path = '/account/identities/{identityId}' api_params = {} if identity_id is None: @@ -82,7 +92,9 @@ def delete_identity(self, identity_id): }, api_params) def create_jwt(self): - """Create JWT""" + """Create JWT""" + + api_path = '/account/jwts' api_params = {} @@ -91,7 +103,9 @@ def create_jwt(self): }, api_params) def list_logs(self, queries = None): - """List logs""" + """List logs""" + + api_path = '/account/logs' api_params = {} @@ -102,7 +116,9 @@ def list_logs(self, queries = None): }, api_params) def update_mfa(self, mfa): - """Update MFA""" + """Update MFA""" + + api_path = '/account/mfa' api_params = {} if mfa is None: @@ -116,7 +132,9 @@ def update_mfa(self, mfa): }, api_params) def create_mfa_authenticator(self, type): - """Create authenticator""" + """Create authenticator""" + + api_path = '/account/mfa/authenticators/{type}' api_params = {} if type is None: @@ -130,7 +148,9 @@ def create_mfa_authenticator(self, type): }, api_params) def update_mfa_authenticator(self, type, otp): - """Verify authenticator""" + """Verify authenticator""" + + api_path = '/account/mfa/authenticators/{type}' api_params = {} if type is None: @@ -148,7 +168,9 @@ def update_mfa_authenticator(self, type, otp): }, api_params) def delete_mfa_authenticator(self, type): - """Delete authenticator""" + """Delete authenticator""" + + api_path = '/account/mfa/authenticators/{type}' api_params = {} if type is None: @@ -162,7 +184,9 @@ def delete_mfa_authenticator(self, type): }, api_params) def create_mfa_challenge(self, factor): - """Create MFA challenge""" + """Create MFA challenge""" + + api_path = '/account/mfa/challenge' api_params = {} if factor is None: @@ -176,7 +200,9 @@ def create_mfa_challenge(self, factor): }, api_params) def update_mfa_challenge(self, challenge_id, otp): - """Create MFA challenge (confirmation)""" + """Create MFA challenge (confirmation)""" + + api_path = '/account/mfa/challenge' api_params = {} if challenge_id is None: @@ -194,7 +220,9 @@ def update_mfa_challenge(self, challenge_id, otp): }, api_params) def list_mfa_factors(self): - """List factors""" + """List factors""" + + api_path = '/account/mfa/factors' api_params = {} @@ -203,7 +231,9 @@ def list_mfa_factors(self): }, api_params) def get_mfa_recovery_codes(self): - """Get MFA recovery codes""" + """Get MFA recovery codes""" + + api_path = '/account/mfa/recovery-codes' api_params = {} @@ -212,7 +242,9 @@ def get_mfa_recovery_codes(self): }, api_params) def create_mfa_recovery_codes(self): - """Create MFA recovery codes""" + """Create MFA recovery codes""" + + api_path = '/account/mfa/recovery-codes' api_params = {} @@ -221,7 +253,9 @@ def create_mfa_recovery_codes(self): }, api_params) def update_mfa_recovery_codes(self): - """Regenerate MFA recovery codes""" + """Regenerate MFA recovery codes""" + + api_path = '/account/mfa/recovery-codes' api_params = {} @@ -230,7 +264,9 @@ def update_mfa_recovery_codes(self): }, api_params) def update_name(self, name): - """Update name""" + """Update name""" + + api_path = '/account/name' api_params = {} if name is None: @@ -244,7 +280,9 @@ def update_name(self, name): }, api_params) def update_password(self, password, old_password = None): - """Update password""" + """Update password""" + + api_path = '/account/password' api_params = {} if password is None: @@ -259,7 +297,9 @@ def update_password(self, password, old_password = None): }, api_params) def update_phone(self, phone, password): - """Update phone""" + """Update phone""" + + api_path = '/account/phone' api_params = {} if phone is None: @@ -277,7 +317,9 @@ def update_phone(self, phone, password): }, api_params) def get_prefs(self): - """Get account preferences""" + """Get account preferences""" + + api_path = '/account/prefs' api_params = {} @@ -286,7 +328,9 @@ def get_prefs(self): }, api_params) def update_prefs(self, prefs): - """Update preferences""" + """Update preferences""" + + api_path = '/account/prefs' api_params = {} if prefs is None: @@ -300,7 +344,9 @@ def update_prefs(self, prefs): }, api_params) def create_recovery(self, email, url): - """Create password recovery""" + """Create password recovery""" + + api_path = '/account/recovery' api_params = {} if email is None: @@ -318,7 +364,9 @@ def create_recovery(self, email, url): }, api_params) def update_recovery(self, user_id, secret, password): - """Create password recovery (confirmation)""" + """Create password recovery (confirmation)""" + + api_path = '/account/recovery' api_params = {} if user_id is None: @@ -340,7 +388,9 @@ def update_recovery(self, user_id, secret, password): }, api_params) def list_sessions(self): - """List sessions""" + """List sessions""" + + api_path = '/account/sessions' api_params = {} @@ -349,7 +399,9 @@ def list_sessions(self): }, api_params) def delete_sessions(self): - """Delete sessions""" + """Delete sessions""" + + api_path = '/account/sessions' api_params = {} @@ -358,7 +410,9 @@ def delete_sessions(self): }, api_params) def create_anonymous_session(self): - """Create anonymous session""" + """Create anonymous session""" + + api_path = '/account/sessions/anonymous' api_params = {} @@ -367,7 +421,9 @@ def create_anonymous_session(self): }, api_params) def create_email_password_session(self, email, password): - """Create email password session""" + """Create email password session""" + + api_path = '/account/sessions/email' api_params = {} if email is None: @@ -385,7 +441,9 @@ def create_email_password_session(self, email, password): }, api_params) def update_magic_url_session(self, user_id, secret): - """Update magic URL session""" + """Update magic URL session""" + + api_path = '/account/sessions/magic-url' api_params = {} if user_id is None: @@ -403,7 +461,9 @@ def update_magic_url_session(self, user_id, secret): }, api_params) def update_phone_session(self, user_id, secret): - """Update phone session""" + """Update phone session""" + + api_path = '/account/sessions/phone' api_params = {} if user_id is None: @@ -421,7 +481,9 @@ def update_phone_session(self, user_id, secret): }, api_params) def create_session(self, user_id, secret): - """Create session""" + """Create session""" + + api_path = '/account/sessions/token' api_params = {} if user_id is None: @@ -439,7 +501,9 @@ def create_session(self, user_id, secret): }, api_params) def get_session(self, session_id): - """Get session""" + """Get session""" + + api_path = '/account/sessions/{sessionId}' api_params = {} if session_id is None: @@ -453,7 +517,9 @@ def get_session(self, session_id): }, api_params) def update_session(self, session_id): - """Update session""" + """Update session""" + + api_path = '/account/sessions/{sessionId}' api_params = {} if session_id is None: @@ -467,7 +533,9 @@ def update_session(self, session_id): }, api_params) def delete_session(self, session_id): - """Delete session""" + """Delete session""" + + api_path = '/account/sessions/{sessionId}' api_params = {} if session_id is None: @@ -481,7 +549,9 @@ def delete_session(self, session_id): }, api_params) def update_status(self): - """Update status""" + """Update status""" + + api_path = '/account/status' api_params = {} @@ -490,7 +560,9 @@ def update_status(self): }, api_params) def create_email_token(self, user_id, email, phrase = None): - """Create email token (OTP)""" + """Create email token (OTP)""" + + api_path = '/account/tokens/email' api_params = {} if user_id is None: @@ -509,7 +581,9 @@ def create_email_token(self, user_id, email, phrase = None): }, api_params) def create_magic_url_token(self, user_id, email, url = None, phrase = None): - """Create magic URL token""" + """Create magic URL token""" + + api_path = '/account/tokens/magic-url' api_params = {} if user_id is None: @@ -529,7 +603,9 @@ def create_magic_url_token(self, user_id, email, url = None, phrase = None): }, api_params) def create_o_auth2_token(self, provider, success = None, failure = None, scopes = None): - """Create OAuth2 token""" + """Create OAuth2 token""" + + api_path = '/account/tokens/oauth2/{provider}' api_params = {} if provider is None: @@ -546,7 +622,9 @@ def create_o_auth2_token(self, provider, success = None, failure = None, scopes }, api_params, response_type='location') def create_phone_token(self, user_id, phone): - """Create phone token""" + """Create phone token""" + + api_path = '/account/tokens/phone' api_params = {} if user_id is None: @@ -564,7 +642,9 @@ def create_phone_token(self, user_id, phone): }, api_params) def create_verification(self, url): - """Create email verification""" + """Create email verification""" + + api_path = '/account/verification' api_params = {} if url is None: @@ -578,7 +658,9 @@ def create_verification(self, url): }, api_params) def update_verification(self, user_id, secret): - """Create email verification (confirmation)""" + """Create email verification (confirmation)""" + + api_path = '/account/verification' api_params = {} if user_id is None: @@ -596,7 +678,9 @@ def update_verification(self, user_id, secret): }, api_params) def create_phone_verification(self): - """Create phone verification""" + """Create phone verification""" + + api_path = '/account/verification/phone' api_params = {} @@ -605,7 +689,9 @@ def create_phone_verification(self): }, api_params) def update_phone_verification(self, user_id, secret): - """Update phone verification (confirmation)""" + """Update phone verification (confirmation)""" + + api_path = '/account/verification/phone' api_params = {} if user_id is None: @@ -621,4 +707,3 @@ def update_phone_verification(self, user_id, secret): return self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index a8e23ce..0a9b400 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Avatars, self).__init__(client) def get_browser(self, code, width = None, height = None, quality = None): - """Get browser icon""" + """Get browser icon""" + + api_path = '/avatars/browsers/{code}' api_params = {} if code is None: @@ -24,7 +26,9 @@ def get_browser(self, code, width = None, height = None, quality = None): }, api_params) def get_credit_card(self, code, width = None, height = None, quality = None): - """Get credit card icon""" + """Get credit card icon""" + + api_path = '/avatars/credit-cards/{code}' api_params = {} if code is None: @@ -41,7 +45,9 @@ def get_credit_card(self, code, width = None, height = None, quality = None): }, api_params) def get_favicon(self, url): - """Get favicon""" + """Get favicon""" + + api_path = '/avatars/favicon' api_params = {} if url is None: @@ -55,7 +61,9 @@ def get_favicon(self, url): }, api_params) def get_flag(self, code, width = None, height = None, quality = None): - """Get country flag""" + """Get country flag""" + + api_path = '/avatars/flags/{code}' api_params = {} if code is None: @@ -72,7 +80,9 @@ def get_flag(self, code, width = None, height = None, quality = None): }, api_params) def get_image(self, url, width = None, height = None): - """Get image from URL""" + """Get image from URL""" + + api_path = '/avatars/image' api_params = {} if url is None: @@ -88,7 +98,9 @@ def get_image(self, url, width = None, height = None): }, api_params) def get_initials(self, name = None, width = None, height = None, background = None): - """Get user initials""" + """Get user initials""" + + api_path = '/avatars/initials' api_params = {} @@ -102,7 +114,9 @@ def get_initials(self, name = None, width = None, height = None, background = No }, api_params) def get_qr(self, text, size = None, margin = None, download = None): - """Get QR code""" + """Get QR code""" + + api_path = '/avatars/qr' api_params = {} if text is None: @@ -117,4 +131,3 @@ def get_qr(self, text, size = None, margin = None, download = None): return self.client.call('get', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index c39d7ec..aa47e4e 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Databases, self).__init__(client) def list(self, queries = None, search = None): - """List databases""" + """List databases""" + + api_path = '/databases' api_params = {} @@ -19,7 +21,9 @@ def list(self, queries = None, search = None): }, api_params) def create(self, database_id, name, enabled = None): - """Create database""" + """Create database""" + + api_path = '/databases' api_params = {} if database_id is None: @@ -38,7 +42,9 @@ def create(self, database_id, name, enabled = None): }, api_params) def get(self, database_id): - """Get database""" + """Get database""" + + api_path = '/databases/{databaseId}' api_params = {} if database_id is None: @@ -52,7 +58,9 @@ def get(self, database_id): }, api_params) def update(self, database_id, name, enabled = None): - """Update database""" + """Update database""" + + api_path = '/databases/{databaseId}' api_params = {} if database_id is None: @@ -71,7 +79,9 @@ def update(self, database_id, name, enabled = None): }, api_params) def delete(self, database_id): - """Delete database""" + """Delete database""" + + api_path = '/databases/{databaseId}' api_params = {} if database_id is None: @@ -85,7 +95,9 @@ def delete(self, database_id): }, api_params) def list_collections(self, database_id, queries = None, search = None): - """List collections""" + """List collections""" + + api_path = '/databases/{databaseId}/collections' api_params = {} if database_id is None: @@ -101,7 +113,9 @@ def list_collections(self, database_id, queries = None, search = None): }, api_params) def create_collection(self, database_id, collection_id, name, permissions = None, document_security = None, enabled = None): - """Create collection""" + """Create collection""" + + api_path = '/databases/{databaseId}/collections' api_params = {} if database_id is None: @@ -126,7 +140,9 @@ def create_collection(self, database_id, collection_id, name, permissions = None }, api_params) def get_collection(self, database_id, collection_id): - """Get collection""" + """Get collection""" + + api_path = '/databases/{databaseId}/collections/{collectionId}' api_params = {} if database_id is None: @@ -144,7 +160,9 @@ def get_collection(self, database_id, collection_id): }, api_params) def update_collection(self, database_id, collection_id, name, permissions = None, document_security = None, enabled = None): - """Update collection""" + """Update collection""" + + api_path = '/databases/{databaseId}/collections/{collectionId}' api_params = {} if database_id is None: @@ -169,7 +187,9 @@ def update_collection(self, database_id, collection_id, name, permissions = None }, api_params) def delete_collection(self, database_id, collection_id): - """Delete collection""" + """Delete collection""" + + api_path = '/databases/{databaseId}/collections/{collectionId}' api_params = {} if database_id is None: @@ -187,7 +207,9 @@ def delete_collection(self, database_id, collection_id): }, api_params) def list_attributes(self, database_id, collection_id, queries = None): - """List attributes""" + """List attributes""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' api_params = {} if database_id is None: @@ -206,7 +228,9 @@ def list_attributes(self, database_id, collection_id, queries = None): }, api_params) def create_boolean_attribute(self, database_id, collection_id, key, required, default = None, array = None): - """Create boolean attribute""" + """Create boolean attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' api_params = {} if database_id is None: @@ -234,7 +258,9 @@ def create_boolean_attribute(self, database_id, collection_id, key, required, de }, api_params) def update_boolean_attribute(self, database_id, collection_id, key, required, default, new_key = None): - """Update boolean attribute""" + """Update boolean attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' api_params = {} if database_id is None: @@ -262,7 +288,9 @@ def update_boolean_attribute(self, database_id, collection_id, key, required, de }, api_params) def create_datetime_attribute(self, database_id, collection_id, key, required, default = None, array = None): - """Create datetime attribute""" + """Create datetime attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' api_params = {} if database_id is None: @@ -290,7 +318,9 @@ def create_datetime_attribute(self, database_id, collection_id, key, required, d }, api_params) def update_datetime_attribute(self, database_id, collection_id, key, required, default, new_key = None): - """Update dateTime attribute""" + """Update dateTime attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' api_params = {} if database_id is None: @@ -318,7 +348,9 @@ def update_datetime_attribute(self, database_id, collection_id, key, required, d }, api_params) def create_email_attribute(self, database_id, collection_id, key, required, default = None, array = None): - """Create email attribute""" + """Create email attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' api_params = {} if database_id is None: @@ -346,7 +378,9 @@ def create_email_attribute(self, database_id, collection_id, key, required, defa }, api_params) def update_email_attribute(self, database_id, collection_id, key, required, default, new_key = None): - """Update email attribute""" + """Update email attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' api_params = {} if database_id is None: @@ -374,7 +408,9 @@ def update_email_attribute(self, database_id, collection_id, key, required, defa }, api_params) def create_enum_attribute(self, database_id, collection_id, key, elements, required, default = None, array = None): - """Create enum attribute""" + """Create enum attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' api_params = {} if database_id is None: @@ -406,7 +442,9 @@ def create_enum_attribute(self, database_id, collection_id, key, elements, requi }, api_params) def update_enum_attribute(self, database_id, collection_id, key, elements, required, default, new_key = None): - """Update enum attribute""" + """Update enum attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' api_params = {} if database_id is None: @@ -438,7 +476,9 @@ def update_enum_attribute(self, database_id, collection_id, key, elements, requi }, api_params) def create_float_attribute(self, database_id, collection_id, key, required, min = None, max = None, default = None, array = None): - """Create float attribute""" + """Create float attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' api_params = {} if database_id is None: @@ -468,7 +508,9 @@ def create_float_attribute(self, database_id, collection_id, key, required, min }, api_params) def update_float_attribute(self, database_id, collection_id, key, required, min, max, default, new_key = None): - """Update float attribute""" + """Update float attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' api_params = {} if database_id is None: @@ -504,7 +546,9 @@ def update_float_attribute(self, database_id, collection_id, key, required, min, }, api_params) def create_integer_attribute(self, database_id, collection_id, key, required, min = None, max = None, default = None, array = None): - """Create integer attribute""" + """Create integer attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' api_params = {} if database_id is None: @@ -534,7 +578,9 @@ def create_integer_attribute(self, database_id, collection_id, key, required, mi }, api_params) def update_integer_attribute(self, database_id, collection_id, key, required, min, max, default, new_key = None): - """Update integer attribute""" + """Update integer attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' api_params = {} if database_id is None: @@ -570,7 +616,9 @@ def update_integer_attribute(self, database_id, collection_id, key, required, mi }, api_params) def create_ip_attribute(self, database_id, collection_id, key, required, default = None, array = None): - """Create IP address attribute""" + """Create IP address attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' api_params = {} if database_id is None: @@ -598,7 +646,9 @@ def create_ip_attribute(self, database_id, collection_id, key, required, default }, api_params) def update_ip_attribute(self, database_id, collection_id, key, required, default, new_key = None): - """Update IP address attribute""" + """Update IP address attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' api_params = {} if database_id is None: @@ -626,7 +676,9 @@ def update_ip_attribute(self, database_id, collection_id, key, required, default }, api_params) def create_relationship_attribute(self, database_id, collection_id, related_collection_id, type, two_way = None, key = None, two_way_key = None, on_delete = None): - """Create relationship attribute""" + """Create relationship attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' api_params = {} if database_id is None: @@ -656,7 +708,9 @@ def create_relationship_attribute(self, database_id, collection_id, related_coll }, api_params) def create_string_attribute(self, database_id, collection_id, key, size, required, default = None, array = None, encrypt = None): - """Create string attribute""" + """Create string attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' api_params = {} if database_id is None: @@ -689,7 +743,9 @@ def create_string_attribute(self, database_id, collection_id, key, size, require }, api_params) def update_string_attribute(self, database_id, collection_id, key, required, default, size = None, new_key = None): - """Update string attribute""" + """Update string attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' api_params = {} if database_id is None: @@ -718,7 +774,9 @@ def update_string_attribute(self, database_id, collection_id, key, required, def }, api_params) def create_url_attribute(self, database_id, collection_id, key, required, default = None, array = None): - """Create URL attribute""" + """Create URL attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' api_params = {} if database_id is None: @@ -746,7 +804,9 @@ def create_url_attribute(self, database_id, collection_id, key, required, defaul }, api_params) def update_url_attribute(self, database_id, collection_id, key, required, default, new_key = None): - """Update URL attribute""" + """Update URL attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' api_params = {} if database_id is None: @@ -774,7 +834,9 @@ def update_url_attribute(self, database_id, collection_id, key, required, defaul }, api_params) def get_attribute(self, database_id, collection_id, key): - """Get attribute""" + """Get attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' api_params = {} if database_id is None: @@ -796,7 +858,9 @@ def get_attribute(self, database_id, collection_id, key): }, api_params) def delete_attribute(self, database_id, collection_id, key): - """Delete attribute""" + """Delete attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' api_params = {} if database_id is None: @@ -818,7 +882,9 @@ def delete_attribute(self, database_id, collection_id, key): }, api_params) def update_relationship_attribute(self, database_id, collection_id, key, on_delete = None, new_key = None): - """Update relationship attribute""" + """Update relationship attribute""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship' api_params = {} if database_id is None: @@ -842,7 +908,9 @@ def update_relationship_attribute(self, database_id, collection_id, key, on_dele }, api_params) def list_documents(self, database_id, collection_id, queries = None): - """List documents""" + """List documents""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' api_params = {} if database_id is None: @@ -861,7 +929,9 @@ def list_documents(self, database_id, collection_id, queries = None): }, api_params) def create_document(self, database_id, collection_id, document_id, data, permissions = None): - """Create document""" + """Create document""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' api_params = {} if database_id is None: @@ -888,7 +958,9 @@ def create_document(self, database_id, collection_id, document_id, data, permiss }, api_params) def get_document(self, database_id, collection_id, document_id, queries = None): - """Get document""" + """Get document""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' api_params = {} if database_id is None: @@ -911,7 +983,9 @@ def get_document(self, database_id, collection_id, document_id, queries = None): }, api_params) def update_document(self, database_id, collection_id, document_id, data = None, permissions = None): - """Update document""" + """Update document""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' api_params = {} if database_id is None: @@ -935,7 +1009,9 @@ def update_document(self, database_id, collection_id, document_id, data = None, }, api_params) def delete_document(self, database_id, collection_id, document_id): - """Delete document""" + """Delete document""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' api_params = {} if database_id is None: @@ -957,7 +1033,9 @@ def delete_document(self, database_id, collection_id, document_id): }, api_params) def list_indexes(self, database_id, collection_id, queries = None): - """List indexes""" + """List indexes""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' api_params = {} if database_id is None: @@ -976,7 +1054,9 @@ def list_indexes(self, database_id, collection_id, queries = None): }, api_params) def create_index(self, database_id, collection_id, key, type, attributes, orders = None): - """Create index""" + """Create index""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' api_params = {} if database_id is None: @@ -1007,7 +1087,9 @@ def create_index(self, database_id, collection_id, key, type, attributes, orders }, api_params) def get_index(self, database_id, collection_id, key): - """Get index""" + """Get index""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' api_params = {} if database_id is None: @@ -1029,7 +1111,9 @@ def get_index(self, database_id, collection_id, key): }, api_params) def delete_index(self, database_id, collection_id, key): - """Delete index""" + """Delete index""" + + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' api_params = {} if database_id is None: @@ -1049,4 +1133,3 @@ def delete_index(self, database_id, collection_id, key): return self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index d59e288..34b13a9 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Functions, self).__init__(client) def list(self, queries = None, search = None): - """List functions""" + """List functions""" + + api_path = '/functions' api_params = {} @@ -19,7 +21,9 @@ def list(self, queries = None, search = None): }, api_params) def create(self, function_id, name, runtime, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, scopes = None, installation_id = None, provider_repository_id = None, provider_branch = None, provider_silent_mode = None, provider_root_directory = None, template_repository = None, template_owner = None, template_root_directory = None, template_version = None, specification = None): - """Create function""" + """Create function""" + + api_path = '/functions' api_params = {} if function_id is None: @@ -60,7 +64,9 @@ def create(self, function_id, name, runtime, execute = None, events = None, sche }, api_params) def list_runtimes(self): - """List runtimes""" + """List runtimes""" + + api_path = '/functions/runtimes' api_params = {} @@ -69,7 +75,9 @@ def list_runtimes(self): }, api_params) def list_specifications(self): - """List available function runtime specifications""" + """List available function runtime specifications""" + + api_path = '/functions/specifications' api_params = {} @@ -78,7 +86,9 @@ def list_specifications(self): }, api_params) def get(self, function_id): - """Get function""" + """Get function""" + + api_path = '/functions/{functionId}' api_params = {} if function_id is None: @@ -92,7 +102,9 @@ def get(self, function_id): }, api_params) def update(self, function_id, name, runtime = None, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, scopes = None, installation_id = None, provider_repository_id = None, provider_branch = None, provider_silent_mode = None, provider_root_directory = None, specification = None): - """Update function""" + """Update function""" + + api_path = '/functions/{functionId}' api_params = {} if function_id is None: @@ -126,7 +138,9 @@ def update(self, function_id, name, runtime = None, execute = None, events = Non }, api_params) def delete(self, function_id): - """Delete function""" + """Delete function""" + + api_path = '/functions/{functionId}' api_params = {} if function_id is None: @@ -140,7 +154,9 @@ def delete(self, function_id): }, api_params) def list_deployments(self, function_id, queries = None, search = None): - """List deployments""" + """List deployments""" + + api_path = '/functions/{functionId}/deployments' api_params = {} if function_id is None: @@ -156,7 +172,9 @@ def list_deployments(self, function_id, queries = None, search = None): }, api_params) def create_deployment(self, function_id, code, activate, entrypoint = None, commands = None, on_progress = None): - """Create deployment""" + """Create deployment""" + + api_path = '/functions/{functionId}/deployments' api_params = {} if function_id is None: @@ -176,15 +194,18 @@ def create_deployment(self, function_id, code, activate, entrypoint = None, comm api_params['activate'] = str(activate).lower() if type(activate) is bool else activate param_name = 'code' + + upload_id = '' return self.client.chunked_upload(api_path, { 'content-type': 'multipart/form-data', }, api_params, param_name, on_progress, upload_id) - def get_deployment(self, function_id, deployment_id): - """Get deployment""" + """Get deployment""" + + api_path = '/functions/{functionId}/deployments/{deploymentId}' api_params = {} if function_id is None: @@ -202,7 +223,9 @@ def get_deployment(self, function_id, deployment_id): }, api_params) def update_deployment(self, function_id, deployment_id): - """Update deployment""" + """Update deployment""" + + api_path = '/functions/{functionId}/deployments/{deploymentId}' api_params = {} if function_id is None: @@ -220,7 +243,9 @@ def update_deployment(self, function_id, deployment_id): }, api_params) def delete_deployment(self, function_id, deployment_id): - """Delete deployment""" + """Delete deployment""" + + api_path = '/functions/{functionId}/deployments/{deploymentId}' api_params = {} if function_id is None: @@ -238,7 +263,9 @@ def delete_deployment(self, function_id, deployment_id): }, api_params) def create_build(self, function_id, deployment_id, build_id = None): - """Rebuild deployment""" + """Rebuild deployment""" + + api_path = '/functions/{functionId}/deployments/{deploymentId}/build' api_params = {} if function_id is None: @@ -257,7 +284,9 @@ def create_build(self, function_id, deployment_id, build_id = None): }, api_params) def update_deployment_build(self, function_id, deployment_id): - """Cancel deployment""" + """Cancel deployment""" + + api_path = '/functions/{functionId}/deployments/{deploymentId}/build' api_params = {} if function_id is None: @@ -275,7 +304,9 @@ def update_deployment_build(self, function_id, deployment_id): }, api_params) def get_deployment_download(self, function_id, deployment_id): - """Download deployment""" + """Download deployment""" + + api_path = '/functions/{functionId}/deployments/{deploymentId}/download' api_params = {} if function_id is None: @@ -293,7 +324,9 @@ def get_deployment_download(self, function_id, deployment_id): }, api_params) def list_executions(self, function_id, queries = None, search = None): - """List executions""" + """List executions""" + + api_path = '/functions/{functionId}/executions' api_params = {} if function_id is None: @@ -308,8 +341,10 @@ def list_executions(self, function_id, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create_execution(self, function_id, body = None, xasync = None, path = None, method = None, headers = None, scheduled_at = None, on_progress = None): - """Create execution""" + def create_execution(self, function_id, body = None, xasync = None, path = None, method = None, headers = None, scheduled_at = None): + """Create execution""" + + api_path = '/functions/{functionId}/executions' api_params = {} if function_id is None: @@ -317,19 +352,21 @@ def create_execution(self, function_id, body = None, xasync = None, path = None, api_path = api_path.replace('{functionId}', function_id) - api_params['body'] = str(body).lower() if type(body) is bool else body - api_params['async'] = str(xasync).lower() if type(xasync) is bool else xasync + api_params['body'] = body + api_params['async'] = xasync api_params['path'] = path api_params['method'] = method - api_params['headers'] = str(headers).lower() if type(headers) is bool else headers + api_params['headers'] = headers api_params['scheduledAt'] = scheduled_at return self.client.call('post', api_path, { - 'content-type': 'multipart/form-data', + 'content-type': 'application/json', }, api_params) def get_execution(self, function_id, execution_id): - """Get execution""" + """Get execution""" + + api_path = '/functions/{functionId}/executions/{executionId}' api_params = {} if function_id is None: @@ -347,7 +384,9 @@ def get_execution(self, function_id, execution_id): }, api_params) def delete_execution(self, function_id, execution_id): - """Delete execution""" + """Delete execution""" + + api_path = '/functions/{functionId}/executions/{executionId}' api_params = {} if function_id is None: @@ -365,7 +404,9 @@ def delete_execution(self, function_id, execution_id): }, api_params) def list_variables(self, function_id): - """List variables""" + """List variables""" + + api_path = '/functions/{functionId}/variables' api_params = {} if function_id is None: @@ -379,7 +420,9 @@ def list_variables(self, function_id): }, api_params) def create_variable(self, function_id, key, value): - """Create variable""" + """Create variable""" + + api_path = '/functions/{functionId}/variables' api_params = {} if function_id is None: @@ -401,7 +444,9 @@ def create_variable(self, function_id, key, value): }, api_params) def get_variable(self, function_id, variable_id): - """Get variable""" + """Get variable""" + + api_path = '/functions/{functionId}/variables/{variableId}' api_params = {} if function_id is None: @@ -419,7 +464,9 @@ def get_variable(self, function_id, variable_id): }, api_params) def update_variable(self, function_id, variable_id, key, value = None): - """Update variable""" + """Update variable""" + + api_path = '/functions/{functionId}/variables/{variableId}' api_params = {} if function_id is None: @@ -442,7 +489,9 @@ def update_variable(self, function_id, variable_id, key, value = None): }, api_params) def delete_variable(self, function_id, variable_id): - """Delete variable""" + """Delete variable""" + + api_path = '/functions/{functionId}/variables/{variableId}' api_params = {} if function_id is None: @@ -458,4 +507,3 @@ def delete_variable(self, function_id, variable_id): return self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/graphql.py b/appwrite/services/graphql.py index defa60c..58a6e99 100644 --- a/appwrite/services/graphql.py +++ b/appwrite/services/graphql.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Graphql, self).__init__(client) def query(self, query): - """GraphQL endpoint""" + """GraphQL endpoint""" + + api_path = '/graphql' api_params = {} if query is None: @@ -22,7 +24,9 @@ def query(self, query): }, api_params) def mutation(self, query): - """GraphQL endpoint""" + """GraphQL endpoint""" + + api_path = '/graphql/mutation' api_params = {} if query is None: @@ -35,4 +39,3 @@ def mutation(self, query): 'x-sdk-graphql': 'true', 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/health.py b/appwrite/services/health.py index ea1e6f2..ef4b3cd 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Health, self).__init__(client) def get(self): - """Get HTTP""" + """Get HTTP""" + + api_path = '/health' api_params = {} @@ -16,7 +18,9 @@ def get(self): }, api_params) def get_antivirus(self): - """Get antivirus""" + """Get antivirus""" + + api_path = '/health/anti-virus' api_params = {} @@ -25,7 +29,9 @@ def get_antivirus(self): }, api_params) def get_cache(self): - """Get cache""" + """Get cache""" + + api_path = '/health/cache' api_params = {} @@ -34,7 +40,9 @@ def get_cache(self): }, api_params) def get_certificate(self, domain = None): - """Get the SSL certificate for a domain""" + """Get the SSL certificate for a domain""" + + api_path = '/health/certificate' api_params = {} @@ -45,7 +53,9 @@ def get_certificate(self, domain = None): }, api_params) def get_db(self): - """Get DB""" + """Get DB""" + + api_path = '/health/db' api_params = {} @@ -54,7 +64,9 @@ def get_db(self): }, api_params) def get_pub_sub(self): - """Get pubsub""" + """Get pubsub""" + + api_path = '/health/pubsub' api_params = {} @@ -63,7 +75,9 @@ def get_pub_sub(self): }, api_params) def get_queue(self): - """Get queue""" + """Get queue""" + + api_path = '/health/queue' api_params = {} @@ -72,7 +86,9 @@ def get_queue(self): }, api_params) def get_queue_builds(self, threshold = None): - """Get builds queue""" + """Get builds queue""" + + api_path = '/health/queue/builds' api_params = {} @@ -83,7 +99,9 @@ def get_queue_builds(self, threshold = None): }, api_params) def get_queue_certificates(self, threshold = None): - """Get certificates queue""" + """Get certificates queue""" + + api_path = '/health/queue/certificates' api_params = {} @@ -94,7 +112,9 @@ def get_queue_certificates(self, threshold = None): }, api_params) def get_queue_databases(self, name = None, threshold = None): - """Get databases queue""" + """Get databases queue""" + + api_path = '/health/queue/databases' api_params = {} @@ -106,7 +126,9 @@ def get_queue_databases(self, name = None, threshold = None): }, api_params) def get_queue_deletes(self, threshold = None): - """Get deletes queue""" + """Get deletes queue""" + + api_path = '/health/queue/deletes' api_params = {} @@ -117,7 +139,9 @@ def get_queue_deletes(self, threshold = None): }, api_params) def get_failed_jobs(self, name, threshold = None): - """Get number of failed queue jobs""" + """Get number of failed queue jobs""" + + api_path = '/health/queue/failed/{name}' api_params = {} if name is None: @@ -132,7 +156,9 @@ def get_failed_jobs(self, name, threshold = None): }, api_params) def get_queue_functions(self, threshold = None): - """Get functions queue""" + """Get functions queue""" + + api_path = '/health/queue/functions' api_params = {} @@ -143,7 +169,9 @@ def get_queue_functions(self, threshold = None): }, api_params) def get_queue_logs(self, threshold = None): - """Get logs queue""" + """Get logs queue""" + + api_path = '/health/queue/logs' api_params = {} @@ -154,7 +182,9 @@ def get_queue_logs(self, threshold = None): }, api_params) def get_queue_mails(self, threshold = None): - """Get mails queue""" + """Get mails queue""" + + api_path = '/health/queue/mails' api_params = {} @@ -165,7 +195,9 @@ def get_queue_mails(self, threshold = None): }, api_params) def get_queue_messaging(self, threshold = None): - """Get messaging queue""" + """Get messaging queue""" + + api_path = '/health/queue/messaging' api_params = {} @@ -176,7 +208,9 @@ def get_queue_messaging(self, threshold = None): }, api_params) def get_queue_migrations(self, threshold = None): - """Get migrations queue""" + """Get migrations queue""" + + api_path = '/health/queue/migrations' api_params = {} @@ -187,7 +221,9 @@ def get_queue_migrations(self, threshold = None): }, api_params) def get_queue_usage(self, threshold = None): - """Get usage queue""" + """Get usage queue""" + + api_path = '/health/queue/usage' api_params = {} @@ -198,7 +234,9 @@ def get_queue_usage(self, threshold = None): }, api_params) def get_queue_usage_dump(self, threshold = None): - """Get usage dump queue""" + """Get usage dump queue""" + + api_path = '/health/queue/usage-dump' api_params = {} @@ -209,7 +247,9 @@ def get_queue_usage_dump(self, threshold = None): }, api_params) def get_queue_webhooks(self, threshold = None): - """Get webhooks queue""" + """Get webhooks queue""" + + api_path = '/health/queue/webhooks' api_params = {} @@ -220,7 +260,9 @@ def get_queue_webhooks(self, threshold = None): }, api_params) def get_storage(self): - """Get storage""" + """Get storage""" + + api_path = '/health/storage' api_params = {} @@ -229,7 +271,9 @@ def get_storage(self): }, api_params) def get_storage_local(self): - """Get local storage""" + """Get local storage""" + + api_path = '/health/storage/local' api_params = {} @@ -238,11 +282,12 @@ def get_storage_local(self): }, api_params) def get_time(self): - """Get time""" + """Get time""" + + api_path = '/health/time' api_params = {} return self.client.call('get', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/locale.py b/appwrite/services/locale.py index 9286502..db38754 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Locale, self).__init__(client) def get(self): - """Get user locale""" + """Get user locale""" + + api_path = '/locale' api_params = {} @@ -16,7 +18,9 @@ def get(self): }, api_params) def list_codes(self): - """List locale codes""" + """List locale codes""" + + api_path = '/locale/codes' api_params = {} @@ -25,7 +29,9 @@ def list_codes(self): }, api_params) def list_continents(self): - """List continents""" + """List continents""" + + api_path = '/locale/continents' api_params = {} @@ -34,7 +40,9 @@ def list_continents(self): }, api_params) def list_countries(self): - """List countries""" + """List countries""" + + api_path = '/locale/countries' api_params = {} @@ -43,7 +51,9 @@ def list_countries(self): }, api_params) def list_countries_eu(self): - """List EU countries""" + """List EU countries""" + + api_path = '/locale/countries/eu' api_params = {} @@ -52,7 +62,9 @@ def list_countries_eu(self): }, api_params) def list_countries_phones(self): - """List countries phone codes""" + """List countries phone codes""" + + api_path = '/locale/countries/phones' api_params = {} @@ -61,7 +73,9 @@ def list_countries_phones(self): }, api_params) def list_currencies(self): - """List currencies""" + """List currencies""" + + api_path = '/locale/currencies' api_params = {} @@ -70,11 +84,12 @@ def list_currencies(self): }, api_params) def list_languages(self): - """List languages""" + """List languages""" + + api_path = '/locale/languages' api_params = {} return self.client.call('get', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/messaging.py b/appwrite/services/messaging.py index 9a94ad0..11e73be 100644 --- a/appwrite/services/messaging.py +++ b/appwrite/services/messaging.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Messaging, self).__init__(client) def list_messages(self, queries = None, search = None): - """List messages""" + """List messages""" + + api_path = '/messaging/messages' api_params = {} @@ -19,7 +21,9 @@ def list_messages(self, queries = None, search = None): }, api_params) def create_email(self, message_id, subject, content, topics = None, users = None, targets = None, cc = None, bcc = None, attachments = None, draft = None, html = None, scheduled_at = None): - """Create email""" + """Create email""" + + api_path = '/messaging/messages/email' api_params = {} if message_id is None: @@ -50,7 +54,9 @@ def create_email(self, message_id, subject, content, topics = None, users = None }, api_params) def update_email(self, message_id, topics = None, users = None, targets = None, subject = None, content = None, draft = None, html = None, cc = None, bcc = None, scheduled_at = None, attachments = None): - """Update email""" + """Update email""" + + api_path = '/messaging/messages/email/{messageId}' api_params = {} if message_id is None: @@ -75,7 +81,9 @@ def update_email(self, message_id, topics = None, users = None, targets = None, }, api_params) def create_push(self, message_id, title, body, topics = None, users = None, targets = None, data = None, action = None, image = None, icon = None, sound = None, color = None, tag = None, badge = None, draft = None, scheduled_at = None): - """Create push notification""" + """Create push notification""" + + api_path = '/messaging/messages/push' api_params = {} if message_id is None: @@ -110,7 +118,9 @@ def create_push(self, message_id, title, body, topics = None, users = None, targ }, api_params) def update_push(self, message_id, topics = None, users = None, targets = None, title = None, body = None, data = None, action = None, image = None, icon = None, sound = None, color = None, tag = None, badge = None, draft = None, scheduled_at = None): - """Update push notification""" + """Update push notification""" + + api_path = '/messaging/messages/push/{messageId}' api_params = {} if message_id is None: @@ -139,7 +149,9 @@ def update_push(self, message_id, topics = None, users = None, targets = None, t }, api_params) def create_sms(self, message_id, content, topics = None, users = None, targets = None, draft = None, scheduled_at = None): - """Create SMS""" + """Create SMS""" + + api_path = '/messaging/messages/sms' api_params = {} if message_id is None: @@ -162,7 +174,9 @@ def create_sms(self, message_id, content, topics = None, users = None, targets = }, api_params) def update_sms(self, message_id, topics = None, users = None, targets = None, content = None, draft = None, scheduled_at = None): - """Update SMS""" + """Update SMS""" + + api_path = '/messaging/messages/sms/{messageId}' api_params = {} if message_id is None: @@ -182,7 +196,9 @@ def update_sms(self, message_id, topics = None, users = None, targets = None, co }, api_params) def get_message(self, message_id): - """Get message""" + """Get message""" + + api_path = '/messaging/messages/{messageId}' api_params = {} if message_id is None: @@ -196,7 +212,9 @@ def get_message(self, message_id): }, api_params) def delete(self, message_id): - """Delete message""" + """Delete message""" + + api_path = '/messaging/messages/{messageId}' api_params = {} if message_id is None: @@ -210,7 +228,9 @@ def delete(self, message_id): }, api_params) def list_message_logs(self, message_id, queries = None): - """List message logs""" + """List message logs""" + + api_path = '/messaging/messages/{messageId}/logs' api_params = {} if message_id is None: @@ -225,7 +245,9 @@ def list_message_logs(self, message_id, queries = None): }, api_params) def list_targets(self, message_id, queries = None): - """List message targets""" + """List message targets""" + + api_path = '/messaging/messages/{messageId}/targets' api_params = {} if message_id is None: @@ -240,7 +262,9 @@ def list_targets(self, message_id, queries = None): }, api_params) def list_providers(self, queries = None, search = None): - """List providers""" + """List providers""" + + api_path = '/messaging/providers' api_params = {} @@ -252,7 +276,9 @@ def list_providers(self, queries = None, search = None): }, api_params) def create_apns_provider(self, provider_id, name, auth_key = None, auth_key_id = None, team_id = None, bundle_id = None, sandbox = None, enabled = None): - """Create APNS provider""" + """Create APNS provider""" + + api_path = '/messaging/providers/apns' api_params = {} if provider_id is None: @@ -276,7 +302,9 @@ def create_apns_provider(self, provider_id, name, auth_key = None, auth_key_id = }, api_params) def update_apns_provider(self, provider_id, name = None, enabled = None, auth_key = None, auth_key_id = None, team_id = None, bundle_id = None, sandbox = None): - """Update APNS provider""" + """Update APNS provider""" + + api_path = '/messaging/providers/apns/{providerId}' api_params = {} if provider_id is None: @@ -297,7 +325,9 @@ def update_apns_provider(self, provider_id, name = None, enabled = None, auth_ke }, api_params) def create_fcm_provider(self, provider_id, name, service_account_json = None, enabled = None): - """Create FCM provider""" + """Create FCM provider""" + + api_path = '/messaging/providers/fcm' api_params = {} if provider_id is None: @@ -317,7 +347,9 @@ def create_fcm_provider(self, provider_id, name, service_account_json = None, en }, api_params) def update_fcm_provider(self, provider_id, name = None, enabled = None, service_account_json = None): - """Update FCM provider""" + """Update FCM provider""" + + api_path = '/messaging/providers/fcm/{providerId}' api_params = {} if provider_id is None: @@ -334,7 +366,9 @@ def update_fcm_provider(self, provider_id, name = None, enabled = None, service_ }, api_params) def create_mailgun_provider(self, provider_id, name, api_key = None, domain = None, is_eu_region = None, from_name = None, from_email = None, reply_to_name = None, reply_to_email = None, enabled = None): - """Create Mailgun provider""" + """Create Mailgun provider""" + + api_path = '/messaging/providers/mailgun' api_params = {} if provider_id is None: @@ -360,7 +394,9 @@ def create_mailgun_provider(self, provider_id, name, api_key = None, domain = No }, api_params) def update_mailgun_provider(self, provider_id, name = None, api_key = None, domain = None, is_eu_region = None, enabled = None, from_name = None, from_email = None, reply_to_name = None, reply_to_email = None): - """Update Mailgun provider""" + """Update Mailgun provider""" + + api_path = '/messaging/providers/mailgun/{providerId}' api_params = {} if provider_id is None: @@ -383,7 +419,9 @@ def update_mailgun_provider(self, provider_id, name = None, api_key = None, doma }, api_params) def create_msg91_provider(self, provider_id, name, template_id = None, sender_id = None, auth_key = None, enabled = None): - """Create Msg91 provider""" + """Create Msg91 provider""" + + api_path = '/messaging/providers/msg91' api_params = {} if provider_id is None: @@ -405,7 +443,9 @@ def create_msg91_provider(self, provider_id, name, template_id = None, sender_id }, api_params) def update_msg91_provider(self, provider_id, name = None, enabled = None, template_id = None, sender_id = None, auth_key = None): - """Update Msg91 provider""" + """Update Msg91 provider""" + + api_path = '/messaging/providers/msg91/{providerId}' api_params = {} if provider_id is None: @@ -424,7 +464,9 @@ def update_msg91_provider(self, provider_id, name = None, enabled = None, templa }, api_params) def create_sendgrid_provider(self, provider_id, name, api_key = None, from_name = None, from_email = None, reply_to_name = None, reply_to_email = None, enabled = None): - """Create Sendgrid provider""" + """Create Sendgrid provider""" + + api_path = '/messaging/providers/sendgrid' api_params = {} if provider_id is None: @@ -448,7 +490,9 @@ def create_sendgrid_provider(self, provider_id, name, api_key = None, from_name }, api_params) def update_sendgrid_provider(self, provider_id, name = None, enabled = None, api_key = None, from_name = None, from_email = None, reply_to_name = None, reply_to_email = None): - """Update Sendgrid provider""" + """Update Sendgrid provider""" + + api_path = '/messaging/providers/sendgrid/{providerId}' api_params = {} if provider_id is None: @@ -469,7 +513,9 @@ def update_sendgrid_provider(self, provider_id, name = None, enabled = None, api }, api_params) def create_smtp_provider(self, provider_id, name, host, port = None, username = None, password = None, encryption = None, auto_tls = None, mailer = None, from_name = None, from_email = None, reply_to_name = None, reply_to_email = None, enabled = None): - """Create SMTP provider""" + """Create SMTP provider""" + + api_path = '/messaging/providers/smtp' api_params = {} if provider_id is None: @@ -502,7 +548,9 @@ def create_smtp_provider(self, provider_id, name, host, port = None, username = }, api_params) def update_smtp_provider(self, provider_id, name = None, host = None, port = None, username = None, password = None, encryption = None, auto_tls = None, mailer = None, from_name = None, from_email = None, reply_to_name = None, reply_to_email = None, enabled = None): - """Update SMTP provider""" + """Update SMTP provider""" + + api_path = '/messaging/providers/smtp/{providerId}' api_params = {} if provider_id is None: @@ -529,7 +577,9 @@ def update_smtp_provider(self, provider_id, name = None, host = None, port = Non }, api_params) def create_telesign_provider(self, provider_id, name, xfrom = None, customer_id = None, api_key = None, enabled = None): - """Create Telesign provider""" + """Create Telesign provider""" + + api_path = '/messaging/providers/telesign' api_params = {} if provider_id is None: @@ -551,7 +601,9 @@ def create_telesign_provider(self, provider_id, name, xfrom = None, customer_id }, api_params) def update_telesign_provider(self, provider_id, name = None, enabled = None, customer_id = None, api_key = None, xfrom = None): - """Update Telesign provider""" + """Update Telesign provider""" + + api_path = '/messaging/providers/telesign/{providerId}' api_params = {} if provider_id is None: @@ -570,7 +622,9 @@ def update_telesign_provider(self, provider_id, name = None, enabled = None, cus }, api_params) def create_textmagic_provider(self, provider_id, name, xfrom = None, username = None, api_key = None, enabled = None): - """Create Textmagic provider""" + """Create Textmagic provider""" + + api_path = '/messaging/providers/textmagic' api_params = {} if provider_id is None: @@ -592,7 +646,9 @@ def create_textmagic_provider(self, provider_id, name, xfrom = None, username = }, api_params) def update_textmagic_provider(self, provider_id, name = None, enabled = None, username = None, api_key = None, xfrom = None): - """Update Textmagic provider""" + """Update Textmagic provider""" + + api_path = '/messaging/providers/textmagic/{providerId}' api_params = {} if provider_id is None: @@ -611,7 +667,9 @@ def update_textmagic_provider(self, provider_id, name = None, enabled = None, us }, api_params) def create_twilio_provider(self, provider_id, name, xfrom = None, account_sid = None, auth_token = None, enabled = None): - """Create Twilio provider""" + """Create Twilio provider""" + + api_path = '/messaging/providers/twilio' api_params = {} if provider_id is None: @@ -633,7 +691,9 @@ def create_twilio_provider(self, provider_id, name, xfrom = None, account_sid = }, api_params) def update_twilio_provider(self, provider_id, name = None, enabled = None, account_sid = None, auth_token = None, xfrom = None): - """Update Twilio provider""" + """Update Twilio provider""" + + api_path = '/messaging/providers/twilio/{providerId}' api_params = {} if provider_id is None: @@ -652,7 +712,9 @@ def update_twilio_provider(self, provider_id, name = None, enabled = None, accou }, api_params) def create_vonage_provider(self, provider_id, name, xfrom = None, api_key = None, api_secret = None, enabled = None): - """Create Vonage provider""" + """Create Vonage provider""" + + api_path = '/messaging/providers/vonage' api_params = {} if provider_id is None: @@ -674,7 +736,9 @@ def create_vonage_provider(self, provider_id, name, xfrom = None, api_key = None }, api_params) def update_vonage_provider(self, provider_id, name = None, enabled = None, api_key = None, api_secret = None, xfrom = None): - """Update Vonage provider""" + """Update Vonage provider""" + + api_path = '/messaging/providers/vonage/{providerId}' api_params = {} if provider_id is None: @@ -693,7 +757,9 @@ def update_vonage_provider(self, provider_id, name = None, enabled = None, api_k }, api_params) def get_provider(self, provider_id): - """Get provider""" + """Get provider""" + + api_path = '/messaging/providers/{providerId}' api_params = {} if provider_id is None: @@ -707,7 +773,9 @@ def get_provider(self, provider_id): }, api_params) def delete_provider(self, provider_id): - """Delete provider""" + """Delete provider""" + + api_path = '/messaging/providers/{providerId}' api_params = {} if provider_id is None: @@ -721,7 +789,9 @@ def delete_provider(self, provider_id): }, api_params) def list_provider_logs(self, provider_id, queries = None): - """List provider logs""" + """List provider logs""" + + api_path = '/messaging/providers/{providerId}/logs' api_params = {} if provider_id is None: @@ -736,7 +806,9 @@ def list_provider_logs(self, provider_id, queries = None): }, api_params) def list_subscriber_logs(self, subscriber_id, queries = None): - """List subscriber logs""" + """List subscriber logs""" + + api_path = '/messaging/subscribers/{subscriberId}/logs' api_params = {} if subscriber_id is None: @@ -751,7 +823,9 @@ def list_subscriber_logs(self, subscriber_id, queries = None): }, api_params) def list_topics(self, queries = None, search = None): - """List topics""" + """List topics""" + + api_path = '/messaging/topics' api_params = {} @@ -763,7 +837,9 @@ def list_topics(self, queries = None, search = None): }, api_params) def create_topic(self, topic_id, name, subscribe = None): - """Create topic""" + """Create topic""" + + api_path = '/messaging/topics' api_params = {} if topic_id is None: @@ -782,7 +858,9 @@ def create_topic(self, topic_id, name, subscribe = None): }, api_params) def get_topic(self, topic_id): - """Get topic""" + """Get topic""" + + api_path = '/messaging/topics/{topicId}' api_params = {} if topic_id is None: @@ -796,7 +874,9 @@ def get_topic(self, topic_id): }, api_params) def update_topic(self, topic_id, name = None, subscribe = None): - """Update topic""" + """Update topic""" + + api_path = '/messaging/topics/{topicId}' api_params = {} if topic_id is None: @@ -812,7 +892,9 @@ def update_topic(self, topic_id, name = None, subscribe = None): }, api_params) def delete_topic(self, topic_id): - """Delete topic""" + """Delete topic""" + + api_path = '/messaging/topics/{topicId}' api_params = {} if topic_id is None: @@ -826,7 +908,9 @@ def delete_topic(self, topic_id): }, api_params) def list_topic_logs(self, topic_id, queries = None): - """List topic logs""" + """List topic logs""" + + api_path = '/messaging/topics/{topicId}/logs' api_params = {} if topic_id is None: @@ -841,7 +925,9 @@ def list_topic_logs(self, topic_id, queries = None): }, api_params) def list_subscribers(self, topic_id, queries = None, search = None): - """List subscribers""" + """List subscribers""" + + api_path = '/messaging/topics/{topicId}/subscribers' api_params = {} if topic_id is None: @@ -857,7 +943,9 @@ def list_subscribers(self, topic_id, queries = None, search = None): }, api_params) def create_subscriber(self, topic_id, subscriber_id, target_id): - """Create subscriber""" + """Create subscriber""" + + api_path = '/messaging/topics/{topicId}/subscribers' api_params = {} if topic_id is None: @@ -879,7 +967,9 @@ def create_subscriber(self, topic_id, subscriber_id, target_id): }, api_params) def get_subscriber(self, topic_id, subscriber_id): - """Get subscriber""" + """Get subscriber""" + + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' api_params = {} if topic_id is None: @@ -897,7 +987,9 @@ def get_subscriber(self, topic_id, subscriber_id): }, api_params) def delete_subscriber(self, topic_id, subscriber_id): - """Delete subscriber""" + """Delete subscriber""" + + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' api_params = {} if topic_id is None: @@ -913,4 +1005,3 @@ def delete_subscriber(self, topic_id, subscriber_id): return self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index f264c80..9acbb3a 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Storage, self).__init__(client) def list_buckets(self, queries = None, search = None): - """List buckets""" + """List buckets""" + + api_path = '/storage/buckets' api_params = {} @@ -19,7 +21,9 @@ def list_buckets(self, queries = None, search = None): }, api_params) def create_bucket(self, bucket_id, name, permissions = None, file_security = None, enabled = None, maximum_file_size = None, allowed_file_extensions = None, compression = None, encryption = None, antivirus = None): - """Create bucket""" + """Create bucket""" + + api_path = '/storage/buckets' api_params = {} if bucket_id is None: @@ -45,7 +49,9 @@ def create_bucket(self, bucket_id, name, permissions = None, file_security = Non }, api_params) def get_bucket(self, bucket_id): - """Get bucket""" + """Get bucket""" + + api_path = '/storage/buckets/{bucketId}' api_params = {} if bucket_id is None: @@ -59,7 +65,9 @@ def get_bucket(self, bucket_id): }, api_params) def update_bucket(self, bucket_id, name, permissions = None, file_security = None, enabled = None, maximum_file_size = None, allowed_file_extensions = None, compression = None, encryption = None, antivirus = None): - """Update bucket""" + """Update bucket""" + + api_path = '/storage/buckets/{bucketId}' api_params = {} if bucket_id is None: @@ -85,7 +93,9 @@ def update_bucket(self, bucket_id, name, permissions = None, file_security = Non }, api_params) def delete_bucket(self, bucket_id): - """Delete bucket""" + """Delete bucket""" + + api_path = '/storage/buckets/{bucketId}' api_params = {} if bucket_id is None: @@ -99,7 +109,9 @@ def delete_bucket(self, bucket_id): }, api_params) def list_files(self, bucket_id, queries = None, search = None): - """List files""" + """List files""" + + api_path = '/storage/buckets/{bucketId}/files' api_params = {} if bucket_id is None: @@ -115,7 +127,9 @@ def list_files(self, bucket_id, queries = None, search = None): }, api_params) def create_file(self, bucket_id, file_id, file, permissions = None, on_progress = None): - """Create file""" + """Create file""" + + api_path = '/storage/buckets/{bucketId}/files' api_params = {} if bucket_id is None: @@ -134,15 +148,19 @@ def create_file(self, bucket_id, file_id, file, permissions = None, on_progress api_params['permissions'] = permissions param_name = 'file' + + upload_id = '' upload_id = file_id + return self.client.chunked_upload(api_path, { 'content-type': 'multipart/form-data', }, api_params, param_name, on_progress, upload_id) - def get_file(self, bucket_id, file_id): - """Get file""" + """Get file""" + + api_path = '/storage/buckets/{bucketId}/files/{fileId}' api_params = {} if bucket_id is None: @@ -160,7 +178,9 @@ def get_file(self, bucket_id, file_id): }, api_params) def update_file(self, bucket_id, file_id, name = None, permissions = None): - """Update file""" + """Update file""" + + api_path = '/storage/buckets/{bucketId}/files/{fileId}' api_params = {} if bucket_id is None: @@ -180,7 +200,9 @@ def update_file(self, bucket_id, file_id, name = None, permissions = None): }, api_params) def delete_file(self, bucket_id, file_id): - """Delete file""" + """Delete file""" + + api_path = '/storage/buckets/{bucketId}/files/{fileId}' api_params = {} if bucket_id is None: @@ -198,7 +220,9 @@ def delete_file(self, bucket_id, file_id): }, api_params) def get_file_download(self, bucket_id, file_id): - """Get file for download""" + """Get file for download""" + + api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' api_params = {} if bucket_id is None: @@ -216,7 +240,9 @@ def get_file_download(self, bucket_id, file_id): }, api_params) def get_file_preview(self, bucket_id, file_id, width = None, height = None, gravity = None, quality = None, border_width = None, border_color = None, border_radius = None, opacity = None, rotation = None, background = None, output = None): - """Get file preview""" + """Get file preview""" + + api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' api_params = {} if bucket_id is None: @@ -245,7 +271,9 @@ def get_file_preview(self, bucket_id, file_id, width = None, height = None, grav }, api_params) def get_file_view(self, bucket_id, file_id): - """Get file for view""" + """Get file for view""" + + api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' api_params = {} if bucket_id is None: @@ -261,4 +289,3 @@ def get_file_view(self, bucket_id, file_id): return self.client.call('get', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 0dd009d..2c387ed 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Teams, self).__init__(client) def list(self, queries = None, search = None): - """List teams""" + """List teams""" + + api_path = '/teams' api_params = {} @@ -19,7 +21,9 @@ def list(self, queries = None, search = None): }, api_params) def create(self, team_id, name, roles = None): - """Create team""" + """Create team""" + + api_path = '/teams' api_params = {} if team_id is None: @@ -38,7 +42,9 @@ def create(self, team_id, name, roles = None): }, api_params) def get(self, team_id): - """Get team""" + """Get team""" + + api_path = '/teams/{teamId}' api_params = {} if team_id is None: @@ -52,7 +58,9 @@ def get(self, team_id): }, api_params) def update_name(self, team_id, name): - """Update name""" + """Update name""" + + api_path = '/teams/{teamId}' api_params = {} if team_id is None: @@ -70,7 +78,9 @@ def update_name(self, team_id, name): }, api_params) def delete(self, team_id): - """Delete team""" + """Delete team""" + + api_path = '/teams/{teamId}' api_params = {} if team_id is None: @@ -84,7 +94,9 @@ def delete(self, team_id): }, api_params) def list_memberships(self, team_id, queries = None, search = None): - """List team memberships""" + """List team memberships""" + + api_path = '/teams/{teamId}/memberships' api_params = {} if team_id is None: @@ -100,7 +112,9 @@ def list_memberships(self, team_id, queries = None, search = None): }, api_params) def create_membership(self, team_id, roles, email = None, user_id = None, phone = None, url = None, name = None): - """Create team membership""" + """Create team membership""" + + api_path = '/teams/{teamId}/memberships' api_params = {} if team_id is None: @@ -123,7 +137,9 @@ def create_membership(self, team_id, roles, email = None, user_id = None, phone }, api_params) def get_membership(self, team_id, membership_id): - """Get team membership""" + """Get team membership""" + + api_path = '/teams/{teamId}/memberships/{membershipId}' api_params = {} if team_id is None: @@ -141,7 +157,9 @@ def get_membership(self, team_id, membership_id): }, api_params) def update_membership(self, team_id, membership_id, roles): - """Update membership""" + """Update membership""" + + api_path = '/teams/{teamId}/memberships/{membershipId}' api_params = {} if team_id is None: @@ -163,7 +181,9 @@ def update_membership(self, team_id, membership_id, roles): }, api_params) def delete_membership(self, team_id, membership_id): - """Delete team membership""" + """Delete team membership""" + + api_path = '/teams/{teamId}/memberships/{membershipId}' api_params = {} if team_id is None: @@ -181,7 +201,9 @@ def delete_membership(self, team_id, membership_id): }, api_params) def update_membership_status(self, team_id, membership_id, user_id, secret): - """Update team membership status""" + """Update team membership status""" + + api_path = '/teams/{teamId}/memberships/{membershipId}/status' api_params = {} if team_id is None: @@ -207,7 +229,9 @@ def update_membership_status(self, team_id, membership_id, user_id, secret): }, api_params) def get_prefs(self, team_id): - """Get team preferences""" + """Get team preferences""" + + api_path = '/teams/{teamId}/prefs' api_params = {} if team_id is None: @@ -221,7 +245,9 @@ def get_prefs(self, team_id): }, api_params) def update_prefs(self, team_id, prefs): - """Update preferences""" + """Update preferences""" + + api_path = '/teams/{teamId}/prefs' api_params = {} if team_id is None: @@ -237,4 +263,3 @@ def update_prefs(self, team_id, prefs): return self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/appwrite/services/users.py b/appwrite/services/users.py index 0774580..aa04a72 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -7,7 +7,9 @@ def __init__(self, client): super(Users, self).__init__(client) def list(self, queries = None, search = None): - """List users""" + """List users""" + + api_path = '/users' api_params = {} @@ -19,7 +21,9 @@ def list(self, queries = None, search = None): }, api_params) def create(self, user_id, email = None, phone = None, password = None, name = None): - """Create user""" + """Create user""" + + api_path = '/users' api_params = {} if user_id is None: @@ -37,7 +41,9 @@ def create(self, user_id, email = None, phone = None, password = None, name = No }, api_params) def create_argon2_user(self, user_id, email, password, name = None): - """Create user with Argon2 password""" + """Create user with Argon2 password""" + + api_path = '/users/argon2' api_params = {} if user_id is None: @@ -60,7 +66,9 @@ def create_argon2_user(self, user_id, email, password, name = None): }, api_params) def create_bcrypt_user(self, user_id, email, password, name = None): - """Create user with bcrypt password""" + """Create user with bcrypt password""" + + api_path = '/users/bcrypt' api_params = {} if user_id is None: @@ -83,7 +91,9 @@ def create_bcrypt_user(self, user_id, email, password, name = None): }, api_params) def list_identities(self, queries = None, search = None): - """List identities""" + """List identities""" + + api_path = '/users/identities' api_params = {} @@ -95,7 +105,9 @@ def list_identities(self, queries = None, search = None): }, api_params) def delete_identity(self, identity_id): - """Delete identity""" + """Delete identity""" + + api_path = '/users/identities/{identityId}' api_params = {} if identity_id is None: @@ -109,7 +121,9 @@ def delete_identity(self, identity_id): }, api_params) def create_md5_user(self, user_id, email, password, name = None): - """Create user with MD5 password""" + """Create user with MD5 password""" + + api_path = '/users/md5' api_params = {} if user_id is None: @@ -132,7 +146,9 @@ def create_md5_user(self, user_id, email, password, name = None): }, api_params) def create_ph_pass_user(self, user_id, email, password, name = None): - """Create user with PHPass password""" + """Create user with PHPass password""" + + api_path = '/users/phpass' api_params = {} if user_id is None: @@ -155,7 +171,9 @@ def create_ph_pass_user(self, user_id, email, password, name = None): }, api_params) def create_scrypt_user(self, user_id, email, password, password_salt, password_cpu, password_memory, password_parallel, password_length, name = None): - """Create user with Scrypt password""" + """Create user with Scrypt password""" + + api_path = '/users/scrypt' api_params = {} if user_id is None: @@ -198,7 +216,9 @@ def create_scrypt_user(self, user_id, email, password, password_salt, password_c }, api_params) def create_scrypt_modified_user(self, user_id, email, password, password_salt, password_salt_separator, password_signer_key, name = None): - """Create user with Scrypt modified password""" + """Create user with Scrypt modified password""" + + api_path = '/users/scrypt-modified' api_params = {} if user_id is None: @@ -233,7 +253,9 @@ def create_scrypt_modified_user(self, user_id, email, password, password_salt, p }, api_params) def create_sha_user(self, user_id, email, password, password_version = None, name = None): - """Create user with SHA password""" + """Create user with SHA password""" + + api_path = '/users/sha' api_params = {} if user_id is None: @@ -257,7 +279,9 @@ def create_sha_user(self, user_id, email, password, password_version = None, nam }, api_params) def get(self, user_id): - """Get user""" + """Get user""" + + api_path = '/users/{userId}' api_params = {} if user_id is None: @@ -271,7 +295,9 @@ def get(self, user_id): }, api_params) def delete(self, user_id): - """Delete user""" + """Delete user""" + + api_path = '/users/{userId}' api_params = {} if user_id is None: @@ -285,7 +311,9 @@ def delete(self, user_id): }, api_params) def update_email(self, user_id, email): - """Update email""" + """Update email""" + + api_path = '/users/{userId}/email' api_params = {} if user_id is None: @@ -303,7 +331,9 @@ def update_email(self, user_id, email): }, api_params) def create_jwt(self, user_id, session_id = None, duration = None): - """Create user JWT""" + """Create user JWT""" + + api_path = '/users/{userId}/jwts' api_params = {} if user_id is None: @@ -319,7 +349,9 @@ def create_jwt(self, user_id, session_id = None, duration = None): }, api_params) def update_labels(self, user_id, labels): - """Update user labels""" + """Update user labels""" + + api_path = '/users/{userId}/labels' api_params = {} if user_id is None: @@ -337,7 +369,9 @@ def update_labels(self, user_id, labels): }, api_params) def list_logs(self, user_id, queries = None): - """List user logs""" + """List user logs""" + + api_path = '/users/{userId}/logs' api_params = {} if user_id is None: @@ -352,7 +386,9 @@ def list_logs(self, user_id, queries = None): }, api_params) def list_memberships(self, user_id): - """List user memberships""" + """List user memberships""" + + api_path = '/users/{userId}/memberships' api_params = {} if user_id is None: @@ -366,7 +402,9 @@ def list_memberships(self, user_id): }, api_params) def update_mfa(self, user_id, mfa): - """Update MFA""" + """Update MFA""" + + api_path = '/users/{userId}/mfa' api_params = {} if user_id is None: @@ -384,7 +422,9 @@ def update_mfa(self, user_id, mfa): }, api_params) def delete_mfa_authenticator(self, user_id, type): - """Delete authenticator""" + """Delete authenticator""" + + api_path = '/users/{userId}/mfa/authenticators/{type}' api_params = {} if user_id is None: @@ -402,7 +442,9 @@ def delete_mfa_authenticator(self, user_id, type): }, api_params) def list_mfa_factors(self, user_id): - """List factors""" + """List factors""" + + api_path = '/users/{userId}/mfa/factors' api_params = {} if user_id is None: @@ -416,7 +458,9 @@ def list_mfa_factors(self, user_id): }, api_params) def get_mfa_recovery_codes(self, user_id): - """Get MFA recovery codes""" + """Get MFA recovery codes""" + + api_path = '/users/{userId}/mfa/recovery-codes' api_params = {} if user_id is None: @@ -430,7 +474,9 @@ def get_mfa_recovery_codes(self, user_id): }, api_params) def update_mfa_recovery_codes(self, user_id): - """Regenerate MFA recovery codes""" + """Regenerate MFA recovery codes""" + + api_path = '/users/{userId}/mfa/recovery-codes' api_params = {} if user_id is None: @@ -444,7 +490,9 @@ def update_mfa_recovery_codes(self, user_id): }, api_params) def create_mfa_recovery_codes(self, user_id): - """Create MFA recovery codes""" + """Create MFA recovery codes""" + + api_path = '/users/{userId}/mfa/recovery-codes' api_params = {} if user_id is None: @@ -458,7 +506,9 @@ def create_mfa_recovery_codes(self, user_id): }, api_params) def update_name(self, user_id, name): - """Update name""" + """Update name""" + + api_path = '/users/{userId}/name' api_params = {} if user_id is None: @@ -476,7 +526,9 @@ def update_name(self, user_id, name): }, api_params) def update_password(self, user_id, password): - """Update password""" + """Update password""" + + api_path = '/users/{userId}/password' api_params = {} if user_id is None: @@ -494,7 +546,9 @@ def update_password(self, user_id, password): }, api_params) def update_phone(self, user_id, number): - """Update phone""" + """Update phone""" + + api_path = '/users/{userId}/phone' api_params = {} if user_id is None: @@ -512,7 +566,9 @@ def update_phone(self, user_id, number): }, api_params) def get_prefs(self, user_id): - """Get user preferences""" + """Get user preferences""" + + api_path = '/users/{userId}/prefs' api_params = {} if user_id is None: @@ -526,7 +582,9 @@ def get_prefs(self, user_id): }, api_params) def update_prefs(self, user_id, prefs): - """Update user preferences""" + """Update user preferences""" + + api_path = '/users/{userId}/prefs' api_params = {} if user_id is None: @@ -544,7 +602,9 @@ def update_prefs(self, user_id, prefs): }, api_params) def list_sessions(self, user_id): - """List user sessions""" + """List user sessions""" + + api_path = '/users/{userId}/sessions' api_params = {} if user_id is None: @@ -558,7 +618,9 @@ def list_sessions(self, user_id): }, api_params) def create_session(self, user_id): - """Create session""" + """Create session""" + + api_path = '/users/{userId}/sessions' api_params = {} if user_id is None: @@ -572,7 +634,9 @@ def create_session(self, user_id): }, api_params) def delete_sessions(self, user_id): - """Delete user sessions""" + """Delete user sessions""" + + api_path = '/users/{userId}/sessions' api_params = {} if user_id is None: @@ -586,7 +650,9 @@ def delete_sessions(self, user_id): }, api_params) def delete_session(self, user_id, session_id): - """Delete user session""" + """Delete user session""" + + api_path = '/users/{userId}/sessions/{sessionId}' api_params = {} if user_id is None: @@ -604,7 +670,9 @@ def delete_session(self, user_id, session_id): }, api_params) def update_status(self, user_id, status): - """Update user status""" + """Update user status""" + + api_path = '/users/{userId}/status' api_params = {} if user_id is None: @@ -622,7 +690,9 @@ def update_status(self, user_id, status): }, api_params) def list_targets(self, user_id, queries = None): - """List user targets""" + """List user targets""" + + api_path = '/users/{userId}/targets' api_params = {} if user_id is None: @@ -637,7 +707,9 @@ def list_targets(self, user_id, queries = None): }, api_params) def create_target(self, user_id, target_id, provider_type, identifier, provider_id = None, name = None): - """Create user target""" + """Create user target""" + + api_path = '/users/{userId}/targets' api_params = {} if user_id is None: @@ -665,7 +737,9 @@ def create_target(self, user_id, target_id, provider_type, identifier, provider_ }, api_params) def get_target(self, user_id, target_id): - """Get user target""" + """Get user target""" + + api_path = '/users/{userId}/targets/{targetId}' api_params = {} if user_id is None: @@ -683,7 +757,9 @@ def get_target(self, user_id, target_id): }, api_params) def update_target(self, user_id, target_id, identifier = None, provider_id = None, name = None): - """Update user target""" + """Update user target""" + + api_path = '/users/{userId}/targets/{targetId}' api_params = {} if user_id is None: @@ -704,7 +780,9 @@ def update_target(self, user_id, target_id, identifier = None, provider_id = Non }, api_params) def delete_target(self, user_id, target_id): - """Delete user target""" + """Delete user target""" + + api_path = '/users/{userId}/targets/{targetId}' api_params = {} if user_id is None: @@ -722,7 +800,9 @@ def delete_target(self, user_id, target_id): }, api_params) def create_token(self, user_id, length = None, expire = None): - """Create token""" + """Create token""" + + api_path = '/users/{userId}/tokens' api_params = {} if user_id is None: @@ -738,7 +818,9 @@ def create_token(self, user_id, length = None, expire = None): }, api_params) def update_email_verification(self, user_id, email_verification): - """Update email verification""" + """Update email verification""" + + api_path = '/users/{userId}/verification' api_params = {} if user_id is None: @@ -756,7 +838,9 @@ def update_email_verification(self, user_id, email_verification): }, api_params) def update_phone_verification(self, user_id, phone_verification): - """Update phone verification""" + """Update phone verification""" + + api_path = '/users/{userId}/verification/phone' api_params = {} if user_id is None: @@ -772,4 +856,3 @@ def update_phone_verification(self, user_id, phone_verification): return self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index bbe7ddb..ab910d9 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -13,6 +13,6 @@ result = databases.update_string_attribute( key = '', required = False, default = '', - size = None, # optional + size = 1, # optional new_key = '' # optional ) diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 9e2b711..da9b559 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -1,5 +1,5 @@ from appwrite.client import Client -from appwrite.payload import Payload +from appwrite.input_file import InputFile client = Client() client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint @@ -10,7 +10,7 @@ functions = Functions(client) result = functions.create_deployment( function_id = '', - code = Payload.from_file('/path/to/file.png'), + code = InputFile.from_path('file.png'), activate = False, entrypoint = '', # optional commands = '' # optional diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index aa4a2f5..e1decb9 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -9,7 +9,7 @@ functions = Functions(client) result = functions.create_execution( function_id = '', - body = Payload.from_json({"x": "y"}), # optional + body = '', # optional async = False, # optional path = '', # optional method = ExecutionMethod.GET, # optional diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 2884c26..d275070 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,5 +1,5 @@ from appwrite.client import Client -from appwrite.payload import Payload +from appwrite.input_file import InputFile client = Client() client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint @@ -11,6 +11,6 @@ storage = Storage(client) result = storage.create_file( bucket_id = '', file_id = '', - file = Payload.from_file('/path/to/file.png'), + file = InputFile.from_path('file.png'), permissions = ["read("any")"] # optional )