diff --git a/appwrite/client.py b/appwrite/client.py index 9c96d2e..17b4fe3 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -1,8 +1,7 @@ -import io import json -import os import requests -from .input_file import InputFile +from .payload import Payload +from .multipart import MultipartParser from .exception import AppwriteException from .encoders.value_class_encoder import ValueClassEncoder @@ -13,11 +12,11 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : 'AppwritePythonSDK/6.1.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})', + 'user-agent' : 'AppwritePythonSDK/7.0.0-rc1 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '6.1.0', + 'x-sdk-version': '7.0.0-rc1', 'X-Appwrite-Response-Format' : '1.6.0', } @@ -91,10 +90,14 @@ 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], InputFile): - files[key] = (data[key].filename, data[key].data) + if isinstance(data[key], Payload): + if data[key].filename: + files[key] = (data[key].filename, data[key].to_binary()) + else: + data[key] = data[key].to_binary() del data[key] data = self.flatten(data, stringify=stringify) @@ -126,6 +129,9 @@ 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: @@ -146,20 +152,10 @@ def chunked_upload( on_progress = None, upload_id = '' ): - input_file = params[param_name] - - if input_file.source_type == 'path': - size = os.stat(input_file.path).st_size - input = open(input_file.path, 'rb') - elif input_file.source_type == 'bytes': - size = len(input_file.data) - input = input_file.data - - if size < self._chunk_size: - if input_file.source_type == 'path': - input_file.data = input.read() + payload = params[param_name] + size = params[param_name].size - params[param_name] = input_file + if size < self._chunk_size: return self.call( 'post', path, @@ -182,16 +178,10 @@ def chunked_upload( input.seek(offset) while offset < size: - if input_file.source_type == 'path': - input_file.data = input.read(self._chunk_size) or input.read(size - offset) - elif input_file.source_type == 'bytes': - if offset + self._chunk_size < size: - end = offset + self._chunk_size - else: - end = size - offset - input_file.data = input[offset:end] - - params[param_name] = input_file + params[param_name] = Payload.from_binary( + payload.to_binary(offset, min(self._chunk_size, size - offset)), + payload.filename + ) 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 a52ca61..1e0b47a 100644 --- a/appwrite/enums/runtime.py +++ b/appwrite/enums/runtime.py @@ -21,6 +21,9 @@ class Runtime(Enum): PYTHON_3_11 = "python-3.11" PYTHON_3_12 = "python-3.12" PYTHON_ML_3_11 = "python-ml-3.11" + DENO_1_21 = "deno-1.21" + DENO_1_24 = "deno-1.24" + DENO_1_35 = "deno-1.35" DENO_1_40 = "deno-1.40" DART_2_15 = "dart-2.15" DART_2_16 = "dart-2.16" diff --git a/appwrite/input_file.py b/appwrite/input_file.py deleted file mode 100644 index 33d5a77..0000000 --- a/appwrite/input_file.py +++ /dev/null @@ -1,21 +0,0 @@ -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 new file mode 100644 index 0000000..27ceb63 --- /dev/null +++ b/appwrite/multipart.py @@ -0,0 +1,48 @@ +from email.parser import BytesParser +from email.policy import default +from .payload import Payload + +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] = dict(line.split(": ", 1) for line in headers_str.split("\r\n") if line) + 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 new file mode 100644 index 0000000..7d1108d --- /dev/null +++ b/appwrite/payload.py @@ -0,0 +1,63 @@ +from typing import Optional, Dict, Any +import os, json + +class Payload: + size: int + filename: Optional[str] = None + + _path: Optional[str] = None + _data: Optional[bytes] = None + + def __init__(self, path: Optional[str] = None, data: Optional[bytes] = None, filename: Optional[str] = None): + if not path and not data: + raise ValueError("One of path or data must be provided") + + self._path = path + self._data = data + + self.filename = filename + if not self._data: + 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 not length: + length = self.size + + if not self._data: + with open(self._path, 'rb') as f: + f.seek(offset) + return f.read(length) + + return self._data[offset:offset + length] + + def to_string(self) -> str: + return str(self.to_binary()) + + def to_json(self) -> Dict[str, Any]: + return json.loads(self.to_string()) + + def to_file(self, path: str) -> None: # in the client SDKs, this is def to_file() -> File: + 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, json: Dict[str, Any]) -> 'Payload': + return cls(data=json.dumps(json)) \ No newline at end of file diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 7e38e08..d782da0 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -7,9 +7,7 @@ def __init__(self, client): super(Account, self).__init__(client) def get(self): - """Get account""" - - + """Get account""" api_path = '/account' api_params = {} @@ -18,9 +16,7 @@ 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: @@ -43,9 +39,7 @@ 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: @@ -63,9 +57,7 @@ def update_email(self, email, password): }, api_params) def list_identities(self, queries = None): - """List Identities""" - - + """List Identities""" api_path = '/account/identities' api_params = {} @@ -76,9 +68,7 @@ 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: @@ -92,9 +82,7 @@ def delete_identity(self, identity_id): }, api_params) def create_jwt(self): - """Create JWT""" - - + """Create JWT""" api_path = '/account/jwts' api_params = {} @@ -103,9 +91,7 @@ def create_jwt(self): }, api_params) def list_logs(self, queries = None): - """List logs""" - - + """List logs""" api_path = '/account/logs' api_params = {} @@ -116,9 +102,7 @@ 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: @@ -132,9 +116,7 @@ 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: @@ -148,9 +130,7 @@ 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: @@ -168,9 +148,7 @@ 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: @@ -184,9 +162,7 @@ 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: @@ -200,9 +176,7 @@ 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: @@ -220,9 +194,7 @@ 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 = {} @@ -231,9 +203,7 @@ 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 = {} @@ -242,9 +212,7 @@ 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 = {} @@ -253,9 +221,7 @@ 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 = {} @@ -264,9 +230,7 @@ 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: @@ -280,9 +244,7 @@ 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: @@ -297,9 +259,7 @@ 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: @@ -317,9 +277,7 @@ def update_phone(self, phone, password): }, api_params) def get_prefs(self): - """Get account preferences""" - - + """Get account preferences""" api_path = '/account/prefs' api_params = {} @@ -328,9 +286,7 @@ 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: @@ -344,9 +300,7 @@ 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: @@ -364,9 +318,7 @@ 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: @@ -388,9 +340,7 @@ def update_recovery(self, user_id, secret, password): }, api_params) def list_sessions(self): - """List sessions""" - - + """List sessions""" api_path = '/account/sessions' api_params = {} @@ -399,9 +349,7 @@ def list_sessions(self): }, api_params) def delete_sessions(self): - """Delete sessions""" - - + """Delete sessions""" api_path = '/account/sessions' api_params = {} @@ -410,9 +358,7 @@ def delete_sessions(self): }, api_params) def create_anonymous_session(self): - """Create anonymous session""" - - + """Create anonymous session""" api_path = '/account/sessions/anonymous' api_params = {} @@ -421,9 +367,7 @@ 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: @@ -441,9 +385,7 @@ 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: @@ -461,9 +403,7 @@ 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: @@ -481,9 +421,7 @@ 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: @@ -501,9 +439,7 @@ 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: @@ -517,9 +453,7 @@ 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: @@ -533,9 +467,7 @@ 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: @@ -549,9 +481,7 @@ def delete_session(self, session_id): }, api_params) def update_status(self): - """Update status""" - - + """Update status""" api_path = '/account/status' api_params = {} @@ -560,9 +490,7 @@ 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: @@ -581,9 +509,7 @@ 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: @@ -603,9 +529,7 @@ 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: @@ -622,9 +546,7 @@ 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: @@ -642,9 +564,7 @@ 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: @@ -658,9 +578,7 @@ 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: @@ -678,9 +596,7 @@ 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 = {} @@ -689,9 +605,7 @@ 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: @@ -707,3 +621,4 @@ 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 0a9b400..a8e23ce 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -7,9 +7,7 @@ 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: @@ -26,9 +24,7 @@ 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: @@ -45,9 +41,7 @@ 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: @@ -61,9 +55,7 @@ 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: @@ -80,9 +72,7 @@ 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: @@ -98,9 +88,7 @@ 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 = {} @@ -114,9 +102,7 @@ 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: @@ -131,3 +117,4 @@ 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 aa47e4e..c39d7ec 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -7,9 +7,7 @@ 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 = {} @@ -21,9 +19,7 @@ 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: @@ -42,9 +38,7 @@ 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: @@ -58,9 +52,7 @@ 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: @@ -79,9 +71,7 @@ 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: @@ -95,9 +85,7 @@ 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: @@ -113,9 +101,7 @@ 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: @@ -140,9 +126,7 @@ 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: @@ -160,9 +144,7 @@ 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: @@ -187,9 +169,7 @@ 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: @@ -207,9 +187,7 @@ 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: @@ -228,9 +206,7 @@ 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: @@ -258,9 +234,7 @@ 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: @@ -288,9 +262,7 @@ 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: @@ -318,9 +290,7 @@ 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: @@ -348,9 +318,7 @@ 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: @@ -378,9 +346,7 @@ 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: @@ -408,9 +374,7 @@ 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: @@ -442,9 +406,7 @@ 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: @@ -476,9 +438,7 @@ 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: @@ -508,9 +468,7 @@ 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: @@ -546,9 +504,7 @@ 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: @@ -578,9 +534,7 @@ 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: @@ -616,9 +570,7 @@ 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: @@ -646,9 +598,7 @@ 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: @@ -676,9 +626,7 @@ 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: @@ -708,9 +656,7 @@ 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: @@ -743,9 +689,7 @@ 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: @@ -774,9 +718,7 @@ 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: @@ -804,9 +746,7 @@ 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: @@ -834,9 +774,7 @@ 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: @@ -858,9 +796,7 @@ 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: @@ -882,9 +818,7 @@ 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: @@ -908,9 +842,7 @@ 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: @@ -929,9 +861,7 @@ 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: @@ -958,9 +888,7 @@ 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: @@ -983,9 +911,7 @@ 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: @@ -1009,9 +935,7 @@ 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: @@ -1033,9 +957,7 @@ 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: @@ -1054,9 +976,7 @@ 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: @@ -1087,9 +1007,7 @@ 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: @@ -1111,9 +1029,7 @@ 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: @@ -1133,3 +1049,4 @@ 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 34b13a9..d59e288 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -7,9 +7,7 @@ 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 = {} @@ -21,9 +19,7 @@ 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: @@ -64,9 +60,7 @@ 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 = {} @@ -75,9 +69,7 @@ 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 = {} @@ -86,9 +78,7 @@ 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: @@ -102,9 +92,7 @@ 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: @@ -138,9 +126,7 @@ 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: @@ -154,9 +140,7 @@ 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: @@ -172,9 +156,7 @@ 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: @@ -194,18 +176,15 @@ 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""" - + def get_deployment(self, function_id, deployment_id): + """Get deployment""" api_path = '/functions/{functionId}/deployments/{deploymentId}' api_params = {} if function_id is None: @@ -223,9 +202,7 @@ 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: @@ -243,9 +220,7 @@ 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: @@ -263,9 +238,7 @@ 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: @@ -284,9 +257,7 @@ 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: @@ -304,9 +275,7 @@ 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: @@ -324,9 +293,7 @@ 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: @@ -341,10 +308,8 @@ 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): - """Create execution""" - - + def create_execution(self, function_id, body = None, xasync = None, path = None, method = None, headers = None, scheduled_at = None, on_progress = None): + """Create execution""" api_path = '/functions/{functionId}/executions' api_params = {} if function_id is None: @@ -352,21 +317,19 @@ def create_execution(self, function_id, body = None, xasync = None, path = None, api_path = api_path.replace('{functionId}', function_id) - api_params['body'] = body - api_params['async'] = xasync + 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['path'] = path api_params['method'] = method - api_params['headers'] = headers + api_params['headers'] = str(headers).lower() if type(headers) is bool else headers api_params['scheduledAt'] = scheduled_at return self.client.call('post', api_path, { - 'content-type': 'application/json', + 'content-type': 'multipart/form-data', }, 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: @@ -384,9 +347,7 @@ 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: @@ -404,9 +365,7 @@ 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: @@ -420,9 +379,7 @@ 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: @@ -444,9 +401,7 @@ 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: @@ -464,9 +419,7 @@ 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: @@ -489,9 +442,7 @@ 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: @@ -507,3 +458,4 @@ 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 58a6e99..defa60c 100644 --- a/appwrite/services/graphql.py +++ b/appwrite/services/graphql.py @@ -7,9 +7,7 @@ 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: @@ -24,9 +22,7 @@ def query(self, query): }, api_params) def mutation(self, query): - """GraphQL endpoint""" - - + """GraphQL endpoint""" api_path = '/graphql/mutation' api_params = {} if query is None: @@ -39,3 +35,4 @@ 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 ef4b3cd..ea1e6f2 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -7,9 +7,7 @@ def __init__(self, client): super(Health, self).__init__(client) def get(self): - """Get HTTP""" - - + """Get HTTP""" api_path = '/health' api_params = {} @@ -18,9 +16,7 @@ def get(self): }, api_params) def get_antivirus(self): - """Get antivirus""" - - + """Get antivirus""" api_path = '/health/anti-virus' api_params = {} @@ -29,9 +25,7 @@ def get_antivirus(self): }, api_params) def get_cache(self): - """Get cache""" - - + """Get cache""" api_path = '/health/cache' api_params = {} @@ -40,9 +34,7 @@ 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 = {} @@ -53,9 +45,7 @@ def get_certificate(self, domain = None): }, api_params) def get_db(self): - """Get DB""" - - + """Get DB""" api_path = '/health/db' api_params = {} @@ -64,9 +54,7 @@ def get_db(self): }, api_params) def get_pub_sub(self): - """Get pubsub""" - - + """Get pubsub""" api_path = '/health/pubsub' api_params = {} @@ -75,9 +63,7 @@ def get_pub_sub(self): }, api_params) def get_queue(self): - """Get queue""" - - + """Get queue""" api_path = '/health/queue' api_params = {} @@ -86,9 +72,7 @@ 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 = {} @@ -99,9 +83,7 @@ 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 = {} @@ -112,9 +94,7 @@ 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 = {} @@ -126,9 +106,7 @@ 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 = {} @@ -139,9 +117,7 @@ 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: @@ -156,9 +132,7 @@ 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 = {} @@ -169,9 +143,7 @@ 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 = {} @@ -182,9 +154,7 @@ 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 = {} @@ -195,9 +165,7 @@ 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 = {} @@ -208,9 +176,7 @@ 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 = {} @@ -221,9 +187,7 @@ 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 = {} @@ -234,9 +198,7 @@ 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 = {} @@ -247,9 +209,7 @@ 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 = {} @@ -260,9 +220,7 @@ def get_queue_webhooks(self, threshold = None): }, api_params) def get_storage(self): - """Get storage""" - - + """Get storage""" api_path = '/health/storage' api_params = {} @@ -271,9 +229,7 @@ def get_storage(self): }, api_params) def get_storage_local(self): - """Get local storage""" - - + """Get local storage""" api_path = '/health/storage/local' api_params = {} @@ -282,12 +238,11 @@ 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 2ba17ac..bd386f0 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -7,9 +7,7 @@ def __init__(self, client): super(Locale, self).__init__(client) def get(self): - """Get user locale""" - - + """Get user locale""" api_path = '/locale' api_params = {} @@ -18,9 +16,7 @@ def get(self): }, api_params) def list_codes(self): - """List Locale Codes""" - - + """List Locale Codes""" api_path = '/locale/codes' api_params = {} @@ -29,9 +25,7 @@ def list_codes(self): }, api_params) def list_continents(self): - """List continents""" - - + """List continents""" api_path = '/locale/continents' api_params = {} @@ -40,9 +34,7 @@ def list_continents(self): }, api_params) def list_countries(self): - """List countries""" - - + """List countries""" api_path = '/locale/countries' api_params = {} @@ -51,9 +43,7 @@ def list_countries(self): }, api_params) def list_countries_eu(self): - """List EU countries""" - - + """List EU countries""" api_path = '/locale/countries/eu' api_params = {} @@ -62,9 +52,7 @@ 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 = {} @@ -73,9 +61,7 @@ def list_countries_phones(self): }, api_params) def list_currencies(self): - """List currencies""" - - + """List currencies""" api_path = '/locale/currencies' api_params = {} @@ -84,12 +70,11 @@ 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 11e73be..9a94ad0 100644 --- a/appwrite/services/messaging.py +++ b/appwrite/services/messaging.py @@ -7,9 +7,7 @@ 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 = {} @@ -21,9 +19,7 @@ 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: @@ -54,9 +50,7 @@ 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: @@ -81,9 +75,7 @@ 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: @@ -118,9 +110,7 @@ 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: @@ -149,9 +139,7 @@ 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: @@ -174,9 +162,7 @@ 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: @@ -196,9 +182,7 @@ 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: @@ -212,9 +196,7 @@ 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: @@ -228,9 +210,7 @@ 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: @@ -245,9 +225,7 @@ 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: @@ -262,9 +240,7 @@ 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 = {} @@ -276,9 +252,7 @@ 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: @@ -302,9 +276,7 @@ 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: @@ -325,9 +297,7 @@ 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: @@ -347,9 +317,7 @@ 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: @@ -366,9 +334,7 @@ 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: @@ -394,9 +360,7 @@ 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: @@ -419,9 +383,7 @@ 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: @@ -443,9 +405,7 @@ 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: @@ -464,9 +424,7 @@ 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: @@ -490,9 +448,7 @@ 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: @@ -513,9 +469,7 @@ 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: @@ -548,9 +502,7 @@ 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: @@ -577,9 +529,7 @@ 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: @@ -601,9 +551,7 @@ 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: @@ -622,9 +570,7 @@ 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: @@ -646,9 +592,7 @@ 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: @@ -667,9 +611,7 @@ 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: @@ -691,9 +633,7 @@ 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: @@ -712,9 +652,7 @@ 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: @@ -736,9 +674,7 @@ 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: @@ -757,9 +693,7 @@ 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: @@ -773,9 +707,7 @@ 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: @@ -789,9 +721,7 @@ 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: @@ -806,9 +736,7 @@ 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: @@ -823,9 +751,7 @@ 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 = {} @@ -837,9 +763,7 @@ 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: @@ -858,9 +782,7 @@ 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: @@ -874,9 +796,7 @@ 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: @@ -892,9 +812,7 @@ 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: @@ -908,9 +826,7 @@ 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: @@ -925,9 +841,7 @@ 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: @@ -943,9 +857,7 @@ 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: @@ -967,9 +879,7 @@ 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: @@ -987,9 +897,7 @@ 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: @@ -1005,3 +913,4 @@ 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 d86e412..8684d0a 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -7,9 +7,7 @@ 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 = {} @@ -21,9 +19,7 @@ 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: @@ -49,9 +45,7 @@ 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: @@ -65,9 +59,7 @@ 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: @@ -93,9 +85,7 @@ 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: @@ -109,9 +99,7 @@ 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: @@ -127,9 +115,7 @@ 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: @@ -148,19 +134,15 @@ 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""" - + def get_file(self, bucket_id, file_id): + """Get file""" api_path = '/storage/buckets/{bucketId}/files/{fileId}' api_params = {} if bucket_id is None: @@ -178,9 +160,7 @@ 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: @@ -200,9 +180,7 @@ 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: @@ -220,9 +198,7 @@ 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: @@ -240,9 +216,7 @@ 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: @@ -271,9 +245,7 @@ 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: @@ -289,3 +261,4 @@ 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 2c387ed..0dd009d 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -7,9 +7,7 @@ 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 = {} @@ -21,9 +19,7 @@ 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: @@ -42,9 +38,7 @@ 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: @@ -58,9 +52,7 @@ 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: @@ -78,9 +70,7 @@ 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: @@ -94,9 +84,7 @@ 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: @@ -112,9 +100,7 @@ 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: @@ -137,9 +123,7 @@ 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: @@ -157,9 +141,7 @@ 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: @@ -181,9 +163,7 @@ 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: @@ -201,9 +181,7 @@ 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: @@ -229,9 +207,7 @@ 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: @@ -245,9 +221,7 @@ 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: @@ -263,3 +237,4 @@ 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 698fbf1..92b266e 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -7,9 +7,7 @@ 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 = {} @@ -21,9 +19,7 @@ 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: @@ -41,9 +37,7 @@ 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: @@ -66,9 +60,7 @@ 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: @@ -91,9 +83,7 @@ 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 = {} @@ -105,9 +95,7 @@ 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: @@ -121,9 +109,7 @@ 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: @@ -146,9 +132,7 @@ 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: @@ -171,9 +155,7 @@ 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: @@ -216,9 +198,7 @@ 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: @@ -253,9 +233,7 @@ 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: @@ -279,9 +257,7 @@ 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: @@ -295,9 +271,7 @@ 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: @@ -311,9 +285,7 @@ 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: @@ -331,9 +303,7 @@ 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: @@ -349,9 +319,7 @@ 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: @@ -369,9 +337,7 @@ 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: @@ -386,9 +352,7 @@ 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: @@ -402,9 +366,7 @@ 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: @@ -422,9 +384,7 @@ 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: @@ -442,9 +402,7 @@ 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: @@ -458,9 +416,7 @@ 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: @@ -474,9 +430,7 @@ 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: @@ -490,9 +444,7 @@ 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: @@ -506,9 +458,7 @@ 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: @@ -526,9 +476,7 @@ 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: @@ -546,9 +494,7 @@ 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: @@ -566,9 +512,7 @@ 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: @@ -582,9 +526,7 @@ 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: @@ -602,9 +544,7 @@ 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: @@ -618,9 +558,7 @@ 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: @@ -634,9 +572,7 @@ 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: @@ -650,9 +586,7 @@ 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: @@ -670,9 +604,7 @@ 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: @@ -690,9 +622,7 @@ 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: @@ -707,9 +637,7 @@ 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: @@ -737,9 +665,7 @@ 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: @@ -757,9 +683,7 @@ 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: @@ -780,9 +704,7 @@ 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: @@ -800,9 +722,7 @@ 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: @@ -818,9 +738,7 @@ 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: @@ -838,9 +756,7 @@ 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: @@ -856,3 +772,4 @@ 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/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index da9b559..9e2b711 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.input_file import InputFile +from appwrite.payload import Payload 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 = InputFile.from_path('file.png'), + code = Payload.from_file('/path/to/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 e1decb9..aa4a2f5 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 = '', # optional + body = Payload.from_json({"x": "y"}), # 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 d275070..2884c26 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.input_file import InputFile +from appwrite.payload import Payload 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 = InputFile.from_path('file.png'), + file = Payload.from_file('/path/to/file.png'), permissions = ["read("any")"] # optional ) diff --git a/setup.py b/setup.py index 8064d17..52160a3 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'appwrite/encoders', 'appwrite/enums', ], - version = '6.1.0', + version = '7.0.0-rc1', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -23,7 +23,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/6.1.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/7.0.0-rc1.tar.gz', install_requires=[ 'requests', ],