diff --git a/appwrite/client.py b/appwrite/client.py index be73fb8..4e04484 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -13,11 +13,11 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : 'AppwritePythonSDK/8.0.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/9.0.0 ({os.uname().sysname}; {os.uname().version}; {os.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '8.0.0', + 'x-sdk-version': '9.0.0', 'X-Appwrite-Response-Format' : '1.6.0', } @@ -131,9 +131,9 @@ def call(self, method, path='', headers=None, params=None, response_type='json') if response != None: content_type = response.headers['Content-Type'] if content_type.startswith('application/json'): - raise AppwriteException(response.json()['message'], response.status_code, response.json().get('type'), response.json()) + raise AppwriteException(response.json()['message'], response.status_code, response.json().get('type'), response.text) else: - raise AppwriteException(response.text, response.status_code) + raise AppwriteException(response.text, response.status_code, None, response.text) else: raise AppwriteException(e) diff --git a/appwrite/enums/credit_card.py b/appwrite/enums/credit_card.py index 097ea64..3f770a3 100644 --- a/appwrite/enums/credit_card.py +++ b/appwrite/enums/credit_card.py @@ -17,3 +17,4 @@ class CreditCard(Enum): VISA = "visa" MIR = "mir" MAESTRO = "maestro" + RUPAY = "rupay" diff --git a/appwrite/enums/name.py b/appwrite/enums/name.py index c5ad74e..0ac227e 100644 --- a/appwrite/enums/name.py +++ b/appwrite/enums/name.py @@ -6,8 +6,9 @@ class Name(Enum): V1_AUDITS = "v1-audits" V1_MAILS = "v1-mails" V1_FUNCTIONS = "v1-functions" - V1_USAGE = "v1-usage" - V1_USAGE_DUMP = "v1-usage-dump" + V1_STATS_RESOURCES = "v1-stats-resources" + V1_STATS_USAGE = "v1-stats-usage" + V1_STATS_USAGE_DUMP = "v1-stats-usage-dump" V1_WEBHOOKS = "v1-webhooks" V1_CERTIFICATES = "v1-certificates" V1_BUILDS = "v1-builds" diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 10255b2..7c248f3 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -1,5 +1,8 @@ from ..service import Service from ..exception import AppwriteException +from ..enums.authenticator_type import AuthenticatorType; +from ..enums.authentication_factor import AuthenticationFactor; +from ..enums.o_auth_provider import OAuthProvider; class Account(Service): @@ -9,7 +12,6 @@ def __init__(self, client): def get(self): """Get account""" - api_path = '/account' api_params = {} @@ -17,10 +19,9 @@ def get(self): 'content-type': 'application/json', }, api_params) - def create(self, user_id, email, password, name = None): + def create(self, user_id: str, email: str, password: str, name: str = None): """Create account""" - api_path = '/account' api_params = {} if user_id is None: @@ -42,10 +43,9 @@ def create(self, user_id, email, password, name = None): 'content-type': 'application/json', }, api_params) - def update_email(self, email, password): + def update_email(self, email: str, password: str): """Update email""" - api_path = '/account/email' api_params = {} if email is None: @@ -62,10 +62,9 @@ def update_email(self, email, password): 'content-type': 'application/json', }, api_params) - def list_identities(self, queries = None): + def list_identities(self, queries: list[str] = None): """List identities""" - api_path = '/account/identities' api_params = {} @@ -75,10 +74,9 @@ def list_identities(self, queries = None): 'content-type': 'application/json', }, api_params) - def delete_identity(self, identity_id): + def delete_identity(self, identity_id: str): """Delete identity""" - api_path = '/account/identities/{identityId}' api_params = {} if identity_id is None: @@ -94,7 +92,6 @@ def delete_identity(self, identity_id): def create_jwt(self): """Create JWT""" - api_path = '/account/jwts' api_params = {} @@ -102,10 +99,9 @@ def create_jwt(self): 'content-type': 'application/json', }, api_params) - def list_logs(self, queries = None): + def list_logs(self, queries: list[str] = None): """List logs""" - api_path = '/account/logs' api_params = {} @@ -115,10 +111,9 @@ def list_logs(self, queries = None): 'content-type': 'application/json', }, api_params) - def update_mfa(self, mfa): + def update_mfa(self, mfa: bool): """Update MFA""" - api_path = '/account/mfa' api_params = {} if mfa is None: @@ -131,10 +126,9 @@ def update_mfa(self, mfa): 'content-type': 'application/json', }, api_params) - def create_mfa_authenticator(self, type): + def create_mfa_authenticator(self, type: AuthenticatorType): """Create authenticator""" - api_path = '/account/mfa/authenticators/{type}' api_params = {} if type is None: @@ -147,10 +141,9 @@ def create_mfa_authenticator(self, type): 'content-type': 'application/json', }, api_params) - def update_mfa_authenticator(self, type, otp): + def update_mfa_authenticator(self, type: AuthenticatorType, otp: str): """Verify authenticator""" - api_path = '/account/mfa/authenticators/{type}' api_params = {} if type is None: @@ -167,10 +160,9 @@ def update_mfa_authenticator(self, type, otp): 'content-type': 'application/json', }, api_params) - def delete_mfa_authenticator(self, type): + def delete_mfa_authenticator(self, type: AuthenticatorType): """Delete authenticator""" - api_path = '/account/mfa/authenticators/{type}' api_params = {} if type is None: @@ -183,10 +175,9 @@ def delete_mfa_authenticator(self, type): 'content-type': 'application/json', }, api_params) - def create_mfa_challenge(self, factor): + def create_mfa_challenge(self, factor: AuthenticationFactor): """Create MFA challenge""" - api_path = '/account/mfa/challenge' api_params = {} if factor is None: @@ -199,10 +190,9 @@ def create_mfa_challenge(self, factor): 'content-type': 'application/json', }, api_params) - def update_mfa_challenge(self, challenge_id, otp): + def update_mfa_challenge(self, challenge_id: str, otp: str): """Create MFA challenge (confirmation)""" - api_path = '/account/mfa/challenge' api_params = {} if challenge_id is None: @@ -222,7 +212,6 @@ def update_mfa_challenge(self, challenge_id, otp): def list_mfa_factors(self): """List factors""" - api_path = '/account/mfa/factors' api_params = {} @@ -233,7 +222,6 @@ def list_mfa_factors(self): def get_mfa_recovery_codes(self): """Get MFA recovery codes""" - api_path = '/account/mfa/recovery-codes' api_params = {} @@ -244,7 +232,6 @@ def get_mfa_recovery_codes(self): def create_mfa_recovery_codes(self): """Create MFA recovery codes""" - api_path = '/account/mfa/recovery-codes' api_params = {} @@ -255,7 +242,6 @@ def create_mfa_recovery_codes(self): def update_mfa_recovery_codes(self): """Regenerate MFA recovery codes""" - api_path = '/account/mfa/recovery-codes' api_params = {} @@ -263,10 +249,9 @@ def update_mfa_recovery_codes(self): 'content-type': 'application/json', }, api_params) - def update_name(self, name): + def update_name(self, name: str): """Update name""" - api_path = '/account/name' api_params = {} if name is None: @@ -279,10 +264,9 @@ def update_name(self, name): 'content-type': 'application/json', }, api_params) - def update_password(self, password, old_password = None): + def update_password(self, password: str, old_password: str = None): """Update password""" - api_path = '/account/password' api_params = {} if password is None: @@ -296,10 +280,9 @@ def update_password(self, password, old_password = None): 'content-type': 'application/json', }, api_params) - def update_phone(self, phone, password): + def update_phone(self, phone: str, password: str): """Update phone""" - api_path = '/account/phone' api_params = {} if phone is None: @@ -319,7 +302,6 @@ def update_phone(self, phone, password): def get_prefs(self): """Get account preferences""" - api_path = '/account/prefs' api_params = {} @@ -327,10 +309,9 @@ def get_prefs(self): 'content-type': 'application/json', }, api_params) - def update_prefs(self, prefs): + def update_prefs(self, prefs: dict): """Update preferences""" - api_path = '/account/prefs' api_params = {} if prefs is None: @@ -343,10 +324,9 @@ def update_prefs(self, prefs): 'content-type': 'application/json', }, api_params) - def create_recovery(self, email, url): + def create_recovery(self, email: str, url: str): """Create password recovery""" - api_path = '/account/recovery' api_params = {} if email is None: @@ -363,10 +343,9 @@ def create_recovery(self, email, url): 'content-type': 'application/json', }, api_params) - def update_recovery(self, user_id, secret, password): + def update_recovery(self, user_id: str, secret: str, password: str): """Create password recovery (confirmation)""" - api_path = '/account/recovery' api_params = {} if user_id is None: @@ -390,7 +369,6 @@ def update_recovery(self, user_id, secret, password): def list_sessions(self): """List sessions""" - api_path = '/account/sessions' api_params = {} @@ -401,7 +379,6 @@ def list_sessions(self): def delete_sessions(self): """Delete sessions""" - api_path = '/account/sessions' api_params = {} @@ -412,7 +389,6 @@ def delete_sessions(self): def create_anonymous_session(self): """Create anonymous session""" - api_path = '/account/sessions/anonymous' api_params = {} @@ -420,10 +396,9 @@ def create_anonymous_session(self): 'content-type': 'application/json', }, api_params) - def create_email_password_session(self, email, password): + def create_email_password_session(self, email: str, password: str): """Create email password session""" - api_path = '/account/sessions/email' api_params = {} if email is None: @@ -440,10 +415,9 @@ def create_email_password_session(self, email, password): 'content-type': 'application/json', }, api_params) - def update_magic_url_session(self, user_id, secret): + def update_magic_url_session(self, user_id: str, secret: str): """Update magic URL session""" - api_path = '/account/sessions/magic-url' api_params = {} if user_id is None: @@ -460,10 +434,9 @@ def update_magic_url_session(self, user_id, secret): 'content-type': 'application/json', }, api_params) - def update_phone_session(self, user_id, secret): + def update_phone_session(self, user_id: str, secret: str): """Update phone session""" - api_path = '/account/sessions/phone' api_params = {} if user_id is None: @@ -480,10 +453,9 @@ def update_phone_session(self, user_id, secret): 'content-type': 'application/json', }, api_params) - def create_session(self, user_id, secret): + def create_session(self, user_id: str, secret: str): """Create session""" - api_path = '/account/sessions/token' api_params = {} if user_id is None: @@ -500,10 +472,9 @@ def create_session(self, user_id, secret): 'content-type': 'application/json', }, api_params) - def get_session(self, session_id): + def get_session(self, session_id: str): """Get session""" - api_path = '/account/sessions/{sessionId}' api_params = {} if session_id is None: @@ -516,10 +487,9 @@ def get_session(self, session_id): 'content-type': 'application/json', }, api_params) - def update_session(self, session_id): + def update_session(self, session_id: str): """Update session""" - api_path = '/account/sessions/{sessionId}' api_params = {} if session_id is None: @@ -532,10 +502,9 @@ def update_session(self, session_id): 'content-type': 'application/json', }, api_params) - def delete_session(self, session_id): + def delete_session(self, session_id: str): """Delete session""" - api_path = '/account/sessions/{sessionId}' api_params = {} if session_id is None: @@ -551,7 +520,6 @@ def delete_session(self, session_id): def update_status(self): """Update status""" - api_path = '/account/status' api_params = {} @@ -559,10 +527,9 @@ def update_status(self): 'content-type': 'application/json', }, api_params) - def create_email_token(self, user_id, email, phrase = None): + def create_email_token(self, user_id: str, email: str, phrase: bool = None): """Create email token (OTP)""" - api_path = '/account/tokens/email' api_params = {} if user_id is None: @@ -580,10 +547,9 @@ def create_email_token(self, user_id, email, phrase = None): 'content-type': 'application/json', }, api_params) - def create_magic_url_token(self, user_id, email, url = None, phrase = None): + def create_magic_url_token(self, user_id: str, email: str, url: str = None, phrase: bool = None): """Create magic URL token""" - api_path = '/account/tokens/magic-url' api_params = {} if user_id is None: @@ -602,10 +568,9 @@ def create_magic_url_token(self, user_id, email, url = None, phrase = None): 'content-type': 'application/json', }, api_params) - def create_o_auth2_token(self, provider, success = None, failure = None, scopes = None): + def create_o_auth2_token(self, provider: OAuthProvider, success: str = None, failure: str = None, scopes: list[str] = None): """Create OAuth2 token""" - api_path = '/account/tokens/oauth2/{provider}' api_params = {} if provider is None: @@ -621,10 +586,9 @@ def create_o_auth2_token(self, provider, success = None, failure = None, scopes 'content-type': 'application/json', }, api_params, response_type='location') - def create_phone_token(self, user_id, phone): + def create_phone_token(self, user_id: str, phone: str): """Create phone token""" - api_path = '/account/tokens/phone' api_params = {} if user_id is None: @@ -641,10 +605,9 @@ def create_phone_token(self, user_id, phone): 'content-type': 'application/json', }, api_params) - def create_verification(self, url): + def create_verification(self, url: str): """Create email verification""" - api_path = '/account/verification' api_params = {} if url is None: @@ -657,10 +620,9 @@ def create_verification(self, url): 'content-type': 'application/json', }, api_params) - def update_verification(self, user_id, secret): + def update_verification(self, user_id: str, secret: str): """Create email verification (confirmation)""" - api_path = '/account/verification' api_params = {} if user_id is None: @@ -680,7 +642,6 @@ def update_verification(self, user_id, secret): def create_phone_verification(self): """Create phone verification""" - api_path = '/account/verification/phone' api_params = {} @@ -688,10 +649,9 @@ def create_phone_verification(self): 'content-type': 'application/json', }, api_params) - def update_phone_verification(self, user_id, secret): + def update_phone_verification(self, user_id: str, secret: str): """Update phone verification (confirmation)""" - api_path = '/account/verification/phone' api_params = {} if user_id is None: diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index 0a9b400..40a0abb 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -1,15 +1,17 @@ from ..service import Service from ..exception import AppwriteException +from ..enums.browser import Browser; +from ..enums.credit_card import CreditCard; +from ..enums.flag import Flag; class Avatars(Service): def __init__(self, client): super(Avatars, self).__init__(client) - def get_browser(self, code, width = None, height = None, quality = None): + def get_browser(self, code: Browser, width: float = None, height: float = None, quality: float = None): """Get browser icon""" - api_path = '/avatars/browsers/{code}' api_params = {} if code is None: @@ -25,10 +27,9 @@ def get_browser(self, code, width = None, height = None, quality = None): 'content-type': 'application/json', }, api_params) - def get_credit_card(self, code, width = None, height = None, quality = None): + def get_credit_card(self, code: CreditCard, width: float = None, height: float = None, quality: float = None): """Get credit card icon""" - api_path = '/avatars/credit-cards/{code}' api_params = {} if code is None: @@ -44,10 +45,9 @@ def get_credit_card(self, code, width = None, height = None, quality = None): 'content-type': 'application/json', }, api_params) - def get_favicon(self, url): + def get_favicon(self, url: str): """Get favicon""" - api_path = '/avatars/favicon' api_params = {} if url is None: @@ -60,10 +60,9 @@ def get_favicon(self, url): 'content-type': 'application/json', }, api_params) - def get_flag(self, code, width = None, height = None, quality = None): + def get_flag(self, code: Flag, width: float = None, height: float = None, quality: float = None): """Get country flag""" - api_path = '/avatars/flags/{code}' api_params = {} if code is None: @@ -79,10 +78,9 @@ def get_flag(self, code, width = None, height = None, quality = None): 'content-type': 'application/json', }, api_params) - def get_image(self, url, width = None, height = None): + def get_image(self, url: str, width: float = None, height: float = None): """Get image from URL""" - api_path = '/avatars/image' api_params = {} if url is None: @@ -97,10 +95,9 @@ def get_image(self, url, width = None, height = None): 'content-type': 'application/json', }, api_params) - def get_initials(self, name = None, width = None, height = None, background = None): + def get_initials(self, name: str = None, width: float = None, height: float = None, background: str = None): """Get user initials""" - api_path = '/avatars/initials' api_params = {} @@ -113,10 +110,9 @@ def get_initials(self, name = None, width = None, height = None, background = No 'content-type': 'application/json', }, api_params) - def get_qr(self, text, size = None, margin = None, download = None): + def get_qr(self, text: str, size: float = None, margin: float = None, download: bool = None): """Get QR code""" - api_path = '/avatars/qr' api_params = {} if text is None: diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index aa47e4e..e1c63b2 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -1,15 +1,17 @@ from ..service import Service from ..exception import AppwriteException +from ..enums.relationship_type import RelationshipType; +from ..enums.relation_mutate import RelationMutate; +from ..enums.index_type import IndexType; class Databases(Service): def __init__(self, client): super(Databases, self).__init__(client) - def list(self, queries = None, search = None): + def list(self, queries: list[str] = None, search: str = None): """List databases""" - api_path = '/databases' api_params = {} @@ -20,10 +22,9 @@ def list(self, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create(self, database_id, name, enabled = None): + def create(self, database_id: str, name: str, enabled: bool = None): """Create database""" - api_path = '/databases' api_params = {} if database_id is None: @@ -41,10 +42,9 @@ def create(self, database_id, name, enabled = None): 'content-type': 'application/json', }, api_params) - def get(self, database_id): + def get(self, database_id: str): """Get database""" - api_path = '/databases/{databaseId}' api_params = {} if database_id is None: @@ -57,10 +57,9 @@ def get(self, database_id): 'content-type': 'application/json', }, api_params) - def update(self, database_id, name, enabled = None): + def update(self, database_id: str, name: str, enabled: bool = None): """Update database""" - api_path = '/databases/{databaseId}' api_params = {} if database_id is None: @@ -78,10 +77,9 @@ def update(self, database_id, name, enabled = None): 'content-type': 'application/json', }, api_params) - def delete(self, database_id): + def delete(self, database_id: str): """Delete database""" - api_path = '/databases/{databaseId}' api_params = {} if database_id is None: @@ -94,10 +92,9 @@ def delete(self, database_id): 'content-type': 'application/json', }, api_params) - def list_collections(self, database_id, queries = None, search = None): + def list_collections(self, database_id: str, queries: list[str] = None, search: str = None): """List collections""" - api_path = '/databases/{databaseId}/collections' api_params = {} if database_id is None: @@ -112,10 +109,9 @@ def list_collections(self, database_id, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create_collection(self, database_id, collection_id, name, permissions = None, document_security = None, enabled = None): + def create_collection(self, database_id: str, collection_id: str, name: str, permissions: list[str] = None, document_security: bool = None, enabled: bool = None): """Create collection""" - api_path = '/databases/{databaseId}/collections' api_params = {} if database_id is None: @@ -139,10 +135,9 @@ def create_collection(self, database_id, collection_id, name, permissions = None 'content-type': 'application/json', }, api_params) - def get_collection(self, database_id, collection_id): + def get_collection(self, database_id: str, collection_id: str): """Get collection""" - api_path = '/databases/{databaseId}/collections/{collectionId}' api_params = {} if database_id is None: @@ -159,10 +154,9 @@ def get_collection(self, database_id, collection_id): 'content-type': 'application/json', }, api_params) - def update_collection(self, database_id, collection_id, name, permissions = None, document_security = None, enabled = None): + def update_collection(self, database_id: str, collection_id: str, name: str, permissions: list[str] = None, document_security: bool = None, enabled: bool = None): """Update collection""" - api_path = '/databases/{databaseId}/collections/{collectionId}' api_params = {} if database_id is None: @@ -186,10 +180,9 @@ def update_collection(self, database_id, collection_id, name, permissions = None 'content-type': 'application/json', }, api_params) - def delete_collection(self, database_id, collection_id): + def delete_collection(self, database_id: str, collection_id: str): """Delete collection""" - api_path = '/databases/{databaseId}/collections/{collectionId}' api_params = {} if database_id is None: @@ -206,10 +199,9 @@ def delete_collection(self, database_id, collection_id): 'content-type': 'application/json', }, api_params) - def list_attributes(self, database_id, collection_id, queries = None): + def list_attributes(self, database_id: str, collection_id: str, queries: list[str] = None): """List attributes""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' api_params = {} if database_id is None: @@ -227,10 +219,9 @@ def list_attributes(self, database_id, collection_id, queries = None): 'content-type': 'application/json', }, api_params) - def create_boolean_attribute(self, database_id, collection_id, key, required, default = None, array = None): + def create_boolean_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: bool = None, array: bool = None): """Create boolean attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' api_params = {} if database_id is None: @@ -257,10 +248,9 @@ def create_boolean_attribute(self, database_id, collection_id, key, required, de 'content-type': 'application/json', }, api_params) - def update_boolean_attribute(self, database_id, collection_id, key, required, default, new_key = None): + def update_boolean_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: bool, new_key: str = None): """Update boolean attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' api_params = {} if database_id is None: @@ -287,10 +277,9 @@ def update_boolean_attribute(self, database_id, collection_id, key, required, de 'content-type': 'application/json', }, api_params) - def create_datetime_attribute(self, database_id, collection_id, key, required, default = None, array = None): + def create_datetime_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, array: bool = None): """Create datetime attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' api_params = {} if database_id is None: @@ -317,10 +306,9 @@ def create_datetime_attribute(self, database_id, collection_id, key, required, d 'content-type': 'application/json', }, api_params) - def update_datetime_attribute(self, database_id, collection_id, key, required, default, new_key = None): + def update_datetime_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, new_key: str = None): """Update dateTime attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' api_params = {} if database_id is None: @@ -347,10 +335,9 @@ def update_datetime_attribute(self, database_id, collection_id, key, required, d 'content-type': 'application/json', }, api_params) - def create_email_attribute(self, database_id, collection_id, key, required, default = None, array = None): + def create_email_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, array: bool = None): """Create email attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' api_params = {} if database_id is None: @@ -377,10 +364,9 @@ def create_email_attribute(self, database_id, collection_id, key, required, defa 'content-type': 'application/json', }, api_params) - def update_email_attribute(self, database_id, collection_id, key, required, default, new_key = None): + def update_email_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, new_key: str = None): """Update email attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' api_params = {} if database_id is None: @@ -407,10 +393,9 @@ def update_email_attribute(self, database_id, collection_id, key, required, defa 'content-type': 'application/json', }, api_params) - def create_enum_attribute(self, database_id, collection_id, key, elements, required, default = None, array = None): + def create_enum_attribute(self, database_id: str, collection_id: str, key: str, elements: list[str], required: bool, default: str = None, array: bool = None): """Create enum attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' api_params = {} if database_id is None: @@ -441,10 +426,9 @@ def create_enum_attribute(self, database_id, collection_id, key, elements, requi 'content-type': 'application/json', }, api_params) - def update_enum_attribute(self, database_id, collection_id, key, elements, required, default, new_key = None): + def update_enum_attribute(self, database_id: str, collection_id: str, key: str, elements: list[str], required: bool, default: str, new_key: str = None): """Update enum attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' api_params = {} if database_id is None: @@ -475,10 +459,9 @@ def update_enum_attribute(self, database_id, collection_id, key, elements, requi 'content-type': 'application/json', }, api_params) - def create_float_attribute(self, database_id, collection_id, key, required, min = None, max = None, default = None, array = None): + def create_float_attribute(self, database_id: str, collection_id: str, key: str, required: bool, min: float = None, max: float = None, default: float = None, array: bool = None): """Create float attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' api_params = {} if database_id is None: @@ -507,10 +490,9 @@ def create_float_attribute(self, database_id, collection_id, key, required, min 'content-type': 'application/json', }, api_params) - def update_float_attribute(self, database_id, collection_id, key, required, min, max, default, new_key = None): + def update_float_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: float, min: float = None, max: float = None, new_key: str = None): """Update float attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' api_params = {} if database_id is None: @@ -525,12 +507,6 @@ def update_float_attribute(self, database_id, collection_id, key, required, min, if required is None: raise AppwriteException('Missing required parameter: "required"') - if min is None: - raise AppwriteException('Missing required parameter: "min"') - - if max is None: - raise AppwriteException('Missing required parameter: "max"') - api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) api_path = api_path.replace('{key}', key) @@ -545,10 +521,9 @@ def update_float_attribute(self, database_id, collection_id, key, required, min, 'content-type': 'application/json', }, api_params) - def create_integer_attribute(self, database_id, collection_id, key, required, min = None, max = None, default = None, array = None): + def create_integer_attribute(self, database_id: str, collection_id: str, key: str, required: bool, min: float = None, max: float = None, default: float = None, array: bool = None): """Create integer attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' api_params = {} if database_id is None: @@ -577,10 +552,9 @@ def create_integer_attribute(self, database_id, collection_id, key, required, mi 'content-type': 'application/json', }, api_params) - def update_integer_attribute(self, database_id, collection_id, key, required, min, max, default, new_key = None): + def update_integer_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: float, min: float = None, max: float = None, new_key: str = None): """Update integer attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' api_params = {} if database_id is None: @@ -595,12 +569,6 @@ def update_integer_attribute(self, database_id, collection_id, key, required, mi if required is None: raise AppwriteException('Missing required parameter: "required"') - if min is None: - raise AppwriteException('Missing required parameter: "min"') - - if max is None: - raise AppwriteException('Missing required parameter: "max"') - api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) api_path = api_path.replace('{key}', key) @@ -615,10 +583,9 @@ def update_integer_attribute(self, database_id, collection_id, key, required, mi 'content-type': 'application/json', }, api_params) - def create_ip_attribute(self, database_id, collection_id, key, required, default = None, array = None): + def create_ip_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, array: bool = None): """Create IP address attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' api_params = {} if database_id is None: @@ -645,10 +612,9 @@ def create_ip_attribute(self, database_id, collection_id, key, required, default 'content-type': 'application/json', }, api_params) - def update_ip_attribute(self, database_id, collection_id, key, required, default, new_key = None): + def update_ip_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, new_key: str = None): """Update IP address attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' api_params = {} if database_id is None: @@ -675,10 +641,9 @@ def update_ip_attribute(self, database_id, collection_id, key, required, default 'content-type': 'application/json', }, api_params) - def create_relationship_attribute(self, database_id, collection_id, related_collection_id, type, two_way = None, key = None, two_way_key = None, on_delete = None): + def create_relationship_attribute(self, database_id: str, collection_id: str, related_collection_id: str, type: RelationshipType, two_way: bool = None, key: str = None, two_way_key: str = None, on_delete: RelationMutate = None): """Create relationship attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' api_params = {} if database_id is None: @@ -707,10 +672,9 @@ def create_relationship_attribute(self, database_id, collection_id, related_coll 'content-type': 'application/json', }, api_params) - def create_string_attribute(self, database_id, collection_id, key, size, required, default = None, array = None, encrypt = None): + def create_string_attribute(self, database_id: str, collection_id: str, key: str, size: float, required: bool, default: str = None, array: bool = None, encrypt: bool = None): """Create string attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' api_params = {} if database_id is None: @@ -742,10 +706,9 @@ def create_string_attribute(self, database_id, collection_id, key, size, require 'content-type': 'application/json', }, api_params) - def update_string_attribute(self, database_id, collection_id, key, required, default, size = None, new_key = None): + def update_string_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, size: float = None, new_key: str = None): """Update string attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' api_params = {} if database_id is None: @@ -773,10 +736,9 @@ def update_string_attribute(self, database_id, collection_id, key, required, def 'content-type': 'application/json', }, api_params) - def create_url_attribute(self, database_id, collection_id, key, required, default = None, array = None): + def create_url_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, array: bool = None): """Create URL attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' api_params = {} if database_id is None: @@ -803,10 +765,9 @@ def create_url_attribute(self, database_id, collection_id, key, required, defaul 'content-type': 'application/json', }, api_params) - def update_url_attribute(self, database_id, collection_id, key, required, default, new_key = None): + def update_url_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str, new_key: str = None): """Update URL attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' api_params = {} if database_id is None: @@ -833,10 +794,9 @@ def update_url_attribute(self, database_id, collection_id, key, required, defaul 'content-type': 'application/json', }, api_params) - def get_attribute(self, database_id, collection_id, key): + def get_attribute(self, database_id: str, collection_id: str, key: str): """Get attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' api_params = {} if database_id is None: @@ -857,10 +817,9 @@ def get_attribute(self, database_id, collection_id, key): 'content-type': 'application/json', }, api_params) - def delete_attribute(self, database_id, collection_id, key): + def delete_attribute(self, database_id: str, collection_id: str, key: str): """Delete attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' api_params = {} if database_id is None: @@ -881,10 +840,9 @@ def delete_attribute(self, database_id, collection_id, key): 'content-type': 'application/json', }, api_params) - def update_relationship_attribute(self, database_id, collection_id, key, on_delete = None, new_key = None): + def update_relationship_attribute(self, database_id: str, collection_id: str, key: str, on_delete: RelationMutate = None, new_key: str = None): """Update relationship attribute""" - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship' api_params = {} if database_id is None: @@ -907,10 +865,9 @@ def update_relationship_attribute(self, database_id, collection_id, key, on_dele 'content-type': 'application/json', }, api_params) - def list_documents(self, database_id, collection_id, queries = None): + def list_documents(self, database_id: str, collection_id: str, queries: list[str] = None): """List documents""" - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' api_params = {} if database_id is None: @@ -928,10 +885,9 @@ def list_documents(self, database_id, collection_id, queries = None): 'content-type': 'application/json', }, api_params) - def create_document(self, database_id, collection_id, document_id, data, permissions = None): + def create_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: list[str] = None): """Create document""" - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' api_params = {} if database_id is None: @@ -957,10 +913,9 @@ def create_document(self, database_id, collection_id, document_id, data, permiss 'content-type': 'application/json', }, api_params) - def get_document(self, database_id, collection_id, document_id, queries = None): + def get_document(self, database_id: str, collection_id: str, document_id: str, queries: list[str] = None): """Get document""" - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' api_params = {} if database_id is None: @@ -982,10 +937,9 @@ def get_document(self, database_id, collection_id, document_id, queries = None): 'content-type': 'application/json', }, api_params) - def update_document(self, database_id, collection_id, document_id, data = None, permissions = None): + def update_document(self, database_id: str, collection_id: str, document_id: str, data: dict = None, permissions: list[str] = None): """Update document""" - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' api_params = {} if database_id is None: @@ -1008,10 +962,9 @@ def update_document(self, database_id, collection_id, document_id, data = None, 'content-type': 'application/json', }, api_params) - def delete_document(self, database_id, collection_id, document_id): + def delete_document(self, database_id: str, collection_id: str, document_id: str): """Delete document""" - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' api_params = {} if database_id is None: @@ -1032,10 +985,9 @@ def delete_document(self, database_id, collection_id, document_id): 'content-type': 'application/json', }, api_params) - def list_indexes(self, database_id, collection_id, queries = None): + def list_indexes(self, database_id: str, collection_id: str, queries: list[str] = None): """List indexes""" - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' api_params = {} if database_id is None: @@ -1053,10 +1005,9 @@ def list_indexes(self, database_id, collection_id, queries = None): 'content-type': 'application/json', }, api_params) - def create_index(self, database_id, collection_id, key, type, attributes, orders = None): + def create_index(self, database_id: str, collection_id: str, key: str, type: IndexType, attributes: list[str], orders: list[str] = None): """Create index""" - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' api_params = {} if database_id is None: @@ -1086,10 +1037,9 @@ def create_index(self, database_id, collection_id, key, type, attributes, orders 'content-type': 'application/json', }, api_params) - def get_index(self, database_id, collection_id, key): + def get_index(self, database_id: str, collection_id: str, key: str): """Get index""" - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' api_params = {} if database_id is None: @@ -1110,10 +1060,9 @@ def get_index(self, database_id, collection_id, key): 'content-type': 'application/json', }, api_params) - def delete_index(self, database_id, collection_id, key): + def delete_index(self, database_id: str, collection_id: str, key: str): """Delete index""" - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' api_params = {} if database_id is None: diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index 34b13a9..6eb8bad 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -1,15 +1,17 @@ from ..service import Service from ..exception import AppwriteException +from ..enums.runtime import Runtime; +from ..input_file import InputFile +from ..enums.execution_method import ExecutionMethod; class Functions(Service): def __init__(self, client): super(Functions, self).__init__(client) - def list(self, queries = None, search = None): + def list(self, queries: list[str] = None, search: str = None): """List functions""" - api_path = '/functions' api_params = {} @@ -20,10 +22,9 @@ def list(self, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create(self, function_id, name, runtime, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, 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): + def create(self, function_id: str, name: str, runtime: Runtime, execute: list[str] = None, events: list[str] = None, schedule: str = None, timeout: float = None, enabled: bool = None, logging: bool = None, entrypoint: str = None, commands: str = None, scopes: list[str] = None, installation_id: str = None, provider_repository_id: str = None, provider_branch: str = None, provider_silent_mode: bool = None, provider_root_directory: str = None, template_repository: str = None, template_owner: str = None, template_root_directory: str = None, template_version: str = None, specification: str = None): """Create function""" - api_path = '/functions' api_params = {} if function_id is None: @@ -66,7 +67,6 @@ def create(self, function_id, name, runtime, execute = None, events = None, sche def list_runtimes(self): """List runtimes""" - api_path = '/functions/runtimes' api_params = {} @@ -77,7 +77,6 @@ def list_runtimes(self): def list_specifications(self): """List available function runtime specifications""" - api_path = '/functions/specifications' api_params = {} @@ -85,10 +84,9 @@ def list_specifications(self): 'content-type': 'application/json', }, api_params) - def get(self, function_id): + def get(self, function_id: str): """Get function""" - api_path = '/functions/{functionId}' api_params = {} if function_id is None: @@ -101,10 +99,9 @@ def get(self, function_id): 'content-type': 'application/json', }, api_params) - def update(self, function_id, name, runtime = None, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, scopes = None, installation_id = None, provider_repository_id = None, provider_branch = None, provider_silent_mode = None, provider_root_directory = None, specification = None): + def update(self, function_id: str, name: str, runtime: Runtime = None, execute: list[str] = None, events: list[str] = None, schedule: str = None, timeout: float = None, enabled: bool = None, logging: bool = None, entrypoint: str = None, commands: str = None, scopes: list[str] = None, installation_id: str = None, provider_repository_id: str = None, provider_branch: str = None, provider_silent_mode: bool = None, provider_root_directory: str = None, specification: str = None): """Update function""" - api_path = '/functions/{functionId}' api_params = {} if function_id is None: @@ -137,10 +134,9 @@ def update(self, function_id, name, runtime = None, execute = None, events = Non 'content-type': 'application/json', }, api_params) - def delete(self, function_id): + def delete(self, function_id: str): """Delete function""" - api_path = '/functions/{functionId}' api_params = {} if function_id is None: @@ -153,10 +149,9 @@ def delete(self, function_id): 'content-type': 'application/json', }, api_params) - def list_deployments(self, function_id, queries = None, search = None): + def list_deployments(self, function_id: str, queries: list[str] = None, search: str = None): """List deployments""" - api_path = '/functions/{functionId}/deployments' api_params = {} if function_id is None: @@ -171,10 +166,9 @@ def list_deployments(self, function_id, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create_deployment(self, function_id, code, activate, entrypoint = None, commands = None, on_progress = None): + def create_deployment(self, function_id: str, code: InputFile, activate: bool, entrypoint: str = None, commands: str = None, on_progress = None): """Create deployment""" - api_path = '/functions/{functionId}/deployments' api_params = {} if function_id is None: @@ -202,10 +196,9 @@ def create_deployment(self, function_id, code, activate, entrypoint = None, comm 'content-type': 'multipart/form-data', }, api_params, param_name, on_progress, upload_id) - def get_deployment(self, function_id, deployment_id): + def get_deployment(self, function_id: str, deployment_id: str): """Get deployment""" - api_path = '/functions/{functionId}/deployments/{deploymentId}' api_params = {} if function_id is None: @@ -222,10 +215,9 @@ def get_deployment(self, function_id, deployment_id): 'content-type': 'application/json', }, api_params) - def update_deployment(self, function_id, deployment_id): + def update_deployment(self, function_id: str, deployment_id: str): """Update deployment""" - api_path = '/functions/{functionId}/deployments/{deploymentId}' api_params = {} if function_id is None: @@ -242,10 +234,9 @@ def update_deployment(self, function_id, deployment_id): 'content-type': 'application/json', }, api_params) - def delete_deployment(self, function_id, deployment_id): + def delete_deployment(self, function_id: str, deployment_id: str): """Delete deployment""" - api_path = '/functions/{functionId}/deployments/{deploymentId}' api_params = {} if function_id is None: @@ -262,10 +253,9 @@ def delete_deployment(self, function_id, deployment_id): 'content-type': 'application/json', }, api_params) - def create_build(self, function_id, deployment_id, build_id = None): + def create_build(self, function_id: str, deployment_id: str, build_id: str = None): """Rebuild deployment""" - api_path = '/functions/{functionId}/deployments/{deploymentId}/build' api_params = {} if function_id is None: @@ -283,10 +273,9 @@ def create_build(self, function_id, deployment_id, build_id = None): 'content-type': 'application/json', }, api_params) - def update_deployment_build(self, function_id, deployment_id): + def update_deployment_build(self, function_id: str, deployment_id: str): """Cancel deployment""" - api_path = '/functions/{functionId}/deployments/{deploymentId}/build' api_params = {} if function_id is None: @@ -303,10 +292,9 @@ def update_deployment_build(self, function_id, deployment_id): 'content-type': 'application/json', }, api_params) - def get_deployment_download(self, function_id, deployment_id): + def get_deployment_download(self, function_id: str, deployment_id: str): """Download deployment""" - api_path = '/functions/{functionId}/deployments/{deploymentId}/download' api_params = {} if function_id is None: @@ -323,10 +311,9 @@ def get_deployment_download(self, function_id, deployment_id): 'content-type': 'application/json', }, api_params) - def list_executions(self, function_id, queries = None, search = None): + def list_executions(self, function_id: str, queries: list[str] = None, search: str = None): """List executions""" - api_path = '/functions/{functionId}/executions' api_params = {} if function_id is None: @@ -341,10 +328,9 @@ 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): + def create_execution(self, function_id: str, body: str = None, xasync: bool = None, path: str = None, method: ExecutionMethod = None, headers: dict = None, scheduled_at: str = None): """Create execution""" - api_path = '/functions/{functionId}/executions' api_params = {} if function_id is None: @@ -363,10 +349,9 @@ def create_execution(self, function_id, body = None, xasync = None, path = None, 'content-type': 'application/json', }, api_params) - def get_execution(self, function_id, execution_id): + def get_execution(self, function_id: str, execution_id: str): """Get execution""" - api_path = '/functions/{functionId}/executions/{executionId}' api_params = {} if function_id is None: @@ -383,10 +368,9 @@ def get_execution(self, function_id, execution_id): 'content-type': 'application/json', }, api_params) - def delete_execution(self, function_id, execution_id): + def delete_execution(self, function_id: str, execution_id: str): """Delete execution""" - api_path = '/functions/{functionId}/executions/{executionId}' api_params = {} if function_id is None: @@ -403,10 +387,9 @@ def delete_execution(self, function_id, execution_id): 'content-type': 'application/json', }, api_params) - def list_variables(self, function_id): + def list_variables(self, function_id: str): """List variables""" - api_path = '/functions/{functionId}/variables' api_params = {} if function_id is None: @@ -419,10 +402,9 @@ def list_variables(self, function_id): 'content-type': 'application/json', }, api_params) - def create_variable(self, function_id, key, value): + def create_variable(self, function_id: str, key: str, value: str): """Create variable""" - api_path = '/functions/{functionId}/variables' api_params = {} if function_id is None: @@ -443,10 +425,9 @@ def create_variable(self, function_id, key, value): 'content-type': 'application/json', }, api_params) - def get_variable(self, function_id, variable_id): + def get_variable(self, function_id: str, variable_id: str): """Get variable""" - api_path = '/functions/{functionId}/variables/{variableId}' api_params = {} if function_id is None: @@ -463,10 +444,9 @@ def get_variable(self, function_id, variable_id): 'content-type': 'application/json', }, api_params) - def update_variable(self, function_id, variable_id, key, value = None): + def update_variable(self, function_id: str, variable_id: str, key: str, value: str = None): """Update variable""" - api_path = '/functions/{functionId}/variables/{variableId}' api_params = {} if function_id is None: @@ -488,10 +468,9 @@ def update_variable(self, function_id, variable_id, key, value = None): 'content-type': 'application/json', }, api_params) - def delete_variable(self, function_id, variable_id): + def delete_variable(self, function_id: str, variable_id: str): """Delete variable""" - api_path = '/functions/{functionId}/variables/{variableId}' api_params = {} if function_id is None: diff --git a/appwrite/services/graphql.py b/appwrite/services/graphql.py index 58a6e99..41421bb 100644 --- a/appwrite/services/graphql.py +++ b/appwrite/services/graphql.py @@ -6,10 +6,9 @@ class Graphql(Service): def __init__(self, client): super(Graphql, self).__init__(client) - def query(self, query): + def query(self, query: dict): """GraphQL endpoint""" - api_path = '/graphql' api_params = {} if query is None: @@ -23,10 +22,9 @@ def query(self, query): 'content-type': 'application/json', }, api_params) - def mutation(self, query): + def mutation(self, query: dict): """GraphQL endpoint""" - api_path = '/graphql/mutation' api_params = {} if query is None: diff --git a/appwrite/services/health.py b/appwrite/services/health.py index ef4b3cd..d87dc57 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -1,5 +1,6 @@ from ..service import Service from ..exception import AppwriteException +from ..enums.name import Name; class Health(Service): @@ -9,7 +10,6 @@ def __init__(self, client): def get(self): """Get HTTP""" - api_path = '/health' api_params = {} @@ -20,7 +20,6 @@ def get(self): def get_antivirus(self): """Get antivirus""" - api_path = '/health/anti-virus' api_params = {} @@ -31,7 +30,6 @@ def get_antivirus(self): def get_cache(self): """Get cache""" - api_path = '/health/cache' api_params = {} @@ -39,10 +37,9 @@ def get_cache(self): 'content-type': 'application/json', }, api_params) - def get_certificate(self, domain = None): + def get_certificate(self, domain: str = None): """Get the SSL certificate for a domain""" - api_path = '/health/certificate' api_params = {} @@ -55,7 +52,6 @@ def get_certificate(self, domain = None): def get_db(self): """Get DB""" - api_path = '/health/db' api_params = {} @@ -66,7 +62,6 @@ def get_db(self): def get_pub_sub(self): """Get pubsub""" - api_path = '/health/pubsub' api_params = {} @@ -74,21 +69,9 @@ def get_pub_sub(self): 'content-type': 'application/json', }, api_params) - def get_queue(self): - """Get queue""" - - - api_path = '/health/queue' - api_params = {} - - return self.client.call('get', api_path, { - 'content-type': 'application/json', - }, api_params) - - def get_queue_builds(self, threshold = None): + def get_queue_builds(self, threshold: float = None): """Get builds queue""" - api_path = '/health/queue/builds' api_params = {} @@ -98,10 +81,9 @@ def get_queue_builds(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_certificates(self, threshold = None): + def get_queue_certificates(self, threshold: float = None): """Get certificates queue""" - api_path = '/health/queue/certificates' api_params = {} @@ -111,10 +93,9 @@ def get_queue_certificates(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_databases(self, name = None, threshold = None): + def get_queue_databases(self, name: str = None, threshold: float = None): """Get databases queue""" - api_path = '/health/queue/databases' api_params = {} @@ -125,10 +106,9 @@ def get_queue_databases(self, name = None, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_deletes(self, threshold = None): + def get_queue_deletes(self, threshold: float = None): """Get deletes queue""" - api_path = '/health/queue/deletes' api_params = {} @@ -138,10 +118,9 @@ def get_queue_deletes(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_failed_jobs(self, name, threshold = None): + def get_failed_jobs(self, name: Name, threshold: float = None): """Get number of failed queue jobs""" - api_path = '/health/queue/failed/{name}' api_params = {} if name is None: @@ -155,10 +134,9 @@ def get_failed_jobs(self, name, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_functions(self, threshold = None): + def get_queue_functions(self, threshold: float = None): """Get functions queue""" - api_path = '/health/queue/functions' api_params = {} @@ -168,10 +146,9 @@ def get_queue_functions(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_logs(self, threshold = None): + def get_queue_logs(self, threshold: float = None): """Get logs queue""" - api_path = '/health/queue/logs' api_params = {} @@ -181,10 +158,9 @@ def get_queue_logs(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_mails(self, threshold = None): + def get_queue_mails(self, threshold: float = None): """Get mails queue""" - api_path = '/health/queue/mails' api_params = {} @@ -194,10 +170,9 @@ def get_queue_mails(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_messaging(self, threshold = None): + def get_queue_messaging(self, threshold: float = None): """Get messaging queue""" - api_path = '/health/queue/messaging' api_params = {} @@ -207,10 +182,9 @@ def get_queue_messaging(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_migrations(self, threshold = None): + def get_queue_migrations(self, threshold: float = None): """Get migrations queue""" - api_path = '/health/queue/migrations' api_params = {} @@ -220,11 +194,22 @@ def get_queue_migrations(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_usage(self, threshold = None): - """Get usage queue""" + def get_queue_stats_resources(self, threshold: float = None): + """Get stats resources queue""" + + api_path = '/health/queue/stats-resources' + api_params = {} + + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_queue_usage(self, threshold: float = None): + """Get stats usage queue""" - - api_path = '/health/queue/usage' + api_path = '/health/queue/stats-usage' api_params = {} api_params['threshold'] = threshold @@ -233,11 +218,10 @@ def get_queue_usage(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_usage_dump(self, threshold = None): + def get_queue_stats_usage_dump(self, threshold: float = None): """Get usage dump queue""" - - api_path = '/health/queue/usage-dump' + api_path = '/health/queue/stats-usage-dump' api_params = {} api_params['threshold'] = threshold @@ -246,10 +230,9 @@ def get_queue_usage_dump(self, threshold = None): 'content-type': 'application/json', }, api_params) - def get_queue_webhooks(self, threshold = None): + def get_queue_webhooks(self, threshold: float = None): """Get webhooks queue""" - api_path = '/health/queue/webhooks' api_params = {} @@ -262,7 +245,6 @@ def get_queue_webhooks(self, threshold = None): def get_storage(self): """Get storage""" - api_path = '/health/storage' api_params = {} @@ -273,7 +255,6 @@ def get_storage(self): def get_storage_local(self): """Get local storage""" - api_path = '/health/storage/local' api_params = {} @@ -284,7 +265,6 @@ def get_storage_local(self): def get_time(self): """Get time""" - api_path = '/health/time' api_params = {} diff --git a/appwrite/services/locale.py b/appwrite/services/locale.py index db38754..6a8f007 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -9,7 +9,6 @@ def __init__(self, client): def get(self): """Get user locale""" - api_path = '/locale' api_params = {} @@ -20,7 +19,6 @@ def get(self): def list_codes(self): """List locale codes""" - api_path = '/locale/codes' api_params = {} @@ -31,7 +29,6 @@ def list_codes(self): def list_continents(self): """List continents""" - api_path = '/locale/continents' api_params = {} @@ -42,7 +39,6 @@ def list_continents(self): def list_countries(self): """List countries""" - api_path = '/locale/countries' api_params = {} @@ -53,7 +49,6 @@ def list_countries(self): def list_countries_eu(self): """List EU countries""" - api_path = '/locale/countries/eu' api_params = {} @@ -64,7 +59,6 @@ def list_countries_eu(self): def list_countries_phones(self): """List countries phone codes""" - api_path = '/locale/countries/phones' api_params = {} @@ -75,7 +69,6 @@ def list_countries_phones(self): def list_currencies(self): """List currencies""" - api_path = '/locale/currencies' api_params = {} @@ -86,7 +79,6 @@ def list_currencies(self): def list_languages(self): """List languages""" - api_path = '/locale/languages' api_params = {} diff --git a/appwrite/services/messaging.py b/appwrite/services/messaging.py index f8ce3bf..f344b9f 100644 --- a/appwrite/services/messaging.py +++ b/appwrite/services/messaging.py @@ -1,15 +1,16 @@ from ..service import Service from ..exception import AppwriteException +from ..enums.message_priority import MessagePriority; +from ..enums.smtp_encryption import SmtpEncryption; class Messaging(Service): def __init__(self, client): super(Messaging, self).__init__(client) - def list_messages(self, queries = None, search = None): + def list_messages(self, queries: list[str] = None, search: str = None): """List messages""" - api_path = '/messaging/messages' api_params = {} @@ -20,10 +21,9 @@ def list_messages(self, queries = None, search = None): 'content-type': 'application/json', }, 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): + def create_email(self, message_id: str, subject: str, content: str, topics: list[str] = None, users: list[str] = None, targets: list[str] = None, cc: list[str] = None, bcc: list[str] = None, attachments: list[str] = None, draft: bool = None, html: bool = None, scheduled_at: str = None): """Create email""" - api_path = '/messaging/messages/email' api_params = {} if message_id is None: @@ -53,10 +53,9 @@ def create_email(self, message_id, subject, content, topics = None, users = None 'content-type': 'application/json', }, 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): + def update_email(self, message_id: str, topics: list[str] = None, users: list[str] = None, targets: list[str] = None, subject: str = None, content: str = None, draft: bool = None, html: bool = None, cc: list[str] = None, bcc: list[str] = None, scheduled_at: str = None, attachments: list[str] = None): """Update email""" - api_path = '/messaging/messages/email/{messageId}' api_params = {} if message_id is None: @@ -80,10 +79,9 @@ def update_email(self, message_id, topics = None, users = None, targets = None, 'content-type': 'application/json', }, api_params) - def create_push(self, message_id, title = None, body = None, 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, content_available = None, critical = None, priority = None): + def create_push(self, message_id: str, title: str = None, body: str = None, topics: list[str] = None, users: list[str] = None, targets: list[str] = None, data: dict = None, action: str = None, image: str = None, icon: str = None, sound: str = None, color: str = None, tag: str = None, badge: float = None, draft: bool = None, scheduled_at: str = None, content_available: bool = None, critical: bool = None, priority: MessagePriority = None): """Create push notification""" - api_path = '/messaging/messages/push' api_params = {} if message_id is None: @@ -114,10 +112,9 @@ def create_push(self, message_id, title = None, body = None, topics = None, user 'content-type': 'application/json', }, 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, content_available = None, critical = None, priority = None): + def update_push(self, message_id: str, topics: list[str] = None, users: list[str] = None, targets: list[str] = None, title: str = None, body: str = None, data: dict = None, action: str = None, image: str = None, icon: str = None, sound: str = None, color: str = None, tag: str = None, badge: float = None, draft: bool = None, scheduled_at: str = None, content_available: bool = None, critical: bool = None, priority: MessagePriority = None): """Update push notification""" - api_path = '/messaging/messages/push/{messageId}' api_params = {} if message_id is None: @@ -148,10 +145,9 @@ def update_push(self, message_id, topics = None, users = None, targets = None, t 'content-type': 'application/json', }, api_params) - def create_sms(self, message_id, content, topics = None, users = None, targets = None, draft = None, scheduled_at = None): + def create_sms(self, message_id: str, content: str, topics: list[str] = None, users: list[str] = None, targets: list[str] = None, draft: bool = None, scheduled_at: str = None): """Create SMS""" - api_path = '/messaging/messages/sms' api_params = {} if message_id is None: @@ -173,10 +169,9 @@ def create_sms(self, message_id, content, topics = None, users = None, targets = 'content-type': 'application/json', }, api_params) - def update_sms(self, message_id, topics = None, users = None, targets = None, content = None, draft = None, scheduled_at = None): + def update_sms(self, message_id: str, topics: list[str] = None, users: list[str] = None, targets: list[str] = None, content: str = None, draft: bool = None, scheduled_at: str = None): """Update SMS""" - api_path = '/messaging/messages/sms/{messageId}' api_params = {} if message_id is None: @@ -195,10 +190,9 @@ def update_sms(self, message_id, topics = None, users = None, targets = None, co 'content-type': 'application/json', }, api_params) - def get_message(self, message_id): + def get_message(self, message_id: str): """Get message""" - api_path = '/messaging/messages/{messageId}' api_params = {} if message_id is None: @@ -211,10 +205,9 @@ def get_message(self, message_id): 'content-type': 'application/json', }, api_params) - def delete(self, message_id): + def delete(self, message_id: str): """Delete message""" - api_path = '/messaging/messages/{messageId}' api_params = {} if message_id is None: @@ -227,10 +220,9 @@ def delete(self, message_id): 'content-type': 'application/json', }, api_params) - def list_message_logs(self, message_id, queries = None): + def list_message_logs(self, message_id: str, queries: list[str] = None): """List message logs""" - api_path = '/messaging/messages/{messageId}/logs' api_params = {} if message_id is None: @@ -244,10 +236,9 @@ def list_message_logs(self, message_id, queries = None): 'content-type': 'application/json', }, api_params) - def list_targets(self, message_id, queries = None): + def list_targets(self, message_id: str, queries: list[str] = None): """List message targets""" - api_path = '/messaging/messages/{messageId}/targets' api_params = {} if message_id is None: @@ -261,10 +252,9 @@ def list_targets(self, message_id, queries = None): 'content-type': 'application/json', }, api_params) - def list_providers(self, queries = None, search = None): + def list_providers(self, queries: list[str] = None, search: str = None): """List providers""" - api_path = '/messaging/providers' api_params = {} @@ -275,10 +265,9 @@ def list_providers(self, queries = None, search = None): 'content-type': 'application/json', }, 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): + def create_apns_provider(self, provider_id: str, name: str, auth_key: str = None, auth_key_id: str = None, team_id: str = None, bundle_id: str = None, sandbox: bool = None, enabled: bool = None): """Create APNS provider""" - api_path = '/messaging/providers/apns' api_params = {} if provider_id is None: @@ -301,10 +290,9 @@ def create_apns_provider(self, provider_id, name, auth_key = None, auth_key_id = 'content-type': 'application/json', }, 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): + def update_apns_provider(self, provider_id: str, name: str = None, enabled: bool = None, auth_key: str = None, auth_key_id: str = None, team_id: str = None, bundle_id: str = None, sandbox: bool = None): """Update APNS provider""" - api_path = '/messaging/providers/apns/{providerId}' api_params = {} if provider_id is None: @@ -324,10 +312,9 @@ def update_apns_provider(self, provider_id, name = None, enabled = None, auth_ke 'content-type': 'application/json', }, api_params) - def create_fcm_provider(self, provider_id, name, service_account_json = None, enabled = None): + def create_fcm_provider(self, provider_id: str, name: str, service_account_json: dict = None, enabled: bool = None): """Create FCM provider""" - api_path = '/messaging/providers/fcm' api_params = {} if provider_id is None: @@ -346,10 +333,9 @@ def create_fcm_provider(self, provider_id, name, service_account_json = None, en 'content-type': 'application/json', }, api_params) - def update_fcm_provider(self, provider_id, name = None, enabled = None, service_account_json = None): + def update_fcm_provider(self, provider_id: str, name: str = None, enabled: bool = None, service_account_json: dict = None): """Update FCM provider""" - api_path = '/messaging/providers/fcm/{providerId}' api_params = {} if provider_id is None: @@ -365,10 +351,9 @@ def update_fcm_provider(self, provider_id, name = None, enabled = None, service_ 'content-type': 'application/json', }, 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): + def create_mailgun_provider(self, provider_id: str, name: str, api_key: str = None, domain: str = None, is_eu_region: bool = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None, enabled: bool = None): """Create Mailgun provider""" - api_path = '/messaging/providers/mailgun' api_params = {} if provider_id is None: @@ -393,10 +378,9 @@ def create_mailgun_provider(self, provider_id, name, api_key = None, domain = No 'content-type': 'application/json', }, 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): + def update_mailgun_provider(self, provider_id: str, name: str = None, api_key: str = None, domain: str = None, is_eu_region: bool = None, enabled: bool = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None): """Update Mailgun provider""" - api_path = '/messaging/providers/mailgun/{providerId}' api_params = {} if provider_id is None: @@ -418,10 +402,9 @@ def update_mailgun_provider(self, provider_id, name = None, api_key = None, doma 'content-type': 'application/json', }, api_params) - def create_msg91_provider(self, provider_id, name, template_id = None, sender_id = None, auth_key = None, enabled = None): + def create_msg91_provider(self, provider_id: str, name: str, template_id: str = None, sender_id: str = None, auth_key: str = None, enabled: bool = None): """Create Msg91 provider""" - api_path = '/messaging/providers/msg91' api_params = {} if provider_id is None: @@ -442,10 +425,9 @@ def create_msg91_provider(self, provider_id, name, template_id = None, sender_id 'content-type': 'application/json', }, api_params) - def update_msg91_provider(self, provider_id, name = None, enabled = None, template_id = None, sender_id = None, auth_key = None): + def update_msg91_provider(self, provider_id: str, name: str = None, enabled: bool = None, template_id: str = None, sender_id: str = None, auth_key: str = None): """Update Msg91 provider""" - api_path = '/messaging/providers/msg91/{providerId}' api_params = {} if provider_id is None: @@ -463,10 +445,9 @@ def update_msg91_provider(self, provider_id, name = None, enabled = None, templa 'content-type': 'application/json', }, 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): + def create_sendgrid_provider(self, provider_id: str, name: str, api_key: str = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None, enabled: bool = None): """Create Sendgrid provider""" - api_path = '/messaging/providers/sendgrid' api_params = {} if provider_id is None: @@ -489,10 +470,9 @@ def create_sendgrid_provider(self, provider_id, name, api_key = None, from_name 'content-type': 'application/json', }, 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): + def update_sendgrid_provider(self, provider_id: str, name: str = None, enabled: bool = None, api_key: str = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None): """Update Sendgrid provider""" - api_path = '/messaging/providers/sendgrid/{providerId}' api_params = {} if provider_id is None: @@ -512,10 +492,9 @@ def update_sendgrid_provider(self, provider_id, name = None, enabled = None, api 'content-type': 'application/json', }, 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): + def create_smtp_provider(self, provider_id: str, name: str, host: str, port: float = None, username: str = None, password: str = None, encryption: SmtpEncryption = None, auto_tls: bool = None, mailer: str = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None, enabled: bool = None): """Create SMTP provider""" - api_path = '/messaging/providers/smtp' api_params = {} if provider_id is None: @@ -547,10 +526,9 @@ def create_smtp_provider(self, provider_id, name, host, port = None, username = 'content-type': 'application/json', }, 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): + def update_smtp_provider(self, provider_id: str, name: str = None, host: str = None, port: float = None, username: str = None, password: str = None, encryption: SmtpEncryption = None, auto_tls: bool = None, mailer: str = None, from_name: str = None, from_email: str = None, reply_to_name: str = None, reply_to_email: str = None, enabled: bool = None): """Update SMTP provider""" - api_path = '/messaging/providers/smtp/{providerId}' api_params = {} if provider_id is None: @@ -576,10 +554,9 @@ def update_smtp_provider(self, provider_id, name = None, host = None, port = Non 'content-type': 'application/json', }, api_params) - def create_telesign_provider(self, provider_id, name, xfrom = None, customer_id = None, api_key = None, enabled = None): + def create_telesign_provider(self, provider_id: str, name: str, xfrom: str = None, customer_id: str = None, api_key: str = None, enabled: bool = None): """Create Telesign provider""" - api_path = '/messaging/providers/telesign' api_params = {} if provider_id is None: @@ -600,10 +577,9 @@ def create_telesign_provider(self, provider_id, name, xfrom = None, customer_id 'content-type': 'application/json', }, api_params) - def update_telesign_provider(self, provider_id, name = None, enabled = None, customer_id = None, api_key = None, xfrom = None): + def update_telesign_provider(self, provider_id: str, name: str = None, enabled: bool = None, customer_id: str = None, api_key: str = None, xfrom: str = None): """Update Telesign provider""" - api_path = '/messaging/providers/telesign/{providerId}' api_params = {} if provider_id is None: @@ -621,10 +597,9 @@ def update_telesign_provider(self, provider_id, name = None, enabled = None, cus 'content-type': 'application/json', }, api_params) - def create_textmagic_provider(self, provider_id, name, xfrom = None, username = None, api_key = None, enabled = None): + def create_textmagic_provider(self, provider_id: str, name: str, xfrom: str = None, username: str = None, api_key: str = None, enabled: bool = None): """Create Textmagic provider""" - api_path = '/messaging/providers/textmagic' api_params = {} if provider_id is None: @@ -645,10 +620,9 @@ def create_textmagic_provider(self, provider_id, name, xfrom = None, username = 'content-type': 'application/json', }, api_params) - def update_textmagic_provider(self, provider_id, name = None, enabled = None, username = None, api_key = None, xfrom = None): + def update_textmagic_provider(self, provider_id: str, name: str = None, enabled: bool = None, username: str = None, api_key: str = None, xfrom: str = None): """Update Textmagic provider""" - api_path = '/messaging/providers/textmagic/{providerId}' api_params = {} if provider_id is None: @@ -666,10 +640,9 @@ def update_textmagic_provider(self, provider_id, name = None, enabled = None, us 'content-type': 'application/json', }, api_params) - def create_twilio_provider(self, provider_id, name, xfrom = None, account_sid = None, auth_token = None, enabled = None): + def create_twilio_provider(self, provider_id: str, name: str, xfrom: str = None, account_sid: str = None, auth_token: str = None, enabled: bool = None): """Create Twilio provider""" - api_path = '/messaging/providers/twilio' api_params = {} if provider_id is None: @@ -690,10 +663,9 @@ def create_twilio_provider(self, provider_id, name, xfrom = None, account_sid = 'content-type': 'application/json', }, api_params) - def update_twilio_provider(self, provider_id, name = None, enabled = None, account_sid = None, auth_token = None, xfrom = None): + def update_twilio_provider(self, provider_id: str, name: str = None, enabled: bool = None, account_sid: str = None, auth_token: str = None, xfrom: str = None): """Update Twilio provider""" - api_path = '/messaging/providers/twilio/{providerId}' api_params = {} if provider_id is None: @@ -711,10 +683,9 @@ def update_twilio_provider(self, provider_id, name = None, enabled = None, accou 'content-type': 'application/json', }, api_params) - def create_vonage_provider(self, provider_id, name, xfrom = None, api_key = None, api_secret = None, enabled = None): + def create_vonage_provider(self, provider_id: str, name: str, xfrom: str = None, api_key: str = None, api_secret: str = None, enabled: bool = None): """Create Vonage provider""" - api_path = '/messaging/providers/vonage' api_params = {} if provider_id is None: @@ -735,10 +706,9 @@ def create_vonage_provider(self, provider_id, name, xfrom = None, api_key = None 'content-type': 'application/json', }, api_params) - def update_vonage_provider(self, provider_id, name = None, enabled = None, api_key = None, api_secret = None, xfrom = None): + def update_vonage_provider(self, provider_id: str, name: str = None, enabled: bool = None, api_key: str = None, api_secret: str = None, xfrom: str = None): """Update Vonage provider""" - api_path = '/messaging/providers/vonage/{providerId}' api_params = {} if provider_id is None: @@ -756,10 +726,9 @@ def update_vonage_provider(self, provider_id, name = None, enabled = None, api_k 'content-type': 'application/json', }, api_params) - def get_provider(self, provider_id): + def get_provider(self, provider_id: str): """Get provider""" - api_path = '/messaging/providers/{providerId}' api_params = {} if provider_id is None: @@ -772,10 +741,9 @@ def get_provider(self, provider_id): 'content-type': 'application/json', }, api_params) - def delete_provider(self, provider_id): + def delete_provider(self, provider_id: str): """Delete provider""" - api_path = '/messaging/providers/{providerId}' api_params = {} if provider_id is None: @@ -788,10 +756,9 @@ def delete_provider(self, provider_id): 'content-type': 'application/json', }, api_params) - def list_provider_logs(self, provider_id, queries = None): + def list_provider_logs(self, provider_id: str, queries: list[str] = None): """List provider logs""" - api_path = '/messaging/providers/{providerId}/logs' api_params = {} if provider_id is None: @@ -805,10 +772,9 @@ def list_provider_logs(self, provider_id, queries = None): 'content-type': 'application/json', }, api_params) - def list_subscriber_logs(self, subscriber_id, queries = None): + def list_subscriber_logs(self, subscriber_id: str, queries: list[str] = None): """List subscriber logs""" - api_path = '/messaging/subscribers/{subscriberId}/logs' api_params = {} if subscriber_id is None: @@ -822,10 +788,9 @@ def list_subscriber_logs(self, subscriber_id, queries = None): 'content-type': 'application/json', }, api_params) - def list_topics(self, queries = None, search = None): + def list_topics(self, queries: list[str] = None, search: str = None): """List topics""" - api_path = '/messaging/topics' api_params = {} @@ -836,10 +801,9 @@ def list_topics(self, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create_topic(self, topic_id, name, subscribe = None): + def create_topic(self, topic_id: str, name: str, subscribe: list[str] = None): """Create topic""" - api_path = '/messaging/topics' api_params = {} if topic_id is None: @@ -857,10 +821,9 @@ def create_topic(self, topic_id, name, subscribe = None): 'content-type': 'application/json', }, api_params) - def get_topic(self, topic_id): + def get_topic(self, topic_id: str): """Get topic""" - api_path = '/messaging/topics/{topicId}' api_params = {} if topic_id is None: @@ -873,10 +836,9 @@ def get_topic(self, topic_id): 'content-type': 'application/json', }, api_params) - def update_topic(self, topic_id, name = None, subscribe = None): + def update_topic(self, topic_id: str, name: str = None, subscribe: list[str] = None): """Update topic""" - api_path = '/messaging/topics/{topicId}' api_params = {} if topic_id is None: @@ -891,10 +853,9 @@ def update_topic(self, topic_id, name = None, subscribe = None): 'content-type': 'application/json', }, api_params) - def delete_topic(self, topic_id): + def delete_topic(self, topic_id: str): """Delete topic""" - api_path = '/messaging/topics/{topicId}' api_params = {} if topic_id is None: @@ -907,10 +868,9 @@ def delete_topic(self, topic_id): 'content-type': 'application/json', }, api_params) - def list_topic_logs(self, topic_id, queries = None): + def list_topic_logs(self, topic_id: str, queries: list[str] = None): """List topic logs""" - api_path = '/messaging/topics/{topicId}/logs' api_params = {} if topic_id is None: @@ -924,10 +884,9 @@ def list_topic_logs(self, topic_id, queries = None): 'content-type': 'application/json', }, api_params) - def list_subscribers(self, topic_id, queries = None, search = None): + def list_subscribers(self, topic_id: str, queries: list[str] = None, search: str = None): """List subscribers""" - api_path = '/messaging/topics/{topicId}/subscribers' api_params = {} if topic_id is None: @@ -942,10 +901,9 @@ def list_subscribers(self, topic_id, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create_subscriber(self, topic_id, subscriber_id, target_id): + def create_subscriber(self, topic_id: str, subscriber_id: str, target_id: str): """Create subscriber""" - api_path = '/messaging/topics/{topicId}/subscribers' api_params = {} if topic_id is None: @@ -966,10 +924,9 @@ def create_subscriber(self, topic_id, subscriber_id, target_id): 'content-type': 'application/json', }, api_params) - def get_subscriber(self, topic_id, subscriber_id): + def get_subscriber(self, topic_id: str, subscriber_id: str): """Get subscriber""" - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' api_params = {} if topic_id is None: @@ -986,10 +943,9 @@ def get_subscriber(self, topic_id, subscriber_id): 'content-type': 'application/json', }, api_params) - def delete_subscriber(self, topic_id, subscriber_id): + def delete_subscriber(self, topic_id: str, subscriber_id: str): """Delete subscriber""" - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' api_params = {} if topic_id is None: diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index 9acbb3a..dc30df5 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -1,15 +1,18 @@ from ..service import Service from ..exception import AppwriteException +from ..enums.compression import Compression; +from ..input_file import InputFile +from ..enums.image_gravity import ImageGravity; +from ..enums.image_format import ImageFormat; class Storage(Service): def __init__(self, client): super(Storage, self).__init__(client) - def list_buckets(self, queries = None, search = None): + def list_buckets(self, queries: list[str] = None, search: str = None): """List buckets""" - api_path = '/storage/buckets' api_params = {} @@ -20,10 +23,9 @@ def list_buckets(self, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create_bucket(self, bucket_id, name, permissions = None, file_security = None, enabled = None, maximum_file_size = None, allowed_file_extensions = None, compression = None, encryption = None, antivirus = None): + def create_bucket(self, bucket_id: str, name: str, permissions: list[str] = None, file_security: bool = None, enabled: bool = None, maximum_file_size: float = None, allowed_file_extensions: list[str] = None, compression: Compression = None, encryption: bool = None, antivirus: bool = None): """Create bucket""" - api_path = '/storage/buckets' api_params = {} if bucket_id is None: @@ -48,10 +50,9 @@ def create_bucket(self, bucket_id, name, permissions = None, file_security = Non 'content-type': 'application/json', }, api_params) - def get_bucket(self, bucket_id): + def get_bucket(self, bucket_id: str): """Get bucket""" - api_path = '/storage/buckets/{bucketId}' api_params = {} if bucket_id is None: @@ -64,10 +65,9 @@ def get_bucket(self, bucket_id): 'content-type': 'application/json', }, api_params) - def update_bucket(self, bucket_id, name, permissions = None, file_security = None, enabled = None, maximum_file_size = None, allowed_file_extensions = None, compression = None, encryption = None, antivirus = None): + def update_bucket(self, bucket_id: str, name: str, permissions: list[str] = None, file_security: bool = None, enabled: bool = None, maximum_file_size: float = None, allowed_file_extensions: list[str] = None, compression: Compression = None, encryption: bool = None, antivirus: bool = None): """Update bucket""" - api_path = '/storage/buckets/{bucketId}' api_params = {} if bucket_id is None: @@ -92,10 +92,9 @@ def update_bucket(self, bucket_id, name, permissions = None, file_security = Non 'content-type': 'application/json', }, api_params) - def delete_bucket(self, bucket_id): + def delete_bucket(self, bucket_id: str): """Delete bucket""" - api_path = '/storage/buckets/{bucketId}' api_params = {} if bucket_id is None: @@ -108,10 +107,9 @@ def delete_bucket(self, bucket_id): 'content-type': 'application/json', }, api_params) - def list_files(self, bucket_id, queries = None, search = None): + def list_files(self, bucket_id: str, queries: list[str] = None, search: str = None): """List files""" - api_path = '/storage/buckets/{bucketId}/files' api_params = {} if bucket_id is None: @@ -126,10 +124,9 @@ def list_files(self, bucket_id, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create_file(self, bucket_id, file_id, file, permissions = None, on_progress = None): + def create_file(self, bucket_id: str, file_id: str, file: InputFile, permissions: list[str] = None, on_progress = None): """Create file""" - api_path = '/storage/buckets/{bucketId}/files' api_params = {} if bucket_id is None: @@ -157,10 +154,9 @@ def create_file(self, bucket_id, file_id, file, permissions = None, on_progress 'content-type': 'multipart/form-data', }, api_params, param_name, on_progress, upload_id) - def get_file(self, bucket_id, file_id): + def get_file(self, bucket_id: str, file_id: str): """Get file""" - api_path = '/storage/buckets/{bucketId}/files/{fileId}' api_params = {} if bucket_id is None: @@ -177,10 +173,9 @@ def get_file(self, bucket_id, file_id): 'content-type': 'application/json', }, api_params) - def update_file(self, bucket_id, file_id, name = None, permissions = None): + def update_file(self, bucket_id: str, file_id: str, name: str = None, permissions: list[str] = None): """Update file""" - api_path = '/storage/buckets/{bucketId}/files/{fileId}' api_params = {} if bucket_id is None: @@ -199,10 +194,9 @@ def update_file(self, bucket_id, file_id, name = None, permissions = None): 'content-type': 'application/json', }, api_params) - def delete_file(self, bucket_id, file_id): + def delete_file(self, bucket_id: str, file_id: str): """Delete file""" - api_path = '/storage/buckets/{bucketId}/files/{fileId}' api_params = {} if bucket_id is None: @@ -219,10 +213,9 @@ def delete_file(self, bucket_id, file_id): 'content-type': 'application/json', }, api_params) - def get_file_download(self, bucket_id, file_id): + def get_file_download(self, bucket_id: str, file_id: str): """Get file for download""" - api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' api_params = {} if bucket_id is None: @@ -239,10 +232,9 @@ def get_file_download(self, bucket_id, file_id): 'content-type': 'application/json', }, api_params) - def get_file_preview(self, bucket_id, file_id, width = None, height = None, gravity = None, quality = None, border_width = None, border_color = None, border_radius = None, opacity = None, rotation = None, background = None, output = None): + def get_file_preview(self, bucket_id: str, file_id: str, width: float = None, height: float = None, gravity: ImageGravity = None, quality: float = None, border_width: float = None, border_color: str = None, border_radius: float = None, opacity: float = None, rotation: float = None, background: str = None, output: ImageFormat = None): """Get file preview""" - api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' api_params = {} if bucket_id is None: @@ -270,10 +262,9 @@ def get_file_preview(self, bucket_id, file_id, width = None, height = None, grav 'content-type': 'application/json', }, api_params) - def get_file_view(self, bucket_id, file_id): + def get_file_view(self, bucket_id: str, file_id: str): """Get file for view""" - api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' api_params = {} if bucket_id is None: diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 2c387ed..f157768 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -6,10 +6,9 @@ class Teams(Service): def __init__(self, client): super(Teams, self).__init__(client) - def list(self, queries = None, search = None): + def list(self, queries: list[str] = None, search: str = None): """List teams""" - api_path = '/teams' api_params = {} @@ -20,10 +19,9 @@ def list(self, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create(self, team_id, name, roles = None): + def create(self, team_id: str, name: str, roles: list[str] = None): """Create team""" - api_path = '/teams' api_params = {} if team_id is None: @@ -41,10 +39,9 @@ def create(self, team_id, name, roles = None): 'content-type': 'application/json', }, api_params) - def get(self, team_id): + def get(self, team_id: str): """Get team""" - api_path = '/teams/{teamId}' api_params = {} if team_id is None: @@ -57,10 +54,9 @@ def get(self, team_id): 'content-type': 'application/json', }, api_params) - def update_name(self, team_id, name): + def update_name(self, team_id: str, name: str): """Update name""" - api_path = '/teams/{teamId}' api_params = {} if team_id is None: @@ -77,10 +73,9 @@ def update_name(self, team_id, name): 'content-type': 'application/json', }, api_params) - def delete(self, team_id): + def delete(self, team_id: str): """Delete team""" - api_path = '/teams/{teamId}' api_params = {} if team_id is None: @@ -93,10 +88,9 @@ def delete(self, team_id): 'content-type': 'application/json', }, api_params) - def list_memberships(self, team_id, queries = None, search = None): + def list_memberships(self, team_id: str, queries: list[str] = None, search: str = None): """List team memberships""" - api_path = '/teams/{teamId}/memberships' api_params = {} if team_id is None: @@ -111,10 +105,9 @@ def list_memberships(self, team_id, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create_membership(self, team_id, roles, email = None, user_id = None, phone = None, url = None, name = None): + def create_membership(self, team_id: str, roles: list[str], email: str = None, user_id: str = None, phone: str = None, url: str = None, name: str = None): """Create team membership""" - api_path = '/teams/{teamId}/memberships' api_params = {} if team_id is None: @@ -136,10 +129,9 @@ def create_membership(self, team_id, roles, email = None, user_id = None, phone 'content-type': 'application/json', }, api_params) - def get_membership(self, team_id, membership_id): + def get_membership(self, team_id: str, membership_id: str): """Get team membership""" - api_path = '/teams/{teamId}/memberships/{membershipId}' api_params = {} if team_id is None: @@ -156,10 +148,9 @@ def get_membership(self, team_id, membership_id): 'content-type': 'application/json', }, api_params) - def update_membership(self, team_id, membership_id, roles): + def update_membership(self, team_id: str, membership_id: str, roles: list[str]): """Update membership""" - api_path = '/teams/{teamId}/memberships/{membershipId}' api_params = {} if team_id is None: @@ -180,10 +171,9 @@ def update_membership(self, team_id, membership_id, roles): 'content-type': 'application/json', }, api_params) - def delete_membership(self, team_id, membership_id): + def delete_membership(self, team_id: str, membership_id: str): """Delete team membership""" - api_path = '/teams/{teamId}/memberships/{membershipId}' api_params = {} if team_id is None: @@ -200,10 +190,9 @@ def delete_membership(self, team_id, membership_id): 'content-type': 'application/json', }, api_params) - def update_membership_status(self, team_id, membership_id, user_id, secret): + def update_membership_status(self, team_id: str, membership_id: str, user_id: str, secret: str): """Update team membership status""" - api_path = '/teams/{teamId}/memberships/{membershipId}/status' api_params = {} if team_id is None: @@ -228,10 +217,9 @@ def update_membership_status(self, team_id, membership_id, user_id, secret): 'content-type': 'application/json', }, api_params) - def get_prefs(self, team_id): + def get_prefs(self, team_id: str): """Get team preferences""" - api_path = '/teams/{teamId}/prefs' api_params = {} if team_id is None: @@ -244,10 +232,9 @@ def get_prefs(self, team_id): 'content-type': 'application/json', }, api_params) - def update_prefs(self, team_id, prefs): + def update_prefs(self, team_id: str, prefs: dict): """Update preferences""" - api_path = '/teams/{teamId}/prefs' api_params = {} if team_id is None: diff --git a/appwrite/services/users.py b/appwrite/services/users.py index aa04a72..6ed17ee 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -1,15 +1,17 @@ from ..service import Service from ..exception import AppwriteException +from ..enums.password_hash import PasswordHash; +from ..enums.authenticator_type import AuthenticatorType; +from ..enums.messaging_provider_type import MessagingProviderType; class Users(Service): def __init__(self, client): super(Users, self).__init__(client) - def list(self, queries = None, search = None): + def list(self, queries: list[str] = None, search: str = None): """List users""" - api_path = '/users' api_params = {} @@ -20,10 +22,9 @@ def list(self, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def create(self, user_id, email = None, phone = None, password = None, name = None): + def create(self, user_id: str, email: str = None, phone: str = None, password: str = None, name: str = None): """Create user""" - api_path = '/users' api_params = {} if user_id is None: @@ -40,10 +41,9 @@ def create(self, user_id, email = None, phone = None, password = None, name = No 'content-type': 'application/json', }, api_params) - def create_argon2_user(self, user_id, email, password, name = None): + def create_argon2_user(self, user_id: str, email: str, password: str, name: str = None): """Create user with Argon2 password""" - api_path = '/users/argon2' api_params = {} if user_id is None: @@ -65,10 +65,9 @@ def create_argon2_user(self, user_id, email, password, name = None): 'content-type': 'application/json', }, api_params) - def create_bcrypt_user(self, user_id, email, password, name = None): + def create_bcrypt_user(self, user_id: str, email: str, password: str, name: str = None): """Create user with bcrypt password""" - api_path = '/users/bcrypt' api_params = {} if user_id is None: @@ -90,10 +89,9 @@ def create_bcrypt_user(self, user_id, email, password, name = None): 'content-type': 'application/json', }, api_params) - def list_identities(self, queries = None, search = None): + def list_identities(self, queries: list[str] = None, search: str = None): """List identities""" - api_path = '/users/identities' api_params = {} @@ -104,10 +102,9 @@ def list_identities(self, queries = None, search = None): 'content-type': 'application/json', }, api_params) - def delete_identity(self, identity_id): + def delete_identity(self, identity_id: str): """Delete identity""" - api_path = '/users/identities/{identityId}' api_params = {} if identity_id is None: @@ -120,10 +117,9 @@ def delete_identity(self, identity_id): 'content-type': 'application/json', }, api_params) - def create_md5_user(self, user_id, email, password, name = None): + def create_md5_user(self, user_id: str, email: str, password: str, name: str = None): """Create user with MD5 password""" - api_path = '/users/md5' api_params = {} if user_id is None: @@ -145,10 +141,9 @@ def create_md5_user(self, user_id, email, password, name = None): 'content-type': 'application/json', }, api_params) - def create_ph_pass_user(self, user_id, email, password, name = None): + def create_ph_pass_user(self, user_id: str, email: str, password: str, name: str = None): """Create user with PHPass password""" - api_path = '/users/phpass' api_params = {} if user_id is None: @@ -170,10 +165,9 @@ def create_ph_pass_user(self, user_id, email, password, name = None): 'content-type': 'application/json', }, api_params) - def create_scrypt_user(self, user_id, email, password, password_salt, password_cpu, password_memory, password_parallel, password_length, name = None): + def create_scrypt_user(self, user_id: str, email: str, password: str, password_salt: str, password_cpu: float, password_memory: float, password_parallel: float, password_length: float, name: str = None): """Create user with Scrypt password""" - api_path = '/users/scrypt' api_params = {} if user_id is None: @@ -215,10 +209,9 @@ def create_scrypt_user(self, user_id, email, password, password_salt, password_c 'content-type': 'application/json', }, api_params) - def create_scrypt_modified_user(self, user_id, email, password, password_salt, password_salt_separator, password_signer_key, name = None): + def create_scrypt_modified_user(self, user_id: str, email: str, password: str, password_salt: str, password_salt_separator: str, password_signer_key: str, name: str = None): """Create user with Scrypt modified password""" - api_path = '/users/scrypt-modified' api_params = {} if user_id is None: @@ -252,10 +245,9 @@ def create_scrypt_modified_user(self, user_id, email, password, password_salt, p 'content-type': 'application/json', }, api_params) - def create_sha_user(self, user_id, email, password, password_version = None, name = None): + def create_sha_user(self, user_id: str, email: str, password: str, password_version: PasswordHash = None, name: str = None): """Create user with SHA password""" - api_path = '/users/sha' api_params = {} if user_id is None: @@ -278,10 +270,9 @@ def create_sha_user(self, user_id, email, password, password_version = None, nam 'content-type': 'application/json', }, api_params) - def get(self, user_id): + def get(self, user_id: str): """Get user""" - api_path = '/users/{userId}' api_params = {} if user_id is None: @@ -294,10 +285,9 @@ def get(self, user_id): 'content-type': 'application/json', }, api_params) - def delete(self, user_id): + def delete(self, user_id: str): """Delete user""" - api_path = '/users/{userId}' api_params = {} if user_id is None: @@ -310,10 +300,9 @@ def delete(self, user_id): 'content-type': 'application/json', }, api_params) - def update_email(self, user_id, email): + def update_email(self, user_id: str, email: str): """Update email""" - api_path = '/users/{userId}/email' api_params = {} if user_id is None: @@ -330,10 +319,9 @@ def update_email(self, user_id, email): 'content-type': 'application/json', }, api_params) - def create_jwt(self, user_id, session_id = None, duration = None): + def create_jwt(self, user_id: str, session_id: str = None, duration: float = None): """Create user JWT""" - api_path = '/users/{userId}/jwts' api_params = {} if user_id is None: @@ -348,10 +336,9 @@ def create_jwt(self, user_id, session_id = None, duration = None): 'content-type': 'application/json', }, api_params) - def update_labels(self, user_id, labels): + def update_labels(self, user_id: str, labels: list[str]): """Update user labels""" - api_path = '/users/{userId}/labels' api_params = {} if user_id is None: @@ -368,10 +355,9 @@ def update_labels(self, user_id, labels): 'content-type': 'application/json', }, api_params) - def list_logs(self, user_id, queries = None): + def list_logs(self, user_id: str, queries: list[str] = None): """List user logs""" - api_path = '/users/{userId}/logs' api_params = {} if user_id is None: @@ -385,10 +371,9 @@ def list_logs(self, user_id, queries = None): 'content-type': 'application/json', }, api_params) - def list_memberships(self, user_id): + def list_memberships(self, user_id: str): """List user memberships""" - api_path = '/users/{userId}/memberships' api_params = {} if user_id is None: @@ -401,10 +386,9 @@ def list_memberships(self, user_id): 'content-type': 'application/json', }, api_params) - def update_mfa(self, user_id, mfa): + def update_mfa(self, user_id: str, mfa: bool): """Update MFA""" - api_path = '/users/{userId}/mfa' api_params = {} if user_id is None: @@ -421,10 +405,9 @@ def update_mfa(self, user_id, mfa): 'content-type': 'application/json', }, api_params) - def delete_mfa_authenticator(self, user_id, type): + def delete_mfa_authenticator(self, user_id: str, type: AuthenticatorType): """Delete authenticator""" - api_path = '/users/{userId}/mfa/authenticators/{type}' api_params = {} if user_id is None: @@ -441,10 +424,9 @@ def delete_mfa_authenticator(self, user_id, type): 'content-type': 'application/json', }, api_params) - def list_mfa_factors(self, user_id): + def list_mfa_factors(self, user_id: str): """List factors""" - api_path = '/users/{userId}/mfa/factors' api_params = {} if user_id is None: @@ -457,10 +439,9 @@ def list_mfa_factors(self, user_id): 'content-type': 'application/json', }, api_params) - def get_mfa_recovery_codes(self, user_id): + def get_mfa_recovery_codes(self, user_id: str): """Get MFA recovery codes""" - api_path = '/users/{userId}/mfa/recovery-codes' api_params = {} if user_id is None: @@ -473,10 +454,9 @@ def get_mfa_recovery_codes(self, user_id): 'content-type': 'application/json', }, api_params) - def update_mfa_recovery_codes(self, user_id): + def update_mfa_recovery_codes(self, user_id: str): """Regenerate MFA recovery codes""" - api_path = '/users/{userId}/mfa/recovery-codes' api_params = {} if user_id is None: @@ -489,10 +469,9 @@ def update_mfa_recovery_codes(self, user_id): 'content-type': 'application/json', }, api_params) - def create_mfa_recovery_codes(self, user_id): + def create_mfa_recovery_codes(self, user_id: str): """Create MFA recovery codes""" - api_path = '/users/{userId}/mfa/recovery-codes' api_params = {} if user_id is None: @@ -505,10 +484,9 @@ def create_mfa_recovery_codes(self, user_id): 'content-type': 'application/json', }, api_params) - def update_name(self, user_id, name): + def update_name(self, user_id: str, name: str): """Update name""" - api_path = '/users/{userId}/name' api_params = {} if user_id is None: @@ -525,10 +503,9 @@ def update_name(self, user_id, name): 'content-type': 'application/json', }, api_params) - def update_password(self, user_id, password): + def update_password(self, user_id: str, password: str): """Update password""" - api_path = '/users/{userId}/password' api_params = {} if user_id is None: @@ -545,10 +522,9 @@ def update_password(self, user_id, password): 'content-type': 'application/json', }, api_params) - def update_phone(self, user_id, number): + def update_phone(self, user_id: str, number: str): """Update phone""" - api_path = '/users/{userId}/phone' api_params = {} if user_id is None: @@ -565,10 +541,9 @@ def update_phone(self, user_id, number): 'content-type': 'application/json', }, api_params) - def get_prefs(self, user_id): + def get_prefs(self, user_id: str): """Get user preferences""" - api_path = '/users/{userId}/prefs' api_params = {} if user_id is None: @@ -581,10 +556,9 @@ def get_prefs(self, user_id): 'content-type': 'application/json', }, api_params) - def update_prefs(self, user_id, prefs): + def update_prefs(self, user_id: str, prefs: dict): """Update user preferences""" - api_path = '/users/{userId}/prefs' api_params = {} if user_id is None: @@ -601,10 +575,9 @@ def update_prefs(self, user_id, prefs): 'content-type': 'application/json', }, api_params) - def list_sessions(self, user_id): + def list_sessions(self, user_id: str): """List user sessions""" - api_path = '/users/{userId}/sessions' api_params = {} if user_id is None: @@ -617,10 +590,9 @@ def list_sessions(self, user_id): 'content-type': 'application/json', }, api_params) - def create_session(self, user_id): + def create_session(self, user_id: str): """Create session""" - api_path = '/users/{userId}/sessions' api_params = {} if user_id is None: @@ -633,10 +605,9 @@ def create_session(self, user_id): 'content-type': 'application/json', }, api_params) - def delete_sessions(self, user_id): + def delete_sessions(self, user_id: str): """Delete user sessions""" - api_path = '/users/{userId}/sessions' api_params = {} if user_id is None: @@ -649,10 +620,9 @@ def delete_sessions(self, user_id): 'content-type': 'application/json', }, api_params) - def delete_session(self, user_id, session_id): + def delete_session(self, user_id: str, session_id: str): """Delete user session""" - api_path = '/users/{userId}/sessions/{sessionId}' api_params = {} if user_id is None: @@ -669,10 +639,9 @@ def delete_session(self, user_id, session_id): 'content-type': 'application/json', }, api_params) - def update_status(self, user_id, status): + def update_status(self, user_id: str, status: bool): """Update user status""" - api_path = '/users/{userId}/status' api_params = {} if user_id is None: @@ -689,10 +658,9 @@ def update_status(self, user_id, status): 'content-type': 'application/json', }, api_params) - def list_targets(self, user_id, queries = None): + def list_targets(self, user_id: str, queries: list[str] = None): """List user targets""" - api_path = '/users/{userId}/targets' api_params = {} if user_id is None: @@ -706,10 +674,9 @@ def list_targets(self, user_id, queries = None): 'content-type': 'application/json', }, api_params) - def create_target(self, user_id, target_id, provider_type, identifier, provider_id = None, name = None): + def create_target(self, user_id: str, target_id: str, provider_type: MessagingProviderType, identifier: str, provider_id: str = None, name: str = None): """Create user target""" - api_path = '/users/{userId}/targets' api_params = {} if user_id is None: @@ -736,10 +703,9 @@ def create_target(self, user_id, target_id, provider_type, identifier, provider_ 'content-type': 'application/json', }, api_params) - def get_target(self, user_id, target_id): + def get_target(self, user_id: str, target_id: str): """Get user target""" - api_path = '/users/{userId}/targets/{targetId}' api_params = {} if user_id is None: @@ -756,10 +722,9 @@ def get_target(self, user_id, target_id): 'content-type': 'application/json', }, api_params) - def update_target(self, user_id, target_id, identifier = None, provider_id = None, name = None): + def update_target(self, user_id: str, target_id: str, identifier: str = None, provider_id: str = None, name: str = None): """Update user target""" - api_path = '/users/{userId}/targets/{targetId}' api_params = {} if user_id is None: @@ -779,10 +744,9 @@ def update_target(self, user_id, target_id, identifier = None, provider_id = Non 'content-type': 'application/json', }, api_params) - def delete_target(self, user_id, target_id): + def delete_target(self, user_id: str, target_id: str): """Delete user target""" - api_path = '/users/{userId}/targets/{targetId}' api_params = {} if user_id is None: @@ -799,10 +763,9 @@ def delete_target(self, user_id, target_id): 'content-type': 'application/json', }, api_params) - def create_token(self, user_id, length = None, expire = None): + def create_token(self, user_id: str, length: float = None, expire: float = None): """Create token""" - api_path = '/users/{userId}/tokens' api_params = {} if user_id is None: @@ -817,10 +780,9 @@ def create_token(self, user_id, length = None, expire = None): 'content-type': 'application/json', }, api_params) - def update_email_verification(self, user_id, email_verification): + def update_email_verification(self, user_id: str, email_verification: bool): """Update email verification""" - api_path = '/users/{userId}/verification' api_params = {} if user_id is None: @@ -837,10 +799,9 @@ def update_email_verification(self, user_id, email_verification): 'content-type': 'application/json', }, api_params) - def update_phone_verification(self, user_id, phone_verification): + def update_phone_verification(self, user_id: str, phone_verification: bool): """Update phone verification""" - api_path = '/users/{userId}/verification/phone' api_params = {} if user_id is None: diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index 8f8a35a..d16b9bb 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -13,8 +13,8 @@ result = databases.update_float_attribute( collection_id = '', key = '', required = False, - min = None, - max = None, default = None, + min = None, # optional + max = None, # optional new_key = '' # optional ) diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index 125cf82..ab0ccd6 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -13,8 +13,8 @@ result = databases.update_integer_attribute( collection_id = '', key = '', required = False, - min = None, - max = None, default = None, + min = None, # optional + max = None, # optional new_key = '' # optional ) diff --git a/docs/examples/health/get-queue-usage-dump.md b/docs/examples/health/get-queue-stats-resources.md similarity index 88% rename from docs/examples/health/get-queue-usage-dump.md rename to docs/examples/health/get-queue-stats-resources.md index dabb79a..3b09342 100644 --- a/docs/examples/health/get-queue-usage-dump.md +++ b/docs/examples/health/get-queue-stats-resources.md @@ -8,6 +8,6 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_usage_dump( +result = health.get_queue_stats_resources( threshold = None # optional ) diff --git a/docs/examples/health/get-queue.md b/docs/examples/health/get-queue-stats-usage-dump.md similarity index 79% rename from docs/examples/health/get-queue.md rename to docs/examples/health/get-queue-stats-usage-dump.md index aafe7c7..c58059e 100644 --- a/docs/examples/health/get-queue.md +++ b/docs/examples/health/get-queue-stats-usage-dump.md @@ -8,4 +8,6 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue() +result = health.get_queue_stats_usage_dump( + threshold = None # optional +) diff --git a/setup.py b/setup.py index 558311d..40bc73f 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'appwrite/encoders', 'appwrite/enums', ], - version = '8.0.0' + version = '9.0.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -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/8.0.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/9.0.0.tar.gz', install_requires=[ 'requests', ],