From daebd114871e6f43c38d916bbd6facf17948e175 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 7 Mar 2026 03:55:12 +0000 Subject: [PATCH 1/6] feat: update Python SDK to 15.3.0 * Added `ActivityEvent` and `ActivityEventList` models to the public API * Updated README with `uv add appwrite` example --- CHANGELOG.md | 7 +- README.md | 6 + appwrite/encoders/value_class_encoder.py | 6 +- appwrite/models/__init__.py | 283 +++ appwrite/models/activity_event.py | 109 ++ appwrite/models/activity_event_list.py | 20 + appwrite/models/algo_argon2.py | 25 + appwrite/models/algo_bcrypt.py | 16 + appwrite/models/algo_md5.py | 16 + appwrite/models/algo_phpass.py | 16 + appwrite/models/algo_scrypt.py | 28 + appwrite/models/algo_scrypt_modified.py | 25 + appwrite/models/algo_sha.py | 16 + appwrite/models/attribute_boolean.py | 41 + appwrite/models/attribute_datetime.py | 44 + appwrite/models/attribute_email.py | 44 + appwrite/models/attribute_enum.py | 47 + appwrite/models/attribute_float.py | 47 + appwrite/models/attribute_integer.py | 47 + appwrite/models/attribute_ip.py | 44 + appwrite/models/attribute_line.py | 41 + appwrite/models/attribute_list.py | 36 + appwrite/models/attribute_longtext.py | 44 + appwrite/models/attribute_mediumtext.py | 44 + appwrite/models/attribute_point.py | 41 + appwrite/models/attribute_polygon.py | 41 + appwrite/models/attribute_relationship.py | 56 + appwrite/models/attribute_string.py | 47 + appwrite/models/attribute_text.py | 44 + appwrite/models/attribute_url.py | 44 + appwrite/models/attribute_varchar.py | 47 + appwrite/models/backup_archive.py | 49 + appwrite/models/backup_archive_list.py | 20 + appwrite/models/backup_policy.py | 46 + appwrite/models/backup_policy_list.py | 20 + appwrite/models/backup_restoration.py | 46 + appwrite/models/backup_restoration_list.py | 20 + appwrite/models/base_model.py | 27 + appwrite/models/bucket.py | 55 + appwrite/models/bucket_list.py | 20 + appwrite/models/collection.py | 67 + appwrite/models/collection_list.py | 20 + appwrite/models/column_boolean.py | 41 + appwrite/models/column_datetime.py | 44 + appwrite/models/column_email.py | 44 + appwrite/models/column_enum.py | 47 + appwrite/models/column_float.py | 47 + appwrite/models/column_index.py | 43 + appwrite/models/column_index_list.py | 20 + appwrite/models/column_integer.py | 47 + appwrite/models/column_ip.py | 44 + appwrite/models/column_line.py | 41 + appwrite/models/column_list.py | 36 + appwrite/models/column_longtext.py | 44 + appwrite/models/column_mediumtext.py | 44 + appwrite/models/column_point.py | 41 + appwrite/models/column_polygon.py | 41 + appwrite/models/column_relationship.py | 56 + appwrite/models/column_string.py | 47 + appwrite/models/column_text.py | 44 + appwrite/models/column_url.py | 44 + appwrite/models/column_varchar.py | 47 + appwrite/models/continent.py | 19 + appwrite/models/continent_list.py | 20 + appwrite/models/country.py | 19 + appwrite/models/country_list.py | 20 + appwrite/models/currency.py | 34 + appwrite/models/currency_list.py | 20 + appwrite/models/database.py | 40 + appwrite/models/database_list.py | 20 + appwrite/models/deployment.py | 95 + appwrite/models/deployment_list.py | 20 + appwrite/models/document.py | 34 + appwrite/models/document_list.py | 20 + appwrite/models/execution.py | 70 + appwrite/models/execution_list.py | 20 + appwrite/models/file.py | 52 + appwrite/models/file_list.py | 20 + appwrite/models/framework.py | 29 + appwrite/models/framework_adapter.py | 28 + appwrite/models/framework_list.py | 20 + appwrite/models/function.py | 98 + appwrite/models/function_list.py | 20 + appwrite/models/headers.py | 19 + appwrite/models/health_antivirus.py | 20 + appwrite/models/health_certificate.py | 31 + appwrite/models/health_queue.py | 16 + appwrite/models/health_status.py | 23 + appwrite/models/health_status_list.py | 20 + appwrite/models/health_time.py | 22 + appwrite/models/identity.py | 43 + appwrite/models/identity_list.py | 20 + appwrite/models/index.py | 44 + appwrite/models/index_list.py | 20 + appwrite/models/jwt.py | 16 + appwrite/models/language.py | 22 + appwrite/models/language_list.py | 20 + appwrite/models/locale.py | 34 + appwrite/models/locale_code.py | 19 + appwrite/models/locale_code_list.py | 20 + appwrite/models/log.py | 76 + appwrite/models/log_list.py | 20 + appwrite/models/membership.py | 52 + appwrite/models/membership_list.py | 20 + appwrite/models/message.py | 53 + appwrite/models/message_list.py | 20 + appwrite/models/mfa_challenge.py | 25 + appwrite/models/mfa_factors.py | 25 + appwrite/models/mfa_recovery_codes.py | 16 + appwrite/models/mfa_type.py | 19 + appwrite/models/phone.py | 22 + appwrite/models/phone_list.py | 20 + appwrite/models/preferences.py | 11 + appwrite/models/provider.py | 40 + appwrite/models/provider_list.py | 20 + appwrite/models/resource_token.py | 34 + appwrite/models/resource_token_list.py | 20 + appwrite/models/row.py | 34 + appwrite/models/row_list.py | 20 + appwrite/models/runtime.py | 37 + appwrite/models/runtime_list.py | 20 + appwrite/models/session.py | 100 + appwrite/models/session_list.py | 20 + appwrite/models/site.py | 101 ++ appwrite/models/site_list.py | 20 + appwrite/models/specification.py | 25 + appwrite/models/specification_list.py | 20 + appwrite/models/subscriber.py | 41 + appwrite/models/subscriber_list.py | 20 + appwrite/models/table.py | 67 + appwrite/models/table_list.py | 20 + appwrite/models/target.py | 40 + appwrite/models/target_list.py | 20 + appwrite/models/team.py | 32 + appwrite/models/team_list.py | 20 + appwrite/models/token.py | 31 + appwrite/models/topic.py | 37 + appwrite/models/topic_list.py | 20 + appwrite/models/transaction.py | 31 + appwrite/models/transaction_list.py | 20 + appwrite/models/user.py | 79 + appwrite/models/user_list.py | 20 + appwrite/models/variable.py | 37 + appwrite/models/variable_list.py | 20 + appwrite/service.py | 55 + appwrite/services/account.py | 725 +++++--- appwrite/services/activities.py | 34 +- appwrite/services/avatars.py | 200 +- appwrite/services/backups.py | 222 ++- appwrite/services/databases.py | 1914 +++++++++++++------- appwrite/services/functions.py | 616 +++++-- appwrite/services/graphql.py | 28 +- appwrite/services/health.py | 428 +++-- appwrite/services/locale.py | 105 +- appwrite/services/messaging.py | 1449 ++++++++++----- appwrite/services/sites.py | 581 ++++-- appwrite/services/storage.py | 332 ++-- appwrite/services/tables_db.py | 1914 +++++++++++++------- appwrite/services/teams.py | 262 ++- appwrite/services/tokens.py | 93 +- appwrite/services/users.py | 843 ++++++--- pyproject.toml | 40 + requirements.txt | 3 +- setup.py | 10 +- 164 files changed, 11861 insertions(+), 3189 deletions(-) create mode 100644 appwrite/models/__init__.py create mode 100644 appwrite/models/activity_event.py create mode 100644 appwrite/models/activity_event_list.py create mode 100644 appwrite/models/algo_argon2.py create mode 100644 appwrite/models/algo_bcrypt.py create mode 100644 appwrite/models/algo_md5.py create mode 100644 appwrite/models/algo_phpass.py create mode 100644 appwrite/models/algo_scrypt.py create mode 100644 appwrite/models/algo_scrypt_modified.py create mode 100644 appwrite/models/algo_sha.py create mode 100644 appwrite/models/attribute_boolean.py create mode 100644 appwrite/models/attribute_datetime.py create mode 100644 appwrite/models/attribute_email.py create mode 100644 appwrite/models/attribute_enum.py create mode 100644 appwrite/models/attribute_float.py create mode 100644 appwrite/models/attribute_integer.py create mode 100644 appwrite/models/attribute_ip.py create mode 100644 appwrite/models/attribute_line.py create mode 100644 appwrite/models/attribute_list.py create mode 100644 appwrite/models/attribute_longtext.py create mode 100644 appwrite/models/attribute_mediumtext.py create mode 100644 appwrite/models/attribute_point.py create mode 100644 appwrite/models/attribute_polygon.py create mode 100644 appwrite/models/attribute_relationship.py create mode 100644 appwrite/models/attribute_string.py create mode 100644 appwrite/models/attribute_text.py create mode 100644 appwrite/models/attribute_url.py create mode 100644 appwrite/models/attribute_varchar.py create mode 100644 appwrite/models/backup_archive.py create mode 100644 appwrite/models/backup_archive_list.py create mode 100644 appwrite/models/backup_policy.py create mode 100644 appwrite/models/backup_policy_list.py create mode 100644 appwrite/models/backup_restoration.py create mode 100644 appwrite/models/backup_restoration_list.py create mode 100644 appwrite/models/base_model.py create mode 100644 appwrite/models/bucket.py create mode 100644 appwrite/models/bucket_list.py create mode 100644 appwrite/models/collection.py create mode 100644 appwrite/models/collection_list.py create mode 100644 appwrite/models/column_boolean.py create mode 100644 appwrite/models/column_datetime.py create mode 100644 appwrite/models/column_email.py create mode 100644 appwrite/models/column_enum.py create mode 100644 appwrite/models/column_float.py create mode 100644 appwrite/models/column_index.py create mode 100644 appwrite/models/column_index_list.py create mode 100644 appwrite/models/column_integer.py create mode 100644 appwrite/models/column_ip.py create mode 100644 appwrite/models/column_line.py create mode 100644 appwrite/models/column_list.py create mode 100644 appwrite/models/column_longtext.py create mode 100644 appwrite/models/column_mediumtext.py create mode 100644 appwrite/models/column_point.py create mode 100644 appwrite/models/column_polygon.py create mode 100644 appwrite/models/column_relationship.py create mode 100644 appwrite/models/column_string.py create mode 100644 appwrite/models/column_text.py create mode 100644 appwrite/models/column_url.py create mode 100644 appwrite/models/column_varchar.py create mode 100644 appwrite/models/continent.py create mode 100644 appwrite/models/continent_list.py create mode 100644 appwrite/models/country.py create mode 100644 appwrite/models/country_list.py create mode 100644 appwrite/models/currency.py create mode 100644 appwrite/models/currency_list.py create mode 100644 appwrite/models/database.py create mode 100644 appwrite/models/database_list.py create mode 100644 appwrite/models/deployment.py create mode 100644 appwrite/models/deployment_list.py create mode 100644 appwrite/models/document.py create mode 100644 appwrite/models/document_list.py create mode 100644 appwrite/models/execution.py create mode 100644 appwrite/models/execution_list.py create mode 100644 appwrite/models/file.py create mode 100644 appwrite/models/file_list.py create mode 100644 appwrite/models/framework.py create mode 100644 appwrite/models/framework_adapter.py create mode 100644 appwrite/models/framework_list.py create mode 100644 appwrite/models/function.py create mode 100644 appwrite/models/function_list.py create mode 100644 appwrite/models/headers.py create mode 100644 appwrite/models/health_antivirus.py create mode 100644 appwrite/models/health_certificate.py create mode 100644 appwrite/models/health_queue.py create mode 100644 appwrite/models/health_status.py create mode 100644 appwrite/models/health_status_list.py create mode 100644 appwrite/models/health_time.py create mode 100644 appwrite/models/identity.py create mode 100644 appwrite/models/identity_list.py create mode 100644 appwrite/models/index.py create mode 100644 appwrite/models/index_list.py create mode 100644 appwrite/models/jwt.py create mode 100644 appwrite/models/language.py create mode 100644 appwrite/models/language_list.py create mode 100644 appwrite/models/locale.py create mode 100644 appwrite/models/locale_code.py create mode 100644 appwrite/models/locale_code_list.py create mode 100644 appwrite/models/log.py create mode 100644 appwrite/models/log_list.py create mode 100644 appwrite/models/membership.py create mode 100644 appwrite/models/membership_list.py create mode 100644 appwrite/models/message.py create mode 100644 appwrite/models/message_list.py create mode 100644 appwrite/models/mfa_challenge.py create mode 100644 appwrite/models/mfa_factors.py create mode 100644 appwrite/models/mfa_recovery_codes.py create mode 100644 appwrite/models/mfa_type.py create mode 100644 appwrite/models/phone.py create mode 100644 appwrite/models/phone_list.py create mode 100644 appwrite/models/preferences.py create mode 100644 appwrite/models/provider.py create mode 100644 appwrite/models/provider_list.py create mode 100644 appwrite/models/resource_token.py create mode 100644 appwrite/models/resource_token_list.py create mode 100644 appwrite/models/row.py create mode 100644 appwrite/models/row_list.py create mode 100644 appwrite/models/runtime.py create mode 100644 appwrite/models/runtime_list.py create mode 100644 appwrite/models/session.py create mode 100644 appwrite/models/session_list.py create mode 100644 appwrite/models/site.py create mode 100644 appwrite/models/site_list.py create mode 100644 appwrite/models/specification.py create mode 100644 appwrite/models/specification_list.py create mode 100644 appwrite/models/subscriber.py create mode 100644 appwrite/models/subscriber_list.py create mode 100644 appwrite/models/table.py create mode 100644 appwrite/models/table_list.py create mode 100644 appwrite/models/target.py create mode 100644 appwrite/models/target_list.py create mode 100644 appwrite/models/team.py create mode 100644 appwrite/models/team_list.py create mode 100644 appwrite/models/token.py create mode 100644 appwrite/models/topic.py create mode 100644 appwrite/models/topic_list.py create mode 100644 appwrite/models/transaction.py create mode 100644 appwrite/models/transaction_list.py create mode 100644 appwrite/models/user.py create mode 100644 appwrite/models/user_list.py create mode 100644 appwrite/models/variable.py create mode 100644 appwrite/models/variable_list.py create mode 100644 pyproject.toml diff --git a/CHANGELOG.md b/CHANGELOG.md index fcd422a..fb17fd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,8 @@ ## 15.3.0 -* Added get_console_pausing health endpoint -* Added ttl parameter to list_documents and list_rows for cached responses -* Added optional activate parameter to Sites.create_deployment -* Updated docs and examples to reflect TTL usage and activation -* Updated query filtering docs in Messaging service +* Added `ActivityEvent` and `ActivityEventList` models to the public API +* Updated README with `uv add appwrite` example ## 15.2.0 diff --git a/README.md b/README.md index 4693d74..b221018 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,12 @@ To install via [PyPI](https://pypi.org/): pip install appwrite ``` +Or with `uv`: + +```bash +uv add appwrite +``` + ## Getting Started diff --git a/appwrite/encoders/value_class_encoder.py b/appwrite/encoders/value_class_encoder.py index 8efe2b3..4b83e25 100644 --- a/appwrite/encoders/value_class_encoder.py +++ b/appwrite/encoders/value_class_encoder.py @@ -1,4 +1,5 @@ import json +from ..models.base_model import AppwriteModel from ..enums.authenticator_type import AuthenticatorType from ..enums.authentication_factor import AuthenticationFactor from ..enums.o_auth_provider import OAuthProvider @@ -43,6 +44,9 @@ class ValueClassEncoder(json.JSONEncoder): def default(self, o): + if isinstance(o, AppwriteModel): + return o.to_dict() + if isinstance(o, AuthenticatorType): return o.value @@ -166,4 +170,4 @@ def default(self, o): if isinstance(o, MessageStatus): return o.value - return super().default(o) \ No newline at end of file + return super().default(o) diff --git a/appwrite/models/__init__.py b/appwrite/models/__init__.py new file mode 100644 index 0000000..630e17d --- /dev/null +++ b/appwrite/models/__init__.py @@ -0,0 +1,283 @@ +from .base_model import AppwriteModel +from .row_list import RowList +from .document_list import DocumentList +from .table_list import TableList +from .collection_list import CollectionList +from .database_list import DatabaseList +from .index_list import IndexList +from .column_index_list import ColumnIndexList +from .user_list import UserList +from .session_list import SessionList +from .identity_list import IdentityList +from .log_list import LogList +from .file_list import FileList +from .bucket_list import BucketList +from .resource_token_list import ResourceTokenList +from .team_list import TeamList +from .membership_list import MembershipList +from .site_list import SiteList +from .function_list import FunctionList +from .framework_list import FrameworkList +from .runtime_list import RuntimeList +from .deployment_list import DeploymentList +from .execution_list import ExecutionList +from .country_list import CountryList +from .continent_list import ContinentList +from .language_list import LanguageList +from .currency_list import CurrencyList +from .phone_list import PhoneList +from .variable_list import VariableList +from .health_status_list import HealthStatusList +from .locale_code_list import LocaleCodeList +from .provider_list import ProviderList +from .message_list import MessageList +from .topic_list import TopicList +from .subscriber_list import SubscriberList +from .target_list import TargetList +from .transaction_list import TransactionList +from .specification_list import SpecificationList +from .database import Database +from .collection import Collection +from .attribute_list import AttributeList +from .attribute_string import AttributeString +from .attribute_integer import AttributeInteger +from .attribute_float import AttributeFloat +from .attribute_boolean import AttributeBoolean +from .attribute_email import AttributeEmail +from .attribute_enum import AttributeEnum +from .attribute_ip import AttributeIp +from .attribute_url import AttributeUrl +from .attribute_datetime import AttributeDatetime +from .attribute_relationship import AttributeRelationship +from .attribute_point import AttributePoint +from .attribute_line import AttributeLine +from .attribute_polygon import AttributePolygon +from .attribute_varchar import AttributeVarchar +from .attribute_text import AttributeText +from .attribute_mediumtext import AttributeMediumtext +from .attribute_longtext import AttributeLongtext +from .table import Table +from .column_list import ColumnList +from .column_string import ColumnString +from .column_integer import ColumnInteger +from .column_float import ColumnFloat +from .column_boolean import ColumnBoolean +from .column_email import ColumnEmail +from .column_enum import ColumnEnum +from .column_ip import ColumnIp +from .column_url import ColumnUrl +from .column_datetime import ColumnDatetime +from .column_relationship import ColumnRelationship +from .column_point import ColumnPoint +from .column_line import ColumnLine +from .column_polygon import ColumnPolygon +from .column_varchar import ColumnVarchar +from .column_text import ColumnText +from .column_mediumtext import ColumnMediumtext +from .column_longtext import ColumnLongtext +from .index import Index +from .column_index import ColumnIndex +from .row import Row +from .document import Document +from .log import Log +from .user import User +from .algo_md5 import AlgoMd5 +from .algo_sha import AlgoSha +from .algo_phpass import AlgoPhpass +from .algo_bcrypt import AlgoBcrypt +from .algo_scrypt import AlgoScrypt +from .algo_scrypt_modified import AlgoScryptModified +from .algo_argon2 import AlgoArgon2 +from .preferences import Preferences +from .session import Session +from .identity import Identity +from .token import Token +from .jwt import Jwt +from .locale import Locale +from .locale_code import LocaleCode +from .file import File +from .bucket import Bucket +from .resource_token import ResourceToken +from .team import Team +from .membership import Membership +from .site import Site +from .function import Function +from .runtime import Runtime +from .framework import Framework +from .framework_adapter import FrameworkAdapter +from .deployment import Deployment +from .execution import Execution +from .variable import Variable +from .country import Country +from .continent import Continent +from .language import Language +from .currency import Currency +from .phone import Phone +from .health_antivirus import HealthAntivirus +from .health_queue import HealthQueue +from .health_status import HealthStatus +from .health_certificate import HealthCertificate +from .health_time import HealthTime +from .headers import Headers +from .specification import Specification +from .mfa_challenge import MfaChallenge +from .mfa_recovery_codes import MfaRecoveryCodes +from .mfa_type import MfaType +from .mfa_factors import MfaFactors +from .provider import Provider +from .message import Message +from .topic import Topic +from .transaction import Transaction +from .subscriber import Subscriber +from .target import Target +from .activity_event import ActivityEvent +from .backup_archive import BackupArchive +from .backup_policy import BackupPolicy +from .backup_restoration import BackupRestoration +from .activity_event_list import ActivityEventList +from .backup_archive_list import BackupArchiveList +from .backup_policy_list import BackupPolicyList +from .backup_restoration_list import BackupRestorationList + +__all__ = [ + 'AppwriteModel', + 'RowList', + 'DocumentList', + 'TableList', + 'CollectionList', + 'DatabaseList', + 'IndexList', + 'ColumnIndexList', + 'UserList', + 'SessionList', + 'IdentityList', + 'LogList', + 'FileList', + 'BucketList', + 'ResourceTokenList', + 'TeamList', + 'MembershipList', + 'SiteList', + 'FunctionList', + 'FrameworkList', + 'RuntimeList', + 'DeploymentList', + 'ExecutionList', + 'CountryList', + 'ContinentList', + 'LanguageList', + 'CurrencyList', + 'PhoneList', + 'VariableList', + 'HealthStatusList', + 'LocaleCodeList', + 'ProviderList', + 'MessageList', + 'TopicList', + 'SubscriberList', + 'TargetList', + 'TransactionList', + 'SpecificationList', + 'Database', + 'Collection', + 'AttributeList', + 'AttributeString', + 'AttributeInteger', + 'AttributeFloat', + 'AttributeBoolean', + 'AttributeEmail', + 'AttributeEnum', + 'AttributeIp', + 'AttributeUrl', + 'AttributeDatetime', + 'AttributeRelationship', + 'AttributePoint', + 'AttributeLine', + 'AttributePolygon', + 'AttributeVarchar', + 'AttributeText', + 'AttributeMediumtext', + 'AttributeLongtext', + 'Table', + 'ColumnList', + 'ColumnString', + 'ColumnInteger', + 'ColumnFloat', + 'ColumnBoolean', + 'ColumnEmail', + 'ColumnEnum', + 'ColumnIp', + 'ColumnUrl', + 'ColumnDatetime', + 'ColumnRelationship', + 'ColumnPoint', + 'ColumnLine', + 'ColumnPolygon', + 'ColumnVarchar', + 'ColumnText', + 'ColumnMediumtext', + 'ColumnLongtext', + 'Index', + 'ColumnIndex', + 'Row', + 'Document', + 'Log', + 'User', + 'AlgoMd5', + 'AlgoSha', + 'AlgoPhpass', + 'AlgoBcrypt', + 'AlgoScrypt', + 'AlgoScryptModified', + 'AlgoArgon2', + 'Preferences', + 'Session', + 'Identity', + 'Token', + 'Jwt', + 'Locale', + 'LocaleCode', + 'File', + 'Bucket', + 'ResourceToken', + 'Team', + 'Membership', + 'Site', + 'Function', + 'Runtime', + 'Framework', + 'FrameworkAdapter', + 'Deployment', + 'Execution', + 'Variable', + 'Country', + 'Continent', + 'Language', + 'Currency', + 'Phone', + 'HealthAntivirus', + 'HealthQueue', + 'HealthStatus', + 'HealthCertificate', + 'HealthTime', + 'Headers', + 'Specification', + 'MfaChallenge', + 'MfaRecoveryCodes', + 'MfaType', + 'MfaFactors', + 'Provider', + 'Message', + 'Topic', + 'Transaction', + 'Subscriber', + 'Target', + 'ActivityEvent', + 'BackupArchive', + 'BackupPolicy', + 'BackupRestoration', + 'ActivityEventList', + 'BackupArchiveList', + 'BackupPolicyList', + 'BackupRestorationList', +] diff --git a/appwrite/models/activity_event.py b/appwrite/models/activity_event.py new file mode 100644 index 0000000..030503b --- /dev/null +++ b/appwrite/models/activity_event.py @@ -0,0 +1,109 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class ActivityEvent(AppwriteModel): + """ + ActivityEvent + + Attributes + ---------- + id : str + Event ID. + usertype : str + User type. + userid : str + User ID. + useremail : str + User Email. + username : str + User Name. + resourceparent : str + Resource parent. + resourcetype : str + Resource type. + resourceid : str + Resource ID. + resource : str + Resource. + event : str + Event name. + useragent : str + User agent. + ip : str + IP address. + mode : str + API mode when event triggered. + country : str + Location. + time : str + Log creation date in ISO 8601 format. + projectid : str + Project ID. + teamid : str + Team ID. + hostname : str + Hostname. + oscode : str + Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + osname : str + Operating system name. + osversion : str + Operating system version. + clienttype : str + Client type. + clientcode : str + Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + clientname : str + Client name. + clientversion : str + Client version. + clientengine : str + Client engine name. + clientengineversion : str + Client engine name. + devicename : str + Device name. + devicebrand : str + Device brand name. + devicemodel : str + Device model name. + countrycode : str + Country two-character ISO 3166-1 alpha code. + countryname : str + Country name. + """ + id: str = Field(..., alias='$id') + usertype: str = Field(..., alias='userType') + userid: str = Field(..., alias='userId') + useremail: str = Field(..., alias='userEmail') + username: str = Field(..., alias='userName') + resourceparent: str = Field(..., alias='resourceParent') + resourcetype: str = Field(..., alias='resourceType') + resourceid: str = Field(..., alias='resourceId') + resource: str = Field(..., alias='resource') + event: str = Field(..., alias='event') + useragent: str = Field(..., alias='userAgent') + ip: str = Field(..., alias='ip') + mode: str = Field(..., alias='mode') + country: str = Field(..., alias='country') + time: str = Field(..., alias='time') + projectid: str = Field(..., alias='projectId') + teamid: str = Field(..., alias='teamId') + hostname: str = Field(..., alias='hostname') + oscode: str = Field(..., alias='osCode') + osname: str = Field(..., alias='osName') + osversion: str = Field(..., alias='osVersion') + clienttype: str = Field(..., alias='clientType') + clientcode: str = Field(..., alias='clientCode') + clientname: str = Field(..., alias='clientName') + clientversion: str = Field(..., alias='clientVersion') + clientengine: str = Field(..., alias='clientEngine') + clientengineversion: str = Field(..., alias='clientEngineVersion') + devicename: str = Field(..., alias='deviceName') + devicebrand: str = Field(..., alias='deviceBrand') + devicemodel: str = Field(..., alias='deviceModel') + countrycode: str = Field(..., alias='countryCode') + countryname: str = Field(..., alias='countryName') diff --git a/appwrite/models/activity_event_list.py b/appwrite/models/activity_event_list.py new file mode 100644 index 0000000..70ca316 --- /dev/null +++ b/appwrite/models/activity_event_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .activity_event import ActivityEvent + +class ActivityEventList(AppwriteModel): + """ + Activity event list + + Attributes + ---------- + total : float + Total number of events that matched your query. + events : List[ActivityEvent] + List of events. + """ + total: float = Field(..., alias='total') + events: List[ActivityEvent] = Field(..., alias='events') diff --git a/appwrite/models/algo_argon2.py b/appwrite/models/algo_argon2.py new file mode 100644 index 0000000..af06717 --- /dev/null +++ b/appwrite/models/algo_argon2.py @@ -0,0 +1,25 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class AlgoArgon2(AppwriteModel): + """ + AlgoArgon2 + + Attributes + ---------- + type : str + Algo type. + memorycost : float + Memory used to compute hash. + timecost : float + Amount of time consumed to compute hash + threads : float + Number of threads used to compute hash. + """ + type: str = Field(..., alias='type') + memorycost: float = Field(..., alias='memoryCost') + timecost: float = Field(..., alias='timeCost') + threads: float = Field(..., alias='threads') diff --git a/appwrite/models/algo_bcrypt.py b/appwrite/models/algo_bcrypt.py new file mode 100644 index 0000000..fcd2b56 --- /dev/null +++ b/appwrite/models/algo_bcrypt.py @@ -0,0 +1,16 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class AlgoBcrypt(AppwriteModel): + """ + AlgoBcrypt + + Attributes + ---------- + type : str + Algo type. + """ + type: str = Field(..., alias='type') diff --git a/appwrite/models/algo_md5.py b/appwrite/models/algo_md5.py new file mode 100644 index 0000000..f90a07d --- /dev/null +++ b/appwrite/models/algo_md5.py @@ -0,0 +1,16 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class AlgoMd5(AppwriteModel): + """ + AlgoMD5 + + Attributes + ---------- + type : str + Algo type. + """ + type: str = Field(..., alias='type') diff --git a/appwrite/models/algo_phpass.py b/appwrite/models/algo_phpass.py new file mode 100644 index 0000000..86a323e --- /dev/null +++ b/appwrite/models/algo_phpass.py @@ -0,0 +1,16 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class AlgoPhpass(AppwriteModel): + """ + AlgoPHPass + + Attributes + ---------- + type : str + Algo type. + """ + type: str = Field(..., alias='type') diff --git a/appwrite/models/algo_scrypt.py b/appwrite/models/algo_scrypt.py new file mode 100644 index 0000000..17285ed --- /dev/null +++ b/appwrite/models/algo_scrypt.py @@ -0,0 +1,28 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class AlgoScrypt(AppwriteModel): + """ + AlgoScrypt + + Attributes + ---------- + type : str + Algo type. + costcpu : float + CPU complexity of computed hash. + costmemory : float + Memory complexity of computed hash. + costparallel : float + Parallelization of computed hash. + length : float + Length used to compute hash. + """ + type: str = Field(..., alias='type') + costcpu: float = Field(..., alias='costCpu') + costmemory: float = Field(..., alias='costMemory') + costparallel: float = Field(..., alias='costParallel') + length: float = Field(..., alias='length') diff --git a/appwrite/models/algo_scrypt_modified.py b/appwrite/models/algo_scrypt_modified.py new file mode 100644 index 0000000..c2809a2 --- /dev/null +++ b/appwrite/models/algo_scrypt_modified.py @@ -0,0 +1,25 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class AlgoScryptModified(AppwriteModel): + """ + AlgoScryptModified + + Attributes + ---------- + type : str + Algo type. + salt : str + Salt used to compute hash. + saltseparator : str + Separator used to compute hash. + signerkey : str + Key used to compute hash. + """ + type: str = Field(..., alias='type') + salt: str = Field(..., alias='salt') + saltseparator: str = Field(..., alias='saltSeparator') + signerkey: str = Field(..., alias='signerKey') diff --git a/appwrite/models/algo_sha.py b/appwrite/models/algo_sha.py new file mode 100644 index 0000000..bf8b6ea --- /dev/null +++ b/appwrite/models/algo_sha.py @@ -0,0 +1,16 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class AlgoSha(AppwriteModel): + """ + AlgoSHA + + Attributes + ---------- + type : str + Algo type. + """ + type: str = Field(..., alias='type') diff --git a/appwrite/models/attribute_boolean.py b/appwrite/models/attribute_boolean.py new file mode 100644 index 0000000..016b120 --- /dev/null +++ b/appwrite/models/attribute_boolean.py @@ -0,0 +1,41 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeBoolean(AppwriteModel): + """ + AttributeBoolean + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + default : Optional[bool] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[bool] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_datetime.py b/appwrite/models/attribute_datetime.py new file mode 100644 index 0000000..4dadf7b --- /dev/null +++ b/appwrite/models/attribute_datetime.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeDatetime(AppwriteModel): + """ + AttributeDatetime + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + format : str + ISO 8601 format. + default : Optional[str] + Default value for attribute when not provided. Only null is optional + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_email.py b/appwrite/models/attribute_email.py new file mode 100644 index 0000000..a7d80e0 --- /dev/null +++ b/appwrite/models/attribute_email.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeEmail(AppwriteModel): + """ + AttributeEmail + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + format : str + String format. + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_enum.py b/appwrite/models/attribute_enum.py new file mode 100644 index 0000000..ce088a4 --- /dev/null +++ b/appwrite/models/attribute_enum.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeEnum(AppwriteModel): + """ + AttributeEnum + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + elements : List[Any] + Array of elements in enumerated type. + format : str + String format. + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + elements: List[Any] = Field(..., alias='elements') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_float.py b/appwrite/models/attribute_float.py new file mode 100644 index 0000000..b0bdc39 --- /dev/null +++ b/appwrite/models/attribute_float.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeFloat(AppwriteModel): + """ + AttributeFloat + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + min : Optional[float] + Minimum value to enforce for new documents. + max : Optional[float] + Maximum value to enforce for new documents. + default : Optional[float] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + min: Optional[float] = Field(default=None, alias='min') + max: Optional[float] = Field(default=None, alias='max') + default: Optional[float] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_integer.py b/appwrite/models/attribute_integer.py new file mode 100644 index 0000000..da51a5d --- /dev/null +++ b/appwrite/models/attribute_integer.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeInteger(AppwriteModel): + """ + AttributeInteger + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + min : Optional[float] + Minimum value to enforce for new documents. + max : Optional[float] + Maximum value to enforce for new documents. + default : Optional[float] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + min: Optional[float] = Field(default=None, alias='min') + max: Optional[float] = Field(default=None, alias='max') + default: Optional[float] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_ip.py b/appwrite/models/attribute_ip.py new file mode 100644 index 0000000..6823e8c --- /dev/null +++ b/appwrite/models/attribute_ip.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeIp(AppwriteModel): + """ + AttributeIP + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + format : str + String format. + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_line.py b/appwrite/models/attribute_line.py new file mode 100644 index 0000000..67500a2 --- /dev/null +++ b/appwrite/models/attribute_line.py @@ -0,0 +1,41 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeLine(AppwriteModel): + """ + AttributeLine + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + default : Optional[List[Any]] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[List[Any]] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_list.py b/appwrite/models/attribute_list.py new file mode 100644 index 0000000..38f1005 --- /dev/null +++ b/appwrite/models/attribute_list.py @@ -0,0 +1,36 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .attribute_boolean import AttributeBoolean +from .attribute_integer import AttributeInteger +from .attribute_float import AttributeFloat +from .attribute_email import AttributeEmail +from .attribute_enum import AttributeEnum +from .attribute_url import AttributeUrl +from .attribute_ip import AttributeIp +from .attribute_datetime import AttributeDatetime +from .attribute_relationship import AttributeRelationship +from .attribute_point import AttributePoint +from .attribute_line import AttributeLine +from .attribute_polygon import AttributePolygon +from .attribute_varchar import AttributeVarchar +from .attribute_text import AttributeText +from .attribute_mediumtext import AttributeMediumtext +from .attribute_longtext import AttributeLongtext +from .attribute_string import AttributeString + +class AttributeList(AppwriteModel): + """ + Attributes List + + Attributes + ---------- + total : float + Total number of attributes in the given collection. + attributes : List[Union[AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString]] + List of attributes. + """ + total: float = Field(..., alias='total') + attributes: List[Union[AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString]] = Field(..., alias='attributes') diff --git a/appwrite/models/attribute_longtext.py b/appwrite/models/attribute_longtext.py new file mode 100644 index 0000000..41412b8 --- /dev/null +++ b/appwrite/models/attribute_longtext.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeLongtext(AppwriteModel): + """ + AttributeLongtext + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + encrypt : Optional[bool] + Defines whether this attribute is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/attribute_mediumtext.py b/appwrite/models/attribute_mediumtext.py new file mode 100644 index 0000000..84dd00a --- /dev/null +++ b/appwrite/models/attribute_mediumtext.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeMediumtext(AppwriteModel): + """ + AttributeMediumtext + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + encrypt : Optional[bool] + Defines whether this attribute is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/attribute_point.py b/appwrite/models/attribute_point.py new file mode 100644 index 0000000..8a83bdb --- /dev/null +++ b/appwrite/models/attribute_point.py @@ -0,0 +1,41 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributePoint(AppwriteModel): + """ + AttributePoint + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + default : Optional[List[Any]] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[List[Any]] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_polygon.py b/appwrite/models/attribute_polygon.py new file mode 100644 index 0000000..842d181 --- /dev/null +++ b/appwrite/models/attribute_polygon.py @@ -0,0 +1,41 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributePolygon(AppwriteModel): + """ + AttributePolygon + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + default : Optional[List[Any]] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[List[Any]] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_relationship.py b/appwrite/models/attribute_relationship.py new file mode 100644 index 0000000..17a5119 --- /dev/null +++ b/appwrite/models/attribute_relationship.py @@ -0,0 +1,56 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeRelationship(AppwriteModel): + """ + AttributeRelationship + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + relatedcollection : str + The ID of the related collection. + relationtype : str + The type of the relationship. + twoway : bool + Is the relationship two-way? + twowaykey : str + The key of the two-way relationship. + ondelete : str + How deleting the parent document will propagate to child documents. + side : str + Whether this is the parent or child side of the relationship + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + relatedcollection: str = Field(..., alias='relatedCollection') + relationtype: str = Field(..., alias='relationType') + twoway: bool = Field(..., alias='twoWay') + twowaykey: str = Field(..., alias='twoWayKey') + ondelete: str = Field(..., alias='onDelete') + side: str = Field(..., alias='side') diff --git a/appwrite/models/attribute_string.py b/appwrite/models/attribute_string.py new file mode 100644 index 0000000..8ad77ab --- /dev/null +++ b/appwrite/models/attribute_string.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeString(AppwriteModel): + """ + AttributeString + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + size : float + Attribute size. + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + encrypt : Optional[bool] + Defines whether this attribute is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + size: float = Field(..., alias='size') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/attribute_text.py b/appwrite/models/attribute_text.py new file mode 100644 index 0000000..58a40ef --- /dev/null +++ b/appwrite/models/attribute_text.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeText(AppwriteModel): + """ + AttributeText + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + encrypt : Optional[bool] + Defines whether this attribute is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/attribute_url.py b/appwrite/models/attribute_url.py new file mode 100644 index 0000000..b7f0845 --- /dev/null +++ b/appwrite/models/attribute_url.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeUrl(AppwriteModel): + """ + AttributeURL + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + format : str + String format. + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/attribute_varchar.py b/appwrite/models/attribute_varchar.py new file mode 100644 index 0000000..c55edbe --- /dev/null +++ b/appwrite/models/attribute_varchar.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeVarchar(AppwriteModel): + """ + AttributeVarchar + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + size : float + Attribute size. + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + encrypt : Optional[bool] + Defines whether this attribute is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + size: float = Field(..., alias='size') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/backup_archive.py b/appwrite/models/backup_archive.py new file mode 100644 index 0000000..71c4164 --- /dev/null +++ b/appwrite/models/backup_archive.py @@ -0,0 +1,49 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class BackupArchive(AppwriteModel): + """ + Archive + + Attributes + ---------- + id : str + Archive ID. + createdat : str + Archive creation time in ISO 8601 format. + updatedat : str + Archive update date in ISO 8601 format. + policyid : str + Archive policy ID. + size : float + Archive size in bytes. + status : str + The status of the archive creation. Possible values: pending, processing, uploading, completed, failed. + startedat : str + The backup start time. + migrationid : str + Migration ID. + services : List[Any] + The services that are backed up by this archive. + resources : List[Any] + The resources that are backed up by this archive. + resourceid : Optional[str] + The resource ID to backup. Set only if this archive should backup a single resource. + resourcetype : Optional[str] + The resource type to backup. Set only if this archive should backup a single resource. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + policyid: str = Field(..., alias='policyId') + size: float = Field(..., alias='size') + status: str = Field(..., alias='status') + startedat: str = Field(..., alias='startedAt') + migrationid: str = Field(..., alias='migrationId') + services: List[Any] = Field(..., alias='services') + resources: List[Any] = Field(..., alias='resources') + resourceid: Optional[str] = Field(default=None, alias='resourceId') + resourcetype: Optional[str] = Field(default=None, alias='resourceType') diff --git a/appwrite/models/backup_archive_list.py b/appwrite/models/backup_archive_list.py new file mode 100644 index 0000000..7545bf9 --- /dev/null +++ b/appwrite/models/backup_archive_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .backup_archive import BackupArchive + +class BackupArchiveList(AppwriteModel): + """ + Backup archive list + + Attributes + ---------- + total : float + Total number of archives that matched your query. + archives : List[BackupArchive] + List of archives. + """ + total: float = Field(..., alias='total') + archives: List[BackupArchive] = Field(..., alias='archives') diff --git a/appwrite/models/backup_policy.py b/appwrite/models/backup_policy.py new file mode 100644 index 0000000..683df57 --- /dev/null +++ b/appwrite/models/backup_policy.py @@ -0,0 +1,46 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class BackupPolicy(AppwriteModel): + """ + backup + + Attributes + ---------- + id : str + Backup policy ID. + name : str + Backup policy name. + createdat : str + Policy creation date in ISO 8601 format. + updatedat : str + Policy update date in ISO 8601 format. + services : List[Any] + The services that are backed up by this policy. + resources : List[Any] + The resources that are backed up by this policy. + resourceid : Optional[str] + The resource ID to backup. Set only if this policy should backup a single resource. + resourcetype : Optional[str] + The resource type to backup. Set only if this policy should backup a single resource. + retention : float + How many days to keep the backup before it will be automatically deleted. + schedule : str + Policy backup schedule in CRON format. + enabled : bool + Is this policy enabled. + """ + id: str = Field(..., alias='$id') + name: str = Field(..., alias='name') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + services: List[Any] = Field(..., alias='services') + resources: List[Any] = Field(..., alias='resources') + resourceid: Optional[str] = Field(default=None, alias='resourceId') + resourcetype: Optional[str] = Field(default=None, alias='resourceType') + retention: float = Field(..., alias='retention') + schedule: str = Field(..., alias='schedule') + enabled: bool = Field(..., alias='enabled') diff --git a/appwrite/models/backup_policy_list.py b/appwrite/models/backup_policy_list.py new file mode 100644 index 0000000..8836bbc --- /dev/null +++ b/appwrite/models/backup_policy_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .backup_policy import BackupPolicy + +class BackupPolicyList(AppwriteModel): + """ + Backup policy list + + Attributes + ---------- + total : float + Total number of policies that matched your query. + policies : List[BackupPolicy] + List of policies. + """ + total: float = Field(..., alias='total') + policies: List[BackupPolicy] = Field(..., alias='policies') diff --git a/appwrite/models/backup_restoration.py b/appwrite/models/backup_restoration.py new file mode 100644 index 0000000..5b91042 --- /dev/null +++ b/appwrite/models/backup_restoration.py @@ -0,0 +1,46 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class BackupRestoration(AppwriteModel): + """ + Restoration + + Attributes + ---------- + id : str + Restoration ID. + createdat : str + Restoration creation time in ISO 8601 format. + updatedat : str + Restoration update date in ISO 8601 format. + archiveid : str + Backup archive ID. + policyid : str + Backup policy ID. + status : str + The status of the restoration. Possible values: pending, downloading, processing, completed, failed. + startedat : str + The backup start time. + migrationid : str + Migration ID. + services : List[Any] + The services that are backed up by this policy. + resources : List[Any] + The resources that are backed up by this policy. + options : str + Optional data in key-value object. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + archiveid: str = Field(..., alias='archiveId') + policyid: str = Field(..., alias='policyId') + status: str = Field(..., alias='status') + startedat: str = Field(..., alias='startedAt') + migrationid: str = Field(..., alias='migrationId') + services: List[Any] = Field(..., alias='services') + resources: List[Any] = Field(..., alias='resources') + options: str = Field(..., alias='options') diff --git a/appwrite/models/backup_restoration_list.py b/appwrite/models/backup_restoration_list.py new file mode 100644 index 0000000..b0bba25 --- /dev/null +++ b/appwrite/models/backup_restoration_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .backup_restoration import BackupRestoration + +class BackupRestorationList(AppwriteModel): + """ + Backup restoration list + + Attributes + ---------- + total : float + Total number of restorations that matched your query. + restorations : List[BackupRestoration] + List of restorations. + """ + total: float = Field(..., alias='total') + restorations: List[BackupRestoration] = Field(..., alias='restorations') diff --git a/appwrite/models/base_model.py b/appwrite/models/base_model.py new file mode 100644 index 0000000..d5b8d9b --- /dev/null +++ b/appwrite/models/base_model.py @@ -0,0 +1,27 @@ +from __future__ import annotations + +from typing import Any, Dict, Optional, Type, TypeVar + +from pydantic import BaseModel, ConfigDict + +ModelType = TypeVar('ModelType', bound='AppwriteModel') + +class AppwriteModel(BaseModel): + model_config = ConfigDict( + arbitrary_types_allowed=True, + extra='allow', + populate_by_name=True, + ) + + @classmethod + def from_dict(cls: Type[ModelType], data: Optional[Dict[str, Any]]) -> Optional[ModelType]: + if data is None: + return None + + return cls.model_validate(data) + + def to_dict(self) -> Dict[str, Any]: + return self.model_dump(by_alias=True, mode='json') + + def to_json(self) -> str: + return self.model_dump_json(by_alias=True) diff --git a/appwrite/models/bucket.py b/appwrite/models/bucket.py new file mode 100644 index 0000000..ba731c5 --- /dev/null +++ b/appwrite/models/bucket.py @@ -0,0 +1,55 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Bucket(AppwriteModel): + """ + Bucket + + Attributes + ---------- + id : str + Bucket ID. + createdat : str + Bucket creation time in ISO 8601 format. + updatedat : str + Bucket update date in ISO 8601 format. + permissions : List[Any] + Bucket permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + filesecurity : bool + Whether file-level security is enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + name : str + Bucket name. + enabled : bool + Bucket enabled. + maximumfilesize : float + Maximum file size supported. + allowedfileextensions : List[Any] + Allowed file extensions. + compression : str + Compression algorithm chosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + encryption : bool + Bucket is encrypted. + antivirus : bool + Virus scanning is enabled. + transformations : bool + Image transformations are enabled. + totalsize : float + Total size of this bucket in bytes. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + permissions: List[Any] = Field(..., alias='$permissions') + filesecurity: bool = Field(..., alias='fileSecurity') + name: str = Field(..., alias='name') + enabled: bool = Field(..., alias='enabled') + maximumfilesize: float = Field(..., alias='maximumFileSize') + allowedfileextensions: List[Any] = Field(..., alias='allowedFileExtensions') + compression: str = Field(..., alias='compression') + encryption: bool = Field(..., alias='encryption') + antivirus: bool = Field(..., alias='antivirus') + transformations: bool = Field(..., alias='transformations') + totalsize: float = Field(..., alias='totalSize') diff --git a/appwrite/models/bucket_list.py b/appwrite/models/bucket_list.py new file mode 100644 index 0000000..7f202e3 --- /dev/null +++ b/appwrite/models/bucket_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .bucket import Bucket + +class BucketList(AppwriteModel): + """ + Buckets List + + Attributes + ---------- + total : float + Total number of buckets that matched your query. + buckets : List[Bucket] + List of buckets. + """ + total: float = Field(..., alias='total') + buckets: List[Bucket] = Field(..., alias='buckets') diff --git a/appwrite/models/collection.py b/appwrite/models/collection.py new file mode 100644 index 0000000..5b8efa7 --- /dev/null +++ b/appwrite/models/collection.py @@ -0,0 +1,67 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .attribute_boolean import AttributeBoolean +from .attribute_integer import AttributeInteger +from .attribute_float import AttributeFloat +from .attribute_email import AttributeEmail +from .attribute_enum import AttributeEnum +from .attribute_url import AttributeUrl +from .attribute_ip import AttributeIp +from .attribute_datetime import AttributeDatetime +from .attribute_relationship import AttributeRelationship +from .attribute_point import AttributePoint +from .attribute_line import AttributeLine +from .attribute_polygon import AttributePolygon +from .attribute_varchar import AttributeVarchar +from .attribute_text import AttributeText +from .attribute_mediumtext import AttributeMediumtext +from .attribute_longtext import AttributeLongtext +from .attribute_string import AttributeString +from .index import Index + +class Collection(AppwriteModel): + """ + Collection + + Attributes + ---------- + id : str + Collection ID. + createdat : str + Collection creation date in ISO 8601 format. + updatedat : str + Collection update date in ISO 8601 format. + permissions : List[Any] + Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + databaseid : str + Database ID. + name : str + Collection name. + enabled : bool + Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. + documentsecurity : bool + Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + attributes : List[Union[AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString]] + Collection attributes. + indexes : List[Index] + Collection indexes. + bytesmax : float + Maximum document size in bytes. Returns 0 when no limit applies. + bytesused : float + Currently used document size in bytes based on defined attributes. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + permissions: List[Any] = Field(..., alias='$permissions') + databaseid: str = Field(..., alias='databaseId') + name: str = Field(..., alias='name') + enabled: bool = Field(..., alias='enabled') + documentsecurity: bool = Field(..., alias='documentSecurity') + attributes: List[Union[AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString]] = Field(..., alias='attributes') + indexes: List[Index] = Field(..., alias='indexes') + bytesmax: float = Field(..., alias='bytesMax') + bytesused: float = Field(..., alias='bytesUsed') diff --git a/appwrite/models/collection_list.py b/appwrite/models/collection_list.py new file mode 100644 index 0000000..90f6641 --- /dev/null +++ b/appwrite/models/collection_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .collection import Collection + +class CollectionList(AppwriteModel): + """ + Collections List + + Attributes + ---------- + total : float + Total number of collections that matched your query. + collections : List[Collection] + List of collections. + """ + total: float = Field(..., alias='total') + collections: List[Collection] = Field(..., alias='collections') diff --git a/appwrite/models/column_boolean.py b/appwrite/models/column_boolean.py new file mode 100644 index 0000000..7e68a0f --- /dev/null +++ b/appwrite/models/column_boolean.py @@ -0,0 +1,41 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnBoolean(AppwriteModel): + """ + ColumnBoolean + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + default : Optional[bool] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[bool] = Field(default=None, alias='default') diff --git a/appwrite/models/column_datetime.py b/appwrite/models/column_datetime.py new file mode 100644 index 0000000..1236004 --- /dev/null +++ b/appwrite/models/column_datetime.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnDatetime(AppwriteModel): + """ + ColumnDatetime + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + format : str + ISO 8601 format. + default : Optional[str] + Default value for column when not provided. Only null is optional + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/column_email.py b/appwrite/models/column_email.py new file mode 100644 index 0000000..b7a4c2d --- /dev/null +++ b/appwrite/models/column_email.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnEmail(AppwriteModel): + """ + ColumnEmail + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + format : str + String format. + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/column_enum.py b/appwrite/models/column_enum.py new file mode 100644 index 0000000..a780076 --- /dev/null +++ b/appwrite/models/column_enum.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnEnum(AppwriteModel): + """ + ColumnEnum + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + elements : List[Any] + Array of elements in enumerated type. + format : str + String format. + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + elements: List[Any] = Field(..., alias='elements') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/column_float.py b/appwrite/models/column_float.py new file mode 100644 index 0000000..577ade5 --- /dev/null +++ b/appwrite/models/column_float.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnFloat(AppwriteModel): + """ + ColumnFloat + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + min : Optional[float] + Minimum value to enforce for new documents. + max : Optional[float] + Maximum value to enforce for new documents. + default : Optional[float] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + min: Optional[float] = Field(default=None, alias='min') + max: Optional[float] = Field(default=None, alias='max') + default: Optional[float] = Field(default=None, alias='default') diff --git a/appwrite/models/column_index.py b/appwrite/models/column_index.py new file mode 100644 index 0000000..9eacbdb --- /dev/null +++ b/appwrite/models/column_index.py @@ -0,0 +1,43 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class ColumnIndex(AppwriteModel): + """ + Index + + Attributes + ---------- + id : str + Index ID. + createdat : str + Index creation date in ISO 8601 format. + updatedat : str + Index update date in ISO 8601 format. + key : str + Index Key. + type : str + Index type. + status : str + Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an index. + columns : List[Any] + Index columns. + lengths : List[Any] + Index columns length. + orders : Optional[List[Any]] + Index orders. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: str = Field(..., alias='status') + error: str = Field(..., alias='error') + columns: List[Any] = Field(..., alias='columns') + lengths: List[Any] = Field(..., alias='lengths') + orders: Optional[List[Any]] = Field(default=None, alias='orders') diff --git a/appwrite/models/column_index_list.py b/appwrite/models/column_index_list.py new file mode 100644 index 0000000..05fbd8f --- /dev/null +++ b/appwrite/models/column_index_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .column_index import ColumnIndex + +class ColumnIndexList(AppwriteModel): + """ + Column Indexes List + + Attributes + ---------- + total : float + Total number of indexes that matched your query. + indexes : List[ColumnIndex] + List of indexes. + """ + total: float = Field(..., alias='total') + indexes: List[ColumnIndex] = Field(..., alias='indexes') diff --git a/appwrite/models/column_integer.py b/appwrite/models/column_integer.py new file mode 100644 index 0000000..0dffb8d --- /dev/null +++ b/appwrite/models/column_integer.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnInteger(AppwriteModel): + """ + ColumnInteger + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + min : Optional[float] + Minimum value to enforce for new documents. + max : Optional[float] + Maximum value to enforce for new documents. + default : Optional[float] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + min: Optional[float] = Field(default=None, alias='min') + max: Optional[float] = Field(default=None, alias='max') + default: Optional[float] = Field(default=None, alias='default') diff --git a/appwrite/models/column_ip.py b/appwrite/models/column_ip.py new file mode 100644 index 0000000..3dd44d3 --- /dev/null +++ b/appwrite/models/column_ip.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnIp(AppwriteModel): + """ + ColumnIP + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + format : str + String format. + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/column_line.py b/appwrite/models/column_line.py new file mode 100644 index 0000000..d0861c9 --- /dev/null +++ b/appwrite/models/column_line.py @@ -0,0 +1,41 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnLine(AppwriteModel): + """ + ColumnLine + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + default : Optional[List[Any]] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[List[Any]] = Field(default=None, alias='default') diff --git a/appwrite/models/column_list.py b/appwrite/models/column_list.py new file mode 100644 index 0000000..2a6092f --- /dev/null +++ b/appwrite/models/column_list.py @@ -0,0 +1,36 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .column_boolean import ColumnBoolean +from .column_integer import ColumnInteger +from .column_float import ColumnFloat +from .column_email import ColumnEmail +from .column_enum import ColumnEnum +from .column_url import ColumnUrl +from .column_ip import ColumnIp +from .column_datetime import ColumnDatetime +from .column_relationship import ColumnRelationship +from .column_point import ColumnPoint +from .column_line import ColumnLine +from .column_polygon import ColumnPolygon +from .column_varchar import ColumnVarchar +from .column_text import ColumnText +from .column_mediumtext import ColumnMediumtext +from .column_longtext import ColumnLongtext +from .column_string import ColumnString + +class ColumnList(AppwriteModel): + """ + Columns List + + Attributes + ---------- + total : float + Total number of columns in the given table. + columns : List[Union[ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString]] + List of columns. + """ + total: float = Field(..., alias='total') + columns: List[Union[ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString]] = Field(..., alias='columns') diff --git a/appwrite/models/column_longtext.py b/appwrite/models/column_longtext.py new file mode 100644 index 0000000..b66f75a --- /dev/null +++ b/appwrite/models/column_longtext.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnLongtext(AppwriteModel): + """ + ColumnLongtext + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + encrypt : Optional[bool] + Defines whether this column is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/column_mediumtext.py b/appwrite/models/column_mediumtext.py new file mode 100644 index 0000000..8be1678 --- /dev/null +++ b/appwrite/models/column_mediumtext.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnMediumtext(AppwriteModel): + """ + ColumnMediumtext + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + encrypt : Optional[bool] + Defines whether this column is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/column_point.py b/appwrite/models/column_point.py new file mode 100644 index 0000000..78be38b --- /dev/null +++ b/appwrite/models/column_point.py @@ -0,0 +1,41 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnPoint(AppwriteModel): + """ + ColumnPoint + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + default : Optional[List[Any]] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[List[Any]] = Field(default=None, alias='default') diff --git a/appwrite/models/column_polygon.py b/appwrite/models/column_polygon.py new file mode 100644 index 0000000..5361347 --- /dev/null +++ b/appwrite/models/column_polygon.py @@ -0,0 +1,41 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnPolygon(AppwriteModel): + """ + ColumnPolygon + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + default : Optional[List[Any]] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[List[Any]] = Field(default=None, alias='default') diff --git a/appwrite/models/column_relationship.py b/appwrite/models/column_relationship.py new file mode 100644 index 0000000..fc088e0 --- /dev/null +++ b/appwrite/models/column_relationship.py @@ -0,0 +1,56 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnRelationship(AppwriteModel): + """ + ColumnRelationship + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + relatedtable : str + The ID of the related table. + relationtype : str + The type of the relationship. + twoway : bool + Is the relationship two-way? + twowaykey : str + The key of the two-way relationship. + ondelete : str + How deleting the parent document will propagate to child documents. + side : str + Whether this is the parent or child side of the relationship + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + relatedtable: str = Field(..., alias='relatedTable') + relationtype: str = Field(..., alias='relationType') + twoway: bool = Field(..., alias='twoWay') + twowaykey: str = Field(..., alias='twoWayKey') + ondelete: str = Field(..., alias='onDelete') + side: str = Field(..., alias='side') diff --git a/appwrite/models/column_string.py b/appwrite/models/column_string.py new file mode 100644 index 0000000..e58b2a6 --- /dev/null +++ b/appwrite/models/column_string.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnString(AppwriteModel): + """ + ColumnString + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + size : float + Column size. + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + encrypt : Optional[bool] + Defines whether this column is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + size: float = Field(..., alias='size') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/column_text.py b/appwrite/models/column_text.py new file mode 100644 index 0000000..692d0b4 --- /dev/null +++ b/appwrite/models/column_text.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnText(AppwriteModel): + """ + ColumnText + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + encrypt : Optional[bool] + Defines whether this column is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/column_url.py b/appwrite/models/column_url.py new file mode 100644 index 0000000..76f70de --- /dev/null +++ b/appwrite/models/column_url.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnUrl(AppwriteModel): + """ + ColumnURL + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + format : str + String format. + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + format: str = Field(..., alias='format') + default: Optional[str] = Field(default=None, alias='default') diff --git a/appwrite/models/column_varchar.py b/appwrite/models/column_varchar.py new file mode 100644 index 0000000..65dade5 --- /dev/null +++ b/appwrite/models/column_varchar.py @@ -0,0 +1,47 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.column_status import ColumnStatus + +class ColumnVarchar(AppwriteModel): + """ + ColumnVarchar + + Attributes + ---------- + key : str + Column Key. + type : str + Column type. + status : ColumnStatus + Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an column. + required : bool + Is column required? + array : Optional[bool] + Is column an array? + createdat : str + Column creation date in ISO 8601 format. + updatedat : str + Column update date in ISO 8601 format. + size : float + Column size. + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + encrypt : Optional[bool] + Defines whether this column is encrypted or not. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: ColumnStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + size: float = Field(..., alias='size') + default: Optional[str] = Field(default=None, alias='default') + encrypt: Optional[bool] = Field(default=None, alias='encrypt') diff --git a/appwrite/models/continent.py b/appwrite/models/continent.py new file mode 100644 index 0000000..2f56544 --- /dev/null +++ b/appwrite/models/continent.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Continent(AppwriteModel): + """ + Continent + + Attributes + ---------- + name : str + Continent name. + code : str + Continent two letter code. + """ + name: str = Field(..., alias='name') + code: str = Field(..., alias='code') diff --git a/appwrite/models/continent_list.py b/appwrite/models/continent_list.py new file mode 100644 index 0000000..0cdf932 --- /dev/null +++ b/appwrite/models/continent_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .continent import Continent + +class ContinentList(AppwriteModel): + """ + Continents List + + Attributes + ---------- + total : float + Total number of continents that matched your query. + continents : List[Continent] + List of continents. + """ + total: float = Field(..., alias='total') + continents: List[Continent] = Field(..., alias='continents') diff --git a/appwrite/models/country.py b/appwrite/models/country.py new file mode 100644 index 0000000..c064450 --- /dev/null +++ b/appwrite/models/country.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Country(AppwriteModel): + """ + Country + + Attributes + ---------- + name : str + Country name. + code : str + Country two-character ISO 3166-1 alpha code. + """ + name: str = Field(..., alias='name') + code: str = Field(..., alias='code') diff --git a/appwrite/models/country_list.py b/appwrite/models/country_list.py new file mode 100644 index 0000000..df8d054 --- /dev/null +++ b/appwrite/models/country_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .country import Country + +class CountryList(AppwriteModel): + """ + Countries List + + Attributes + ---------- + total : float + Total number of countries that matched your query. + countries : List[Country] + List of countries. + """ + total: float = Field(..., alias='total') + countries: List[Country] = Field(..., alias='countries') diff --git a/appwrite/models/currency.py b/appwrite/models/currency.py new file mode 100644 index 0000000..c6f9329 --- /dev/null +++ b/appwrite/models/currency.py @@ -0,0 +1,34 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Currency(AppwriteModel): + """ + Currency + + Attributes + ---------- + symbol : str + Currency symbol. + name : str + Currency name. + symbolnative : str + Currency native symbol. + decimaldigits : float + Number of decimal digits. + rounding : float + Currency digit rounding. + code : str + Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + nameplural : str + Currency plural name + """ + symbol: str = Field(..., alias='symbol') + name: str = Field(..., alias='name') + symbolnative: str = Field(..., alias='symbolNative') + decimaldigits: float = Field(..., alias='decimalDigits') + rounding: float = Field(..., alias='rounding') + code: str = Field(..., alias='code') + nameplural: str = Field(..., alias='namePlural') diff --git a/appwrite/models/currency_list.py b/appwrite/models/currency_list.py new file mode 100644 index 0000000..18a104e --- /dev/null +++ b/appwrite/models/currency_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .currency import Currency + +class CurrencyList(AppwriteModel): + """ + Currencies List + + Attributes + ---------- + total : float + Total number of currencies that matched your query. + currencies : List[Currency] + List of currencies. + """ + total: float = Field(..., alias='total') + currencies: List[Currency] = Field(..., alias='currencies') diff --git a/appwrite/models/database.py b/appwrite/models/database.py new file mode 100644 index 0000000..22f5f7e --- /dev/null +++ b/appwrite/models/database.py @@ -0,0 +1,40 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.database_type import DatabaseType +from .index import Index +from .collection import Collection + +class Database(AppwriteModel): + """ + Database + + Attributes + ---------- + id : str + Database ID. + name : str + Database name. + createdat : str + Database creation date in ISO 8601 format. + updatedat : str + Database update date in ISO 8601 format. + enabled : bool + If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. + type : DatabaseType + Database type. + policies : List[Index] + Database backup policies. + archives : List[Collection] + Database backup archives. + """ + id: str = Field(..., alias='$id') + name: str = Field(..., alias='name') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + enabled: bool = Field(..., alias='enabled') + type: DatabaseType = Field(..., alias='type') + policies: List[Index] = Field(..., alias='policies') + archives: List[Collection] = Field(..., alias='archives') diff --git a/appwrite/models/database_list.py b/appwrite/models/database_list.py new file mode 100644 index 0000000..f55e3e7 --- /dev/null +++ b/appwrite/models/database_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .database import Database + +class DatabaseList(AppwriteModel): + """ + Databases List + + Attributes + ---------- + total : float + Total number of databases that matched your query. + databases : List[Database] + List of databases. + """ + total: float = Field(..., alias='total') + databases: List[Database] = Field(..., alias='databases') diff --git a/appwrite/models/deployment.py b/appwrite/models/deployment.py new file mode 100644 index 0000000..b36bbae --- /dev/null +++ b/appwrite/models/deployment.py @@ -0,0 +1,95 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.deployment_status import DeploymentStatus + +class Deployment(AppwriteModel): + """ + Deployment + + Attributes + ---------- + id : str + Deployment ID. + createdat : str + Deployment creation date in ISO 8601 format. + updatedat : str + Deployment update date in ISO 8601 format. + type : str + Type of deployment. + resourceid : str + Resource ID. + resourcetype : str + Resource type. + entrypoint : str + The entrypoint file to use to execute the deployment code. + sourcesize : float + The code size in bytes. + buildsize : float + The build output size in bytes. + totalsize : float + The total size in bytes (source and build output). + buildid : str + The current build ID. + activate : bool + Whether the deployment should be automatically activated. + screenshotlight : str + Screenshot with light theme preference file ID. + screenshotdark : str + Screenshot with dark theme preference file ID. + status : DeploymentStatus + The deployment status. Possible values are "waiting", "processing", "building", "ready", "canceled" and "failed". + buildlogs : str + The build logs. + buildduration : float + The current build time in seconds. + providerrepositoryname : str + The name of the vcs provider repository + providerrepositoryowner : str + The name of the vcs provider repository owner + providerrepositoryurl : str + The url of the vcs provider repository + providercommithash : str + The commit hash of the vcs commit + providercommitauthorurl : str + The url of vcs commit author + providercommitauthor : str + The name of vcs commit author + providercommitmessage : str + The commit message + providercommiturl : str + The url of the vcs commit + providerbranch : str + The branch of the vcs repository + providerbranchurl : str + The branch of the vcs repository + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + type: str = Field(..., alias='type') + resourceid: str = Field(..., alias='resourceId') + resourcetype: str = Field(..., alias='resourceType') + entrypoint: str = Field(..., alias='entrypoint') + sourcesize: float = Field(..., alias='sourceSize') + buildsize: float = Field(..., alias='buildSize') + totalsize: float = Field(..., alias='totalSize') + buildid: str = Field(..., alias='buildId') + activate: bool = Field(..., alias='activate') + screenshotlight: str = Field(..., alias='screenshotLight') + screenshotdark: str = Field(..., alias='screenshotDark') + status: DeploymentStatus = Field(..., alias='status') + buildlogs: str = Field(..., alias='buildLogs') + buildduration: float = Field(..., alias='buildDuration') + providerrepositoryname: str = Field(..., alias='providerRepositoryName') + providerrepositoryowner: str = Field(..., alias='providerRepositoryOwner') + providerrepositoryurl: str = Field(..., alias='providerRepositoryUrl') + providercommithash: str = Field(..., alias='providerCommitHash') + providercommitauthorurl: str = Field(..., alias='providerCommitAuthorUrl') + providercommitauthor: str = Field(..., alias='providerCommitAuthor') + providercommitmessage: str = Field(..., alias='providerCommitMessage') + providercommiturl: str = Field(..., alias='providerCommitUrl') + providerbranch: str = Field(..., alias='providerBranch') + providerbranchurl: str = Field(..., alias='providerBranchUrl') diff --git a/appwrite/models/deployment_list.py b/appwrite/models/deployment_list.py new file mode 100644 index 0000000..f84950f --- /dev/null +++ b/appwrite/models/deployment_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .deployment import Deployment + +class DeploymentList(AppwriteModel): + """ + Deployments List + + Attributes + ---------- + total : float + Total number of deployments that matched your query. + deployments : List[Deployment] + List of deployments. + """ + total: float = Field(..., alias='total') + deployments: List[Deployment] = Field(..., alias='deployments') diff --git a/appwrite/models/document.py b/appwrite/models/document.py new file mode 100644 index 0000000..31e2b32 --- /dev/null +++ b/appwrite/models/document.py @@ -0,0 +1,34 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Document(AppwriteModel): + """ + Document + + Attributes + ---------- + id : str + Document ID. + sequence : float + Document sequence ID. + collectionid : str + Collection ID. + databaseid : str + Database ID. + createdat : str + Document creation date in ISO 8601 format. + updatedat : str + Document update date in ISO 8601 format. + permissions : List[Any] + Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + """ + id: str = Field(..., alias='$id') + sequence: float = Field(..., alias='$sequence') + collectionid: str = Field(..., alias='$collectionId') + databaseid: str = Field(..., alias='$databaseId') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + permissions: List[Any] = Field(..., alias='$permissions') diff --git a/appwrite/models/document_list.py b/appwrite/models/document_list.py new file mode 100644 index 0000000..6c6a0cf --- /dev/null +++ b/appwrite/models/document_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .document import Document + +class DocumentList(AppwriteModel): + """ + Documents List + + Attributes + ---------- + total : float + Total number of documents that matched your query. + documents : List[Document] + List of documents. + """ + total: float = Field(..., alias='total') + documents: List[Document] = Field(..., alias='documents') diff --git a/appwrite/models/execution.py b/appwrite/models/execution.py new file mode 100644 index 0000000..48c5122 --- /dev/null +++ b/appwrite/models/execution.py @@ -0,0 +1,70 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.execution_trigger import ExecutionTrigger +from ..enums.execution_status import ExecutionStatus +from .headers import Headers + +class Execution(AppwriteModel): + """ + Execution + + Attributes + ---------- + id : str + Execution ID. + createdat : str + Execution creation date in ISO 8601 format. + updatedat : str + Execution update date in ISO 8601 format. + permissions : List[Any] + Execution roles. + functionid : str + Function ID. + deploymentid : str + Function's deployment ID used to create the execution. + trigger : ExecutionTrigger + The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + status : ExecutionStatus + The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + requestmethod : str + HTTP request method type. + requestpath : str + HTTP request path and query. + requestheaders : List[Headers] + HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + responsestatuscode : float + HTTP response status code. + responsebody : str + HTTP response body. This will return empty unless execution is created as synchronous. + responseheaders : List[Headers] + HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + logs : str + Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + errors : str + Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + duration : float + Resource(function/site) execution duration in seconds. + scheduledat : Optional[str] + The scheduled time for execution. If left empty, execution will be queued immediately. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + permissions: List[Any] = Field(..., alias='$permissions') + functionid: str = Field(..., alias='functionId') + deploymentid: str = Field(..., alias='deploymentId') + trigger: ExecutionTrigger = Field(..., alias='trigger') + status: ExecutionStatus = Field(..., alias='status') + requestmethod: str = Field(..., alias='requestMethod') + requestpath: str = Field(..., alias='requestPath') + requestheaders: List[Headers] = Field(..., alias='requestHeaders') + responsestatuscode: float = Field(..., alias='responseStatusCode') + responsebody: str = Field(..., alias='responseBody') + responseheaders: List[Headers] = Field(..., alias='responseHeaders') + logs: str = Field(..., alias='logs') + errors: str = Field(..., alias='errors') + duration: float = Field(..., alias='duration') + scheduledat: Optional[str] = Field(default=None, alias='scheduledAt') diff --git a/appwrite/models/execution_list.py b/appwrite/models/execution_list.py new file mode 100644 index 0000000..d5d83ef --- /dev/null +++ b/appwrite/models/execution_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .execution import Execution + +class ExecutionList(AppwriteModel): + """ + Executions List + + Attributes + ---------- + total : float + Total number of executions that matched your query. + executions : List[Execution] + List of executions. + """ + total: float = Field(..., alias='total') + executions: List[Execution] = Field(..., alias='executions') diff --git a/appwrite/models/file.py b/appwrite/models/file.py new file mode 100644 index 0000000..4567b97 --- /dev/null +++ b/appwrite/models/file.py @@ -0,0 +1,52 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class File(AppwriteModel): + """ + File + + Attributes + ---------- + id : str + File ID. + bucketid : str + Bucket ID. + createdat : str + File creation date in ISO 8601 format. + updatedat : str + File update date in ISO 8601 format. + permissions : List[Any] + File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + name : str + File name. + signature : str + File MD5 signature. + mimetype : str + File mime type. + sizeoriginal : float + File original size in bytes. + chunkstotal : float + Total number of chunks available + chunksuploaded : float + Total number of chunks uploaded + encryption : bool + Whether file contents are encrypted at rest. + compression : str + Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + """ + id: str = Field(..., alias='$id') + bucketid: str = Field(..., alias='bucketId') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + permissions: List[Any] = Field(..., alias='$permissions') + name: str = Field(..., alias='name') + signature: str = Field(..., alias='signature') + mimetype: str = Field(..., alias='mimeType') + sizeoriginal: float = Field(..., alias='sizeOriginal') + chunkstotal: float = Field(..., alias='chunksTotal') + chunksuploaded: float = Field(..., alias='chunksUploaded') + encryption: bool = Field(..., alias='encryption') + compression: str = Field(..., alias='compression') diff --git a/appwrite/models/file_list.py b/appwrite/models/file_list.py new file mode 100644 index 0000000..f05a9a9 --- /dev/null +++ b/appwrite/models/file_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .file import File + +class FileList(AppwriteModel): + """ + Files List + + Attributes + ---------- + total : float + Total number of files that matched your query. + files : List[File] + List of files. + """ + total: float = Field(..., alias='total') + files: List[File] = Field(..., alias='files') diff --git a/appwrite/models/framework.py b/appwrite/models/framework.py new file mode 100644 index 0000000..6f88c67 --- /dev/null +++ b/appwrite/models/framework.py @@ -0,0 +1,29 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .framework_adapter import FrameworkAdapter + +class Framework(AppwriteModel): + """ + Framework + + Attributes + ---------- + key : str + Framework key. + name : str + Framework Name. + buildruntime : str + Default runtime version. + runtimes : List[Any] + List of supported runtime versions. + adapters : List[FrameworkAdapter] + List of supported adapters. + """ + key: str = Field(..., alias='key') + name: str = Field(..., alias='name') + buildruntime: str = Field(..., alias='buildRuntime') + runtimes: List[Any] = Field(..., alias='runtimes') + adapters: List[FrameworkAdapter] = Field(..., alias='adapters') diff --git a/appwrite/models/framework_adapter.py b/appwrite/models/framework_adapter.py new file mode 100644 index 0000000..a4c8aaf --- /dev/null +++ b/appwrite/models/framework_adapter.py @@ -0,0 +1,28 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class FrameworkAdapter(AppwriteModel): + """ + Framework Adapter + + Attributes + ---------- + key : str + Adapter key. + installcommand : str + Default command to download dependencies. + buildcommand : str + Default command to build site into output directory. + outputdirectory : str + Default output directory of build. + fallbackfile : str + Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + """ + key: str = Field(..., alias='key') + installcommand: str = Field(..., alias='installCommand') + buildcommand: str = Field(..., alias='buildCommand') + outputdirectory: str = Field(..., alias='outputDirectory') + fallbackfile: str = Field(..., alias='fallbackFile') diff --git a/appwrite/models/framework_list.py b/appwrite/models/framework_list.py new file mode 100644 index 0000000..d6266bf --- /dev/null +++ b/appwrite/models/framework_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .framework import Framework + +class FrameworkList(AppwriteModel): + """ + Frameworks List + + Attributes + ---------- + total : float + Total number of frameworks that matched your query. + frameworks : List[Framework] + List of frameworks. + """ + total: float = Field(..., alias='total') + frameworks: List[Framework] = Field(..., alias='frameworks') diff --git a/appwrite/models/function.py b/appwrite/models/function.py new file mode 100644 index 0000000..6f0b24d --- /dev/null +++ b/appwrite/models/function.py @@ -0,0 +1,98 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .variable import Variable + +class Function(AppwriteModel): + """ + Function + + Attributes + ---------- + id : str + Function ID. + createdat : str + Function creation date in ISO 8601 format. + updatedat : str + Function update date in ISO 8601 format. + execute : List[Any] + Execution permissions. + name : str + Function name. + enabled : bool + Function enabled. + live : bool + Is the function deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the function to update it with the latest configuration. + logging : bool + When disabled, executions will exclude logs and errors, and will be slightly faster. + runtime : str + Function execution and build runtime. + deploymentid : str + Function's active deployment ID. + deploymentcreatedat : str + Active deployment creation date in ISO 8601 format. + latestdeploymentid : str + Function's latest deployment ID. + latestdeploymentcreatedat : str + Latest deployment creation date in ISO 8601 format. + latestdeploymentstatus : str + Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + scopes : List[Any] + Allowed permission scopes. + vars : List[Variable] + Function variables. + events : List[Any] + Function trigger events. + schedule : str + Function execution schedule in CRON format. + timeout : float + Function execution timeout in seconds. + entrypoint : str + The entrypoint file used to execute the deployment. + commands : str + The build command used to build the deployment. + version : str + Version of Open Runtimes used for the function. + installationid : str + Function VCS (Version Control System) installation id. + providerrepositoryid : str + VCS (Version Control System) Repository ID + providerbranch : str + VCS (Version Control System) branch name + providerrootdirectory : str + Path to function in VCS (Version Control System) repository + providersilentmode : bool + Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + specification : str + Machine specification for builds and executions. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + execute: List[Any] = Field(..., alias='execute') + name: str = Field(..., alias='name') + enabled: bool = Field(..., alias='enabled') + live: bool = Field(..., alias='live') + logging: bool = Field(..., alias='logging') + runtime: str = Field(..., alias='runtime') + deploymentid: str = Field(..., alias='deploymentId') + deploymentcreatedat: str = Field(..., alias='deploymentCreatedAt') + latestdeploymentid: str = Field(..., alias='latestDeploymentId') + latestdeploymentcreatedat: str = Field(..., alias='latestDeploymentCreatedAt') + latestdeploymentstatus: str = Field(..., alias='latestDeploymentStatus') + scopes: List[Any] = Field(..., alias='scopes') + vars: List[Variable] = Field(..., alias='vars') + events: List[Any] = Field(..., alias='events') + schedule: str = Field(..., alias='schedule') + timeout: float = Field(..., alias='timeout') + entrypoint: str = Field(..., alias='entrypoint') + commands: str = Field(..., alias='commands') + version: str = Field(..., alias='version') + installationid: str = Field(..., alias='installationId') + providerrepositoryid: str = Field(..., alias='providerRepositoryId') + providerbranch: str = Field(..., alias='providerBranch') + providerrootdirectory: str = Field(..., alias='providerRootDirectory') + providersilentmode: bool = Field(..., alias='providerSilentMode') + specification: str = Field(..., alias='specification') diff --git a/appwrite/models/function_list.py b/appwrite/models/function_list.py new file mode 100644 index 0000000..153f4fa --- /dev/null +++ b/appwrite/models/function_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .function import Function + +class FunctionList(AppwriteModel): + """ + Functions List + + Attributes + ---------- + total : float + Total number of functions that matched your query. + functions : List[Function] + List of functions. + """ + total: float = Field(..., alias='total') + functions: List[Function] = Field(..., alias='functions') diff --git a/appwrite/models/headers.py b/appwrite/models/headers.py new file mode 100644 index 0000000..837cf1b --- /dev/null +++ b/appwrite/models/headers.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Headers(AppwriteModel): + """ + Headers + + Attributes + ---------- + name : str + Header name. + value : str + Header value. + """ + name: str = Field(..., alias='name') + value: str = Field(..., alias='value') diff --git a/appwrite/models/health_antivirus.py b/appwrite/models/health_antivirus.py new file mode 100644 index 0000000..a70fb0b --- /dev/null +++ b/appwrite/models/health_antivirus.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.health_antivirus_status import HealthAntivirusStatus + +class HealthAntivirus(AppwriteModel): + """ + Health Antivirus + + Attributes + ---------- + version : str + Antivirus version. + status : HealthAntivirusStatus + Antivirus status. Possible values are: `disabled`, `offline`, `online` + """ + version: str = Field(..., alias='version') + status: HealthAntivirusStatus = Field(..., alias='status') diff --git a/appwrite/models/health_certificate.py b/appwrite/models/health_certificate.py new file mode 100644 index 0000000..4ab76d1 --- /dev/null +++ b/appwrite/models/health_certificate.py @@ -0,0 +1,31 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class HealthCertificate(AppwriteModel): + """ + Health Certificate + + Attributes + ---------- + name : str + Certificate name + subjectsn : str + Subject SN + issuerorganisation : str + Issuer organisation + validfrom : str + Valid from + validto : str + Valid to + signaturetypesn : str + Signature type SN + """ + name: str = Field(..., alias='name') + subjectsn: str = Field(..., alias='subjectSN') + issuerorganisation: str = Field(..., alias='issuerOrganisation') + validfrom: str = Field(..., alias='validFrom') + validto: str = Field(..., alias='validTo') + signaturetypesn: str = Field(..., alias='signatureTypeSN') diff --git a/appwrite/models/health_queue.py b/appwrite/models/health_queue.py new file mode 100644 index 0000000..7969b05 --- /dev/null +++ b/appwrite/models/health_queue.py @@ -0,0 +1,16 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class HealthQueue(AppwriteModel): + """ + Health Queue + + Attributes + ---------- + size : float + Amount of actions in the queue. + """ + size: float = Field(..., alias='size') diff --git a/appwrite/models/health_status.py b/appwrite/models/health_status.py new file mode 100644 index 0000000..ca46b68 --- /dev/null +++ b/appwrite/models/health_status.py @@ -0,0 +1,23 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.health_check_status import HealthCheckStatus + +class HealthStatus(AppwriteModel): + """ + Health Status + + Attributes + ---------- + name : str + Name of the service. + ping : float + Duration in milliseconds how long the health check took. + status : HealthCheckStatus + Service status. Possible values are: `pass`, `fail` + """ + name: str = Field(..., alias='name') + ping: float = Field(..., alias='ping') + status: HealthCheckStatus = Field(..., alias='status') diff --git a/appwrite/models/health_status_list.py b/appwrite/models/health_status_list.py new file mode 100644 index 0000000..c645e04 --- /dev/null +++ b/appwrite/models/health_status_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .health_status import HealthStatus + +class HealthStatusList(AppwriteModel): + """ + Status List + + Attributes + ---------- + total : float + Total number of statuses that matched your query. + statuses : List[HealthStatus] + List of statuses. + """ + total: float = Field(..., alias='total') + statuses: List[HealthStatus] = Field(..., alias='statuses') diff --git a/appwrite/models/health_time.py b/appwrite/models/health_time.py new file mode 100644 index 0000000..b564cbf --- /dev/null +++ b/appwrite/models/health_time.py @@ -0,0 +1,22 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class HealthTime(AppwriteModel): + """ + Health Time + + Attributes + ---------- + remotetime : float + Current unix timestamp on trustful remote server. + localtime : float + Current unix timestamp of local server where Appwrite runs. + diff : float + Difference of unix remote and local timestamps in milliseconds. + """ + remotetime: float = Field(..., alias='remoteTime') + localtime: float = Field(..., alias='localTime') + diff: float = Field(..., alias='diff') diff --git a/appwrite/models/identity.py b/appwrite/models/identity.py new file mode 100644 index 0000000..54acec9 --- /dev/null +++ b/appwrite/models/identity.py @@ -0,0 +1,43 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Identity(AppwriteModel): + """ + Identity + + Attributes + ---------- + id : str + Identity ID. + createdat : str + Identity creation date in ISO 8601 format. + updatedat : str + Identity update date in ISO 8601 format. + userid : str + User ID. + provider : str + Identity Provider. + provideruid : str + ID of the User in the Identity Provider. + provideremail : str + Email of the User in the Identity Provider. + provideraccesstoken : str + Identity Provider Access Token. + provideraccesstokenexpiry : str + The date of when the access token expires in ISO 8601 format. + providerrefreshtoken : str + Identity Provider Refresh Token. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + userid: str = Field(..., alias='userId') + provider: str = Field(..., alias='provider') + provideruid: str = Field(..., alias='providerUid') + provideremail: str = Field(..., alias='providerEmail') + provideraccesstoken: str = Field(..., alias='providerAccessToken') + provideraccesstokenexpiry: str = Field(..., alias='providerAccessTokenExpiry') + providerrefreshtoken: str = Field(..., alias='providerRefreshToken') diff --git a/appwrite/models/identity_list.py b/appwrite/models/identity_list.py new file mode 100644 index 0000000..9a64574 --- /dev/null +++ b/appwrite/models/identity_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .identity import Identity + +class IdentityList(AppwriteModel): + """ + Identities List + + Attributes + ---------- + total : float + Total number of identities that matched your query. + identities : List[Identity] + List of identities. + """ + total: float = Field(..., alias='total') + identities: List[Identity] = Field(..., alias='identities') diff --git a/appwrite/models/index.py b/appwrite/models/index.py new file mode 100644 index 0000000..0c2b960 --- /dev/null +++ b/appwrite/models/index.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.index_status import IndexStatus + +class Index(AppwriteModel): + """ + Index + + Attributes + ---------- + id : str + Index ID. + createdat : str + Index creation date in ISO 8601 format. + updatedat : str + Index update date in ISO 8601 format. + key : str + Index key. + type : str + Index type. + status : IndexStatus + Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an index. + attributes : List[Any] + Index attributes. + lengths : List[Any] + Index attributes length. + orders : Optional[List[Any]] + Index orders. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: IndexStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + attributes: List[Any] = Field(..., alias='attributes') + lengths: List[Any] = Field(..., alias='lengths') + orders: Optional[List[Any]] = Field(default=None, alias='orders') diff --git a/appwrite/models/index_list.py b/appwrite/models/index_list.py new file mode 100644 index 0000000..2357189 --- /dev/null +++ b/appwrite/models/index_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .index import Index + +class IndexList(AppwriteModel): + """ + Indexes List + + Attributes + ---------- + total : float + Total number of indexes that matched your query. + indexes : List[Index] + List of indexes. + """ + total: float = Field(..., alias='total') + indexes: List[Index] = Field(..., alias='indexes') diff --git a/appwrite/models/jwt.py b/appwrite/models/jwt.py new file mode 100644 index 0000000..6931b33 --- /dev/null +++ b/appwrite/models/jwt.py @@ -0,0 +1,16 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Jwt(AppwriteModel): + """ + JWT + + Attributes + ---------- + jwt : str + JWT encoded string. + """ + jwt: str = Field(..., alias='jwt') diff --git a/appwrite/models/language.py b/appwrite/models/language.py new file mode 100644 index 0000000..d501a1b --- /dev/null +++ b/appwrite/models/language.py @@ -0,0 +1,22 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Language(AppwriteModel): + """ + Language + + Attributes + ---------- + name : str + Language name. + code : str + Language two-character ISO 639-1 codes. + nativename : str + Language native name. + """ + name: str = Field(..., alias='name') + code: str = Field(..., alias='code') + nativename: str = Field(..., alias='nativeName') diff --git a/appwrite/models/language_list.py b/appwrite/models/language_list.py new file mode 100644 index 0000000..87608df --- /dev/null +++ b/appwrite/models/language_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .language import Language + +class LanguageList(AppwriteModel): + """ + Languages List + + Attributes + ---------- + total : float + Total number of languages that matched your query. + languages : List[Language] + List of languages. + """ + total: float = Field(..., alias='total') + languages: List[Language] = Field(..., alias='languages') diff --git a/appwrite/models/locale.py b/appwrite/models/locale.py new file mode 100644 index 0000000..bc64d2a --- /dev/null +++ b/appwrite/models/locale.py @@ -0,0 +1,34 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Locale(AppwriteModel): + """ + Locale + + Attributes + ---------- + ip : str + User IP address. + countrycode : str + Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + country : str + Country name. This field support localization. + continentcode : str + Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + continent : str + Continent name. This field support localization. + eu : bool + True if country is part of the European Union. + currency : str + Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + """ + ip: str = Field(..., alias='ip') + countrycode: str = Field(..., alias='countryCode') + country: str = Field(..., alias='country') + continentcode: str = Field(..., alias='continentCode') + continent: str = Field(..., alias='continent') + eu: bool = Field(..., alias='eu') + currency: str = Field(..., alias='currency') diff --git a/appwrite/models/locale_code.py b/appwrite/models/locale_code.py new file mode 100644 index 0000000..051aae4 --- /dev/null +++ b/appwrite/models/locale_code.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class LocaleCode(AppwriteModel): + """ + LocaleCode + + Attributes + ---------- + code : str + Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + name : str + Locale name + """ + code: str = Field(..., alias='code') + name: str = Field(..., alias='name') diff --git a/appwrite/models/locale_code_list.py b/appwrite/models/locale_code_list.py new file mode 100644 index 0000000..a1aeedc --- /dev/null +++ b/appwrite/models/locale_code_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .locale_code import LocaleCode + +class LocaleCodeList(AppwriteModel): + """ + Locale codes list + + Attributes + ---------- + total : float + Total number of localeCodes that matched your query. + localecodes : List[LocaleCode] + List of localeCodes. + """ + total: float = Field(..., alias='total') + localecodes: List[LocaleCode] = Field(..., alias='localeCodes') diff --git a/appwrite/models/log.py b/appwrite/models/log.py new file mode 100644 index 0000000..fbb8bff --- /dev/null +++ b/appwrite/models/log.py @@ -0,0 +1,76 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Log(AppwriteModel): + """ + Log + + Attributes + ---------- + event : str + Event name. + userid : str + User ID. + useremail : str + User Email. + username : str + User Name. + mode : str + API mode when event triggered. + ip : str + IP session in use when the session was created. + time : str + Log creation date in ISO 8601 format. + oscode : str + Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + osname : str + Operating system name. + osversion : str + Operating system version. + clienttype : str + Client type. + clientcode : str + Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + clientname : str + Client name. + clientversion : str + Client version. + clientengine : str + Client engine name. + clientengineversion : str + Client engine name. + devicename : str + Device name. + devicebrand : str + Device brand name. + devicemodel : str + Device model name. + countrycode : str + Country two-character ISO 3166-1 alpha code. + countryname : str + Country name. + """ + event: str = Field(..., alias='event') + userid: str = Field(..., alias='userId') + useremail: str = Field(..., alias='userEmail') + username: str = Field(..., alias='userName') + mode: str = Field(..., alias='mode') + ip: str = Field(..., alias='ip') + time: str = Field(..., alias='time') + oscode: str = Field(..., alias='osCode') + osname: str = Field(..., alias='osName') + osversion: str = Field(..., alias='osVersion') + clienttype: str = Field(..., alias='clientType') + clientcode: str = Field(..., alias='clientCode') + clientname: str = Field(..., alias='clientName') + clientversion: str = Field(..., alias='clientVersion') + clientengine: str = Field(..., alias='clientEngine') + clientengineversion: str = Field(..., alias='clientEngineVersion') + devicename: str = Field(..., alias='deviceName') + devicebrand: str = Field(..., alias='deviceBrand') + devicemodel: str = Field(..., alias='deviceModel') + countrycode: str = Field(..., alias='countryCode') + countryname: str = Field(..., alias='countryName') diff --git a/appwrite/models/log_list.py b/appwrite/models/log_list.py new file mode 100644 index 0000000..f0f826f --- /dev/null +++ b/appwrite/models/log_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .log import Log + +class LogList(AppwriteModel): + """ + Logs List + + Attributes + ---------- + total : float + Total number of logs that matched your query. + logs : List[Log] + List of logs. + """ + total: float = Field(..., alias='total') + logs: List[Log] = Field(..., alias='logs') diff --git a/appwrite/models/membership.py b/appwrite/models/membership.py new file mode 100644 index 0000000..66600d9 --- /dev/null +++ b/appwrite/models/membership.py @@ -0,0 +1,52 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Membership(AppwriteModel): + """ + Membership + + Attributes + ---------- + id : str + Membership ID. + createdat : str + Membership creation date in ISO 8601 format. + updatedat : str + Membership update date in ISO 8601 format. + userid : str + User ID. + username : str + User name. Hide this attribute by toggling membership privacy in the Console. + useremail : str + User email address. Hide this attribute by toggling membership privacy in the Console. + teamid : str + Team ID. + teamname : str + Team name. + invited : str + Date, the user has been invited to join the team in ISO 8601 format. + joined : str + Date, the user has accepted the invitation to join the team in ISO 8601 format. + confirm : bool + User confirmation status, true if the user has joined the team or false otherwise. + mfa : bool + Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + roles : List[Any] + User list of roles + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + userid: str = Field(..., alias='userId') + username: str = Field(..., alias='userName') + useremail: str = Field(..., alias='userEmail') + teamid: str = Field(..., alias='teamId') + teamname: str = Field(..., alias='teamName') + invited: str = Field(..., alias='invited') + joined: str = Field(..., alias='joined') + confirm: bool = Field(..., alias='confirm') + mfa: bool = Field(..., alias='mfa') + roles: List[Any] = Field(..., alias='roles') diff --git a/appwrite/models/membership_list.py b/appwrite/models/membership_list.py new file mode 100644 index 0000000..2ea17b4 --- /dev/null +++ b/appwrite/models/membership_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .membership import Membership + +class MembershipList(AppwriteModel): + """ + Memberships List + + Attributes + ---------- + total : float + Total number of memberships that matched your query. + memberships : List[Membership] + List of memberships. + """ + total: float = Field(..., alias='total') + memberships: List[Membership] = Field(..., alias='memberships') diff --git a/appwrite/models/message.py b/appwrite/models/message.py new file mode 100644 index 0000000..818ebba --- /dev/null +++ b/appwrite/models/message.py @@ -0,0 +1,53 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from ..enums.message_status import MessageStatus + +class Message(AppwriteModel): + """ + Message + + Attributes + ---------- + id : str + Message ID. + createdat : str + Message creation time in ISO 8601 format. + updatedat : str + Message update date in ISO 8601 format. + providertype : str + Message provider type. + topics : List[Any] + Topic IDs set as recipients. + users : List[Any] + User IDs set as recipients. + targets : List[Any] + Target IDs set as recipients. + scheduledat : Optional[str] + The scheduled time for message. + deliveredat : Optional[str] + The time when the message was delivered. + deliveryerrors : Optional[List[Any]] + Delivery errors if any. + deliveredtotal : float + Number of recipients the message was delivered to. + data : Dict[str, Any] + Data of the message. + status : MessageStatus + Status of delivery. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + providertype: str = Field(..., alias='providerType') + topics: List[Any] = Field(..., alias='topics') + users: List[Any] = Field(..., alias='users') + targets: List[Any] = Field(..., alias='targets') + scheduledat: Optional[str] = Field(default=None, alias='scheduledAt') + deliveredat: Optional[str] = Field(default=None, alias='deliveredAt') + deliveryerrors: Optional[List[Any]] = Field(default=None, alias='deliveryErrors') + deliveredtotal: float = Field(..., alias='deliveredTotal') + data: Dict[str, Any] = Field(..., alias='data') + status: MessageStatus = Field(..., alias='status') diff --git a/appwrite/models/message_list.py b/appwrite/models/message_list.py new file mode 100644 index 0000000..8520366 --- /dev/null +++ b/appwrite/models/message_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .message import Message + +class MessageList(AppwriteModel): + """ + Message list + + Attributes + ---------- + total : float + Total number of messages that matched your query. + messages : List[Message] + List of messages. + """ + total: float = Field(..., alias='total') + messages: List[Message] = Field(..., alias='messages') diff --git a/appwrite/models/mfa_challenge.py b/appwrite/models/mfa_challenge.py new file mode 100644 index 0000000..4458c5a --- /dev/null +++ b/appwrite/models/mfa_challenge.py @@ -0,0 +1,25 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class MfaChallenge(AppwriteModel): + """ + MFA Challenge + + Attributes + ---------- + id : str + Token ID. + createdat : str + Token creation date in ISO 8601 format. + userid : str + User ID. + expire : str + Token expiration date in ISO 8601 format. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + userid: str = Field(..., alias='userId') + expire: str = Field(..., alias='expire') diff --git a/appwrite/models/mfa_factors.py b/appwrite/models/mfa_factors.py new file mode 100644 index 0000000..1fc312d --- /dev/null +++ b/appwrite/models/mfa_factors.py @@ -0,0 +1,25 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class MfaFactors(AppwriteModel): + """ + MFAFactors + + Attributes + ---------- + totp : bool + Can TOTP be used for MFA challenge for this account. + phone : bool + Can phone (SMS) be used for MFA challenge for this account. + email : bool + Can email be used for MFA challenge for this account. + recoverycode : bool + Can recovery code be used for MFA challenge for this account. + """ + totp: bool = Field(..., alias='totp') + phone: bool = Field(..., alias='phone') + email: bool = Field(..., alias='email') + recoverycode: bool = Field(..., alias='recoveryCode') diff --git a/appwrite/models/mfa_recovery_codes.py b/appwrite/models/mfa_recovery_codes.py new file mode 100644 index 0000000..1038950 --- /dev/null +++ b/appwrite/models/mfa_recovery_codes.py @@ -0,0 +1,16 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class MfaRecoveryCodes(AppwriteModel): + """ + MFA Recovery Codes + + Attributes + ---------- + recoverycodes : List[Any] + Recovery codes. + """ + recoverycodes: List[Any] = Field(..., alias='recoveryCodes') diff --git a/appwrite/models/mfa_type.py b/appwrite/models/mfa_type.py new file mode 100644 index 0000000..47f62aa --- /dev/null +++ b/appwrite/models/mfa_type.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class MfaType(AppwriteModel): + """ + MFAType + + Attributes + ---------- + secret : str + Secret token used for TOTP factor. + uri : str + URI for authenticator apps. + """ + secret: str = Field(..., alias='secret') + uri: str = Field(..., alias='uri') diff --git a/appwrite/models/phone.py b/appwrite/models/phone.py new file mode 100644 index 0000000..6e6e3ef --- /dev/null +++ b/appwrite/models/phone.py @@ -0,0 +1,22 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Phone(AppwriteModel): + """ + Phone + + Attributes + ---------- + code : str + Phone code. + countrycode : str + Country two-character ISO 3166-1 alpha code. + countryname : str + Country name. + """ + code: str = Field(..., alias='code') + countrycode: str = Field(..., alias='countryCode') + countryname: str = Field(..., alias='countryName') diff --git a/appwrite/models/phone_list.py b/appwrite/models/phone_list.py new file mode 100644 index 0000000..89c0499 --- /dev/null +++ b/appwrite/models/phone_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .phone import Phone + +class PhoneList(AppwriteModel): + """ + Phones List + + Attributes + ---------- + total : float + Total number of phones that matched your query. + phones : List[Phone] + List of phones. + """ + total: float = Field(..., alias='total') + phones: List[Phone] = Field(..., alias='phones') diff --git a/appwrite/models/preferences.py b/appwrite/models/preferences.py new file mode 100644 index 0000000..082bb4d --- /dev/null +++ b/appwrite/models/preferences.py @@ -0,0 +1,11 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Preferences(AppwriteModel): + """ + Preferences + """ + pass diff --git a/appwrite/models/provider.py b/appwrite/models/provider.py new file mode 100644 index 0000000..fbfe1f5 --- /dev/null +++ b/appwrite/models/provider.py @@ -0,0 +1,40 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Provider(AppwriteModel): + """ + Provider + + Attributes + ---------- + id : str + Provider ID. + createdat : str + Provider creation time in ISO 8601 format. + updatedat : str + Provider update date in ISO 8601 format. + name : str + The name for the provider instance. + provider : str + The name of the provider service. + enabled : bool + Is provider enabled? + type : str + Type of provider. + credentials : Dict[str, Any] + Provider credentials. + options : Optional[Dict[str, Any]] + Provider options. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + provider: str = Field(..., alias='provider') + enabled: bool = Field(..., alias='enabled') + type: str = Field(..., alias='type') + credentials: Dict[str, Any] = Field(..., alias='credentials') + options: Optional[Dict[str, Any]] = Field(default=None, alias='options') diff --git a/appwrite/models/provider_list.py b/appwrite/models/provider_list.py new file mode 100644 index 0000000..5db7086 --- /dev/null +++ b/appwrite/models/provider_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .provider import Provider + +class ProviderList(AppwriteModel): + """ + Provider list + + Attributes + ---------- + total : float + Total number of providers that matched your query. + providers : List[Provider] + List of providers. + """ + total: float = Field(..., alias='total') + providers: List[Provider] = Field(..., alias='providers') diff --git a/appwrite/models/resource_token.py b/appwrite/models/resource_token.py new file mode 100644 index 0000000..52e96eb --- /dev/null +++ b/appwrite/models/resource_token.py @@ -0,0 +1,34 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class ResourceToken(AppwriteModel): + """ + ResourceToken + + Attributes + ---------- + id : str + Token ID. + createdat : str + Token creation date in ISO 8601 format. + resourceid : str + Resource ID. + resourcetype : str + Resource type. + expire : str + Token expiration date in ISO 8601 format. + secret : str + JWT encoded string. + accessedat : str + Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + resourceid: str = Field(..., alias='resourceId') + resourcetype: str = Field(..., alias='resourceType') + expire: str = Field(..., alias='expire') + secret: str = Field(..., alias='secret') + accessedat: str = Field(..., alias='accessedAt') diff --git a/appwrite/models/resource_token_list.py b/appwrite/models/resource_token_list.py new file mode 100644 index 0000000..e5e181e --- /dev/null +++ b/appwrite/models/resource_token_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .resource_token import ResourceToken + +class ResourceTokenList(AppwriteModel): + """ + Resource Tokens List + + Attributes + ---------- + total : float + Total number of tokens that matched your query. + tokens : List[ResourceToken] + List of tokens. + """ + total: float = Field(..., alias='total') + tokens: List[ResourceToken] = Field(..., alias='tokens') diff --git a/appwrite/models/row.py b/appwrite/models/row.py new file mode 100644 index 0000000..4ec3131 --- /dev/null +++ b/appwrite/models/row.py @@ -0,0 +1,34 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Row(AppwriteModel): + """ + Row + + Attributes + ---------- + id : str + Row ID. + sequence : float + Row sequence ID. + tableid : str + Table ID. + databaseid : str + Database ID. + createdat : str + Row creation date in ISO 8601 format. + updatedat : str + Row update date in ISO 8601 format. + permissions : List[Any] + Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + """ + id: str = Field(..., alias='$id') + sequence: float = Field(..., alias='$sequence') + tableid: str = Field(..., alias='$tableId') + databaseid: str = Field(..., alias='$databaseId') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + permissions: List[Any] = Field(..., alias='$permissions') diff --git a/appwrite/models/row_list.py b/appwrite/models/row_list.py new file mode 100644 index 0000000..fa60620 --- /dev/null +++ b/appwrite/models/row_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .row import Row + +class RowList(AppwriteModel): + """ + Rows List + + Attributes + ---------- + total : float + Total number of rows that matched your query. + rows : List[Row] + List of rows. + """ + total: float = Field(..., alias='total') + rows: List[Row] = Field(..., alias='rows') diff --git a/appwrite/models/runtime.py b/appwrite/models/runtime.py new file mode 100644 index 0000000..5ae4ed6 --- /dev/null +++ b/appwrite/models/runtime.py @@ -0,0 +1,37 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Runtime(AppwriteModel): + """ + Runtime + + Attributes + ---------- + id : str + Runtime ID. + key : str + Parent runtime key. + name : str + Runtime Name. + version : str + Runtime version. + base : str + Base Docker image used to build the runtime. + image : str + Image name of Docker Hub. + logo : str + Name of the logo image. + supports : List[Any] + List of supported architectures. + """ + id: str = Field(..., alias='$id') + key: str = Field(..., alias='key') + name: str = Field(..., alias='name') + version: str = Field(..., alias='version') + base: str = Field(..., alias='base') + image: str = Field(..., alias='image') + logo: str = Field(..., alias='logo') + supports: List[Any] = Field(..., alias='supports') diff --git a/appwrite/models/runtime_list.py b/appwrite/models/runtime_list.py new file mode 100644 index 0000000..87015ec --- /dev/null +++ b/appwrite/models/runtime_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .runtime import Runtime + +class RuntimeList(AppwriteModel): + """ + Runtimes List + + Attributes + ---------- + total : float + Total number of runtimes that matched your query. + runtimes : List[Runtime] + List of runtimes. + """ + total: float = Field(..., alias='total') + runtimes: List[Runtime] = Field(..., alias='runtimes') diff --git a/appwrite/models/session.py b/appwrite/models/session.py new file mode 100644 index 0000000..fba571c --- /dev/null +++ b/appwrite/models/session.py @@ -0,0 +1,100 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Session(AppwriteModel): + """ + Session + + Attributes + ---------- + id : str + Session ID. + createdat : str + Session creation date in ISO 8601 format. + updatedat : str + Session update date in ISO 8601 format. + userid : str + User ID. + expire : str + Session expiration date in ISO 8601 format. + provider : str + Session Provider. + provideruid : str + Session Provider User ID. + provideraccesstoken : str + Session Provider Access Token. + provideraccesstokenexpiry : str + The date of when the access token expires in ISO 8601 format. + providerrefreshtoken : str + Session Provider Refresh Token. + ip : str + IP in use when the session was created. + oscode : str + Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + osname : str + Operating system name. + osversion : str + Operating system version. + clienttype : str + Client type. + clientcode : str + Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + clientname : str + Client name. + clientversion : str + Client version. + clientengine : str + Client engine name. + clientengineversion : str + Client engine name. + devicename : str + Device name. + devicebrand : str + Device brand name. + devicemodel : str + Device model name. + countrycode : str + Country two-character ISO 3166-1 alpha code. + countryname : str + Country name. + current : bool + Returns true if this the current user session. + factors : List[Any] + Returns a list of active session factors. + secret : str + Secret used to authenticate the user. Only included if the request was made with an API key + mfaupdatedat : str + Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + userid: str = Field(..., alias='userId') + expire: str = Field(..., alias='expire') + provider: str = Field(..., alias='provider') + provideruid: str = Field(..., alias='providerUid') + provideraccesstoken: str = Field(..., alias='providerAccessToken') + provideraccesstokenexpiry: str = Field(..., alias='providerAccessTokenExpiry') + providerrefreshtoken: str = Field(..., alias='providerRefreshToken') + ip: str = Field(..., alias='ip') + oscode: str = Field(..., alias='osCode') + osname: str = Field(..., alias='osName') + osversion: str = Field(..., alias='osVersion') + clienttype: str = Field(..., alias='clientType') + clientcode: str = Field(..., alias='clientCode') + clientname: str = Field(..., alias='clientName') + clientversion: str = Field(..., alias='clientVersion') + clientengine: str = Field(..., alias='clientEngine') + clientengineversion: str = Field(..., alias='clientEngineVersion') + devicename: str = Field(..., alias='deviceName') + devicebrand: str = Field(..., alias='deviceBrand') + devicemodel: str = Field(..., alias='deviceModel') + countrycode: str = Field(..., alias='countryCode') + countryname: str = Field(..., alias='countryName') + current: bool = Field(..., alias='current') + factors: List[Any] = Field(..., alias='factors') + secret: str = Field(..., alias='secret') + mfaupdatedat: str = Field(..., alias='mfaUpdatedAt') diff --git a/appwrite/models/session_list.py b/appwrite/models/session_list.py new file mode 100644 index 0000000..dcec9cc --- /dev/null +++ b/appwrite/models/session_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .session import Session + +class SessionList(AppwriteModel): + """ + Sessions List + + Attributes + ---------- + total : float + Total number of sessions that matched your query. + sessions : List[Session] + List of sessions. + """ + total: float = Field(..., alias='total') + sessions: List[Session] = Field(..., alias='sessions') diff --git a/appwrite/models/site.py b/appwrite/models/site.py new file mode 100644 index 0000000..d838ad3 --- /dev/null +++ b/appwrite/models/site.py @@ -0,0 +1,101 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .variable import Variable + +class Site(AppwriteModel): + """ + Site + + Attributes + ---------- + id : str + Site ID. + createdat : str + Site creation date in ISO 8601 format. + updatedat : str + Site update date in ISO 8601 format. + name : str + Site name. + enabled : bool + Site enabled. + live : bool + Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration. + logging : bool + When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + framework : str + Site framework. + deploymentid : str + Site's active deployment ID. + deploymentcreatedat : str + Active deployment creation date in ISO 8601 format. + deploymentscreenshotlight : str + Screenshot of active deployment with light theme preference file ID. + deploymentscreenshotdark : str + Screenshot of active deployment with dark theme preference file ID. + latestdeploymentid : str + Site's latest deployment ID. + latestdeploymentcreatedat : str + Latest deployment creation date in ISO 8601 format. + latestdeploymentstatus : str + Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + vars : List[Variable] + Site variables. + timeout : float + Site request timeout in seconds. + installcommand : str + The install command used to install the site dependencies. + buildcommand : str + The build command used to build the site. + outputdirectory : str + The directory where the site build output is located. + installationid : str + Site VCS (Version Control System) installation id. + providerrepositoryid : str + VCS (Version Control System) Repository ID + providerbranch : str + VCS (Version Control System) branch name + providerrootdirectory : str + Path to site in VCS (Version Control System) repository + providersilentmode : bool + Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + specification : str + Machine specification for builds and executions. + buildruntime : str + Site build runtime. + adapter : str + Site framework adapter. + fallbackfile : str + Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + enabled: bool = Field(..., alias='enabled') + live: bool = Field(..., alias='live') + logging: bool = Field(..., alias='logging') + framework: str = Field(..., alias='framework') + deploymentid: str = Field(..., alias='deploymentId') + deploymentcreatedat: str = Field(..., alias='deploymentCreatedAt') + deploymentscreenshotlight: str = Field(..., alias='deploymentScreenshotLight') + deploymentscreenshotdark: str = Field(..., alias='deploymentScreenshotDark') + latestdeploymentid: str = Field(..., alias='latestDeploymentId') + latestdeploymentcreatedat: str = Field(..., alias='latestDeploymentCreatedAt') + latestdeploymentstatus: str = Field(..., alias='latestDeploymentStatus') + vars: List[Variable] = Field(..., alias='vars') + timeout: float = Field(..., alias='timeout') + installcommand: str = Field(..., alias='installCommand') + buildcommand: str = Field(..., alias='buildCommand') + outputdirectory: str = Field(..., alias='outputDirectory') + installationid: str = Field(..., alias='installationId') + providerrepositoryid: str = Field(..., alias='providerRepositoryId') + providerbranch: str = Field(..., alias='providerBranch') + providerrootdirectory: str = Field(..., alias='providerRootDirectory') + providersilentmode: bool = Field(..., alias='providerSilentMode') + specification: str = Field(..., alias='specification') + buildruntime: str = Field(..., alias='buildRuntime') + adapter: str = Field(..., alias='adapter') + fallbackfile: str = Field(..., alias='fallbackFile') diff --git a/appwrite/models/site_list.py b/appwrite/models/site_list.py new file mode 100644 index 0000000..c8376d7 --- /dev/null +++ b/appwrite/models/site_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .site import Site + +class SiteList(AppwriteModel): + """ + Sites List + + Attributes + ---------- + total : float + Total number of sites that matched your query. + sites : List[Site] + List of sites. + """ + total: float = Field(..., alias='total') + sites: List[Site] = Field(..., alias='sites') diff --git a/appwrite/models/specification.py b/appwrite/models/specification.py new file mode 100644 index 0000000..c3d2751 --- /dev/null +++ b/appwrite/models/specification.py @@ -0,0 +1,25 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Specification(AppwriteModel): + """ + Specification + + Attributes + ---------- + memory : float + Memory size in MB. + cpus : float + Number of CPUs. + enabled : bool + Is size enabled. + slug : str + Size slug. + """ + memory: float = Field(..., alias='memory') + cpus: float = Field(..., alias='cpus') + enabled: bool = Field(..., alias='enabled') + slug: str = Field(..., alias='slug') diff --git a/appwrite/models/specification_list.py b/appwrite/models/specification_list.py new file mode 100644 index 0000000..d75f51a --- /dev/null +++ b/appwrite/models/specification_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .specification import Specification + +class SpecificationList(AppwriteModel): + """ + Specifications List + + Attributes + ---------- + total : float + Total number of specifications that matched your query. + specifications : List[Specification] + List of specifications. + """ + total: float = Field(..., alias='total') + specifications: List[Specification] = Field(..., alias='specifications') diff --git a/appwrite/models/subscriber.py b/appwrite/models/subscriber.py new file mode 100644 index 0000000..2569c1b --- /dev/null +++ b/appwrite/models/subscriber.py @@ -0,0 +1,41 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .target import Target + +class Subscriber(AppwriteModel): + """ + Subscriber + + Attributes + ---------- + id : str + Subscriber ID. + createdat : str + Subscriber creation time in ISO 8601 format. + updatedat : str + Subscriber update date in ISO 8601 format. + targetid : str + Target ID. + target : Target + Target. + userid : str + Topic ID. + username : str + User Name. + topicid : str + Topic ID. + providertype : str + The target provider type. Can be one of the following: `email`, `sms` or `push`. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + targetid: str = Field(..., alias='targetId') + target: Target = Field(..., alias='target') + userid: str = Field(..., alias='userId') + username: str = Field(..., alias='userName') + topicid: str = Field(..., alias='topicId') + providertype: str = Field(..., alias='providerType') diff --git a/appwrite/models/subscriber_list.py b/appwrite/models/subscriber_list.py new file mode 100644 index 0000000..446769c --- /dev/null +++ b/appwrite/models/subscriber_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .subscriber import Subscriber + +class SubscriberList(AppwriteModel): + """ + Subscriber list + + Attributes + ---------- + total : float + Total number of subscribers that matched your query. + subscribers : List[Subscriber] + List of subscribers. + """ + total: float = Field(..., alias='total') + subscribers: List[Subscriber] = Field(..., alias='subscribers') diff --git a/appwrite/models/table.py b/appwrite/models/table.py new file mode 100644 index 0000000..dfb05f7 --- /dev/null +++ b/appwrite/models/table.py @@ -0,0 +1,67 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .column_boolean import ColumnBoolean +from .column_integer import ColumnInteger +from .column_float import ColumnFloat +from .column_email import ColumnEmail +from .column_enum import ColumnEnum +from .column_url import ColumnUrl +from .column_ip import ColumnIp +from .column_datetime import ColumnDatetime +from .column_relationship import ColumnRelationship +from .column_point import ColumnPoint +from .column_line import ColumnLine +from .column_polygon import ColumnPolygon +from .column_varchar import ColumnVarchar +from .column_text import ColumnText +from .column_mediumtext import ColumnMediumtext +from .column_longtext import ColumnLongtext +from .column_string import ColumnString +from .column_index import ColumnIndex + +class Table(AppwriteModel): + """ + Table + + Attributes + ---------- + id : str + Table ID. + createdat : str + Table creation date in ISO 8601 format. + updatedat : str + Table update date in ISO 8601 format. + permissions : List[Any] + Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + databaseid : str + Database ID. + name : str + Table name. + enabled : bool + Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. + rowsecurity : bool + Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + columns : List[Union[ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString]] + Table columns. + indexes : List[ColumnIndex] + Table indexes. + bytesmax : float + Maximum row size in bytes. Returns 0 when no limit applies. + bytesused : float + Currently used row size in bytes based on defined columns. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + permissions: List[Any] = Field(..., alias='$permissions') + databaseid: str = Field(..., alias='databaseId') + name: str = Field(..., alias='name') + enabled: bool = Field(..., alias='enabled') + rowsecurity: bool = Field(..., alias='rowSecurity') + columns: List[Union[ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString]] = Field(..., alias='columns') + indexes: List[ColumnIndex] = Field(..., alias='indexes') + bytesmax: float = Field(..., alias='bytesMax') + bytesused: float = Field(..., alias='bytesUsed') diff --git a/appwrite/models/table_list.py b/appwrite/models/table_list.py new file mode 100644 index 0000000..f086e39 --- /dev/null +++ b/appwrite/models/table_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .table import Table + +class TableList(AppwriteModel): + """ + Tables List + + Attributes + ---------- + total : float + Total number of tables that matched your query. + tables : List[Table] + List of tables. + """ + total: float = Field(..., alias='total') + tables: List[Table] = Field(..., alias='tables') diff --git a/appwrite/models/target.py b/appwrite/models/target.py new file mode 100644 index 0000000..6cae848 --- /dev/null +++ b/appwrite/models/target.py @@ -0,0 +1,40 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Target(AppwriteModel): + """ + Target + + Attributes + ---------- + id : str + Target ID. + createdat : str + Target creation time in ISO 8601 format. + updatedat : str + Target update date in ISO 8601 format. + name : str + Target Name. + userid : str + User ID. + providerid : Optional[str] + Provider ID. + providertype : str + The target provider type. Can be one of the following: `email`, `sms` or `push`. + identifier : str + The target identifier. + expired : bool + Is the target expired. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + userid: str = Field(..., alias='userId') + providerid: Optional[str] = Field(default=None, alias='providerId') + providertype: str = Field(..., alias='providerType') + identifier: str = Field(..., alias='identifier') + expired: bool = Field(..., alias='expired') diff --git a/appwrite/models/target_list.py b/appwrite/models/target_list.py new file mode 100644 index 0000000..7398cf2 --- /dev/null +++ b/appwrite/models/target_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .target import Target + +class TargetList(AppwriteModel): + """ + Target list + + Attributes + ---------- + total : float + Total number of targets that matched your query. + targets : List[Target] + List of targets. + """ + total: float = Field(..., alias='total') + targets: List[Target] = Field(..., alias='targets') diff --git a/appwrite/models/team.py b/appwrite/models/team.py new file mode 100644 index 0000000..26e1086 --- /dev/null +++ b/appwrite/models/team.py @@ -0,0 +1,32 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .preferences import Preferences + +class Team(AppwriteModel): + """ + Team + + Attributes + ---------- + id : str + Team ID. + createdat : str + Team creation date in ISO 8601 format. + updatedat : str + Team update date in ISO 8601 format. + name : str + Team name. + total : float + Total number of team members. + prefs : Preferences + Team preferences as a key-value object + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + total: float = Field(..., alias='total') + prefs: Preferences = Field(..., alias='prefs') diff --git a/appwrite/models/team_list.py b/appwrite/models/team_list.py new file mode 100644 index 0000000..f587966 --- /dev/null +++ b/appwrite/models/team_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .team import Team + +class TeamList(AppwriteModel): + """ + Teams List + + Attributes + ---------- + total : float + Total number of teams that matched your query. + teams : List[Team] + List of teams. + """ + total: float = Field(..., alias='total') + teams: List[Team] = Field(..., alias='teams') diff --git a/appwrite/models/token.py b/appwrite/models/token.py new file mode 100644 index 0000000..e59e023 --- /dev/null +++ b/appwrite/models/token.py @@ -0,0 +1,31 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Token(AppwriteModel): + """ + Token + + Attributes + ---------- + id : str + Token ID. + createdat : str + Token creation date in ISO 8601 format. + userid : str + User ID. + secret : str + Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + expire : str + Token expiration date in ISO 8601 format. + phrase : str + Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + userid: str = Field(..., alias='userId') + secret: str = Field(..., alias='secret') + expire: str = Field(..., alias='expire') + phrase: str = Field(..., alias='phrase') diff --git a/appwrite/models/topic.py b/appwrite/models/topic.py new file mode 100644 index 0000000..fd9370f --- /dev/null +++ b/appwrite/models/topic.py @@ -0,0 +1,37 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Topic(AppwriteModel): + """ + Topic + + Attributes + ---------- + id : str + Topic ID. + createdat : str + Topic creation time in ISO 8601 format. + updatedat : str + Topic update date in ISO 8601 format. + name : str + The name of the topic. + emailtotal : float + Total count of email subscribers subscribed to the topic. + smstotal : float + Total count of SMS subscribers subscribed to the topic. + pushtotal : float + Total count of push subscribers subscribed to the topic. + subscribe : List[Any] + Subscribe permissions. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + emailtotal: float = Field(..., alias='emailTotal') + smstotal: float = Field(..., alias='smsTotal') + pushtotal: float = Field(..., alias='pushTotal') + subscribe: List[Any] = Field(..., alias='subscribe') diff --git a/appwrite/models/topic_list.py b/appwrite/models/topic_list.py new file mode 100644 index 0000000..88e654e --- /dev/null +++ b/appwrite/models/topic_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .topic import Topic + +class TopicList(AppwriteModel): + """ + Topic list + + Attributes + ---------- + total : float + Total number of topics that matched your query. + topics : List[Topic] + List of topics. + """ + total: float = Field(..., alias='total') + topics: List[Topic] = Field(..., alias='topics') diff --git a/appwrite/models/transaction.py b/appwrite/models/transaction.py new file mode 100644 index 0000000..762c3f9 --- /dev/null +++ b/appwrite/models/transaction.py @@ -0,0 +1,31 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Transaction(AppwriteModel): + """ + Transaction + + Attributes + ---------- + id : str + Transaction ID. + createdat : str + Transaction creation time in ISO 8601 format. + updatedat : str + Transaction update date in ISO 8601 format. + status : str + Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + operations : float + Number of operations in the transaction. + expiresat : str + Expiration time in ISO 8601 format. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + status: str = Field(..., alias='status') + operations: float = Field(..., alias='operations') + expiresat: str = Field(..., alias='expiresAt') diff --git a/appwrite/models/transaction_list.py b/appwrite/models/transaction_list.py new file mode 100644 index 0000000..b571f2c --- /dev/null +++ b/appwrite/models/transaction_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .transaction import Transaction + +class TransactionList(AppwriteModel): + """ + Transaction List + + Attributes + ---------- + total : float + Total number of transactions that matched your query. + transactions : List[Transaction] + List of transactions. + """ + total: float = Field(..., alias='total') + transactions: List[Transaction] = Field(..., alias='transactions') diff --git a/appwrite/models/user.py b/appwrite/models/user.py new file mode 100644 index 0000000..9a110c8 --- /dev/null +++ b/appwrite/models/user.py @@ -0,0 +1,79 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .algo_argon2 import AlgoArgon2 +from .algo_scrypt import AlgoScrypt +from .algo_scrypt_modified import AlgoScryptModified +from .algo_bcrypt import AlgoBcrypt +from .algo_phpass import AlgoPhpass +from .algo_sha import AlgoSha +from .algo_md5 import AlgoMd5 +from .preferences import Preferences +from .target import Target + +class User(AppwriteModel): + """ + User + + Attributes + ---------- + id : str + User ID. + createdat : str + User creation date in ISO 8601 format. + updatedat : str + User update date in ISO 8601 format. + name : str + User name. + password : Optional[str] + Hashed user password. + hash : Optional[str] + Password hashing algorithm. + hashoptions : Optional[Union[AlgoArgon2, AlgoScrypt, AlgoScryptModified, AlgoBcrypt, AlgoPhpass, AlgoSha, AlgoMd5]] + Password hashing algorithm configuration. + registration : str + User registration date in ISO 8601 format. + status : bool + User status. Pass `true` for enabled and `false` for disabled. + labels : List[Any] + Labels for the user. + passwordupdate : str + Password update time in ISO 8601 format. + email : str + User email address. + phone : str + User phone number in E.164 format. + emailverification : bool + Email verification status. + phoneverification : bool + Phone verification status. + mfa : bool + Multi factor authentication status. + prefs : Preferences + User preferences as a key-value object + targets : List[Target] + A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + accessedat : str + Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + password: Optional[str] = Field(default=None, alias='password') + hash: Optional[str] = Field(default=None, alias='hash') + hashoptions: Optional[Union[AlgoArgon2, AlgoScrypt, AlgoScryptModified, AlgoBcrypt, AlgoPhpass, AlgoSha, AlgoMd5]] = Field(default=None, alias='hashOptions') + registration: str = Field(..., alias='registration') + status: bool = Field(..., alias='status') + labels: List[Any] = Field(..., alias='labels') + passwordupdate: str = Field(..., alias='passwordUpdate') + email: str = Field(..., alias='email') + phone: str = Field(..., alias='phone') + emailverification: bool = Field(..., alias='emailVerification') + phoneverification: bool = Field(..., alias='phoneVerification') + mfa: bool = Field(..., alias='mfa') + prefs: Preferences = Field(..., alias='prefs') + targets: List[Target] = Field(..., alias='targets') + accessedat: str = Field(..., alias='accessedAt') diff --git a/appwrite/models/user_list.py b/appwrite/models/user_list.py new file mode 100644 index 0000000..632c812 --- /dev/null +++ b/appwrite/models/user_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .user import User + +class UserList(AppwriteModel): + """ + Users List + + Attributes + ---------- + total : float + Total number of users that matched your query. + users : List[User] + List of users. + """ + total: float = Field(..., alias='total') + users: List[User] = Field(..., alias='users') diff --git a/appwrite/models/variable.py b/appwrite/models/variable.py new file mode 100644 index 0000000..fee92ba --- /dev/null +++ b/appwrite/models/variable.py @@ -0,0 +1,37 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel + +class Variable(AppwriteModel): + """ + Variable + + Attributes + ---------- + id : str + Variable ID. + createdat : str + Variable creation date in ISO 8601 format. + updatedat : str + Variable creation date in ISO 8601 format. + key : str + Variable key. + value : str + Variable value. + secret : bool + Variable secret flag. Secret variables can only be updated or deleted, but never read. + resourcetype : str + Service to which the variable belongs. Possible values are "project", "function" + resourceid : str + ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + key: str = Field(..., alias='key') + value: str = Field(..., alias='value') + secret: bool = Field(..., alias='secret') + resourcetype: str = Field(..., alias='resourceType') + resourceid: str = Field(..., alias='resourceId') diff --git a/appwrite/models/variable_list.py b/appwrite/models/variable_list.py new file mode 100644 index 0000000..7b973c9 --- /dev/null +++ b/appwrite/models/variable_list.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Union + +from pydantic import Field + +from .base_model import AppwriteModel +from .variable import Variable + +class VariableList(AppwriteModel): + """ + Variables List + + Attributes + ---------- + total : float + Total number of variables that matched your query. + variables : List[Variable] + List of variables. + """ + total: float = Field(..., alias='total') + variables: List[Variable] = Field(..., alias='variables') diff --git a/appwrite/service.py b/appwrite/service.py index f5e2adb..4905af2 100644 --- a/appwrite/service.py +++ b/appwrite/service.py @@ -1,5 +1,60 @@ +from enum import Enum +from typing import Any, Optional, Tuple, Type, TypeVar + +from pydantic import ValidationError + from .client import Client +from .exception import AppwriteException +from .models.base_model import AppwriteModel + +ModelType = TypeVar('ModelType', bound=AppwriteModel) class Service: def __init__(self, client: Client): self.client = client + + def _normalize_value(self, value: Any) -> Any: + if isinstance(value, AppwriteModel): + return value.to_dict() + + if isinstance(value, Enum): + return value.value + + if isinstance(value, list): + return [self._normalize_value(item) for item in value] + + if isinstance(value, dict): + return { + key: self._normalize_value(item) + for key, item in value.items() + } + + return value + + def _parse_response( + self, + response: Any, + model: Optional[Type[ModelType]] = None, + union_models: Optional[Tuple[Type[AppwriteModel], ...]] = None + ) -> Any: + if model is None and not union_models: + return response + + if not isinstance(response, dict): + return response + + if model is not None: + try: + return model.model_validate(response) + except ValidationError as error: + raise AppwriteException( + f'Unable to parse response into {model.__name__}: {error}' + ) from error + + for union_model in union_models or (): + try: + return union_model.model_validate(response) + except ValidationError: + continue + + raise AppwriteException('Unable to parse response into any known model') diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 29bfd00..6580bb8 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -1,9 +1,21 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.user import User; +from ..models.identity_list import IdentityList; +from ..models.jwt import Jwt; +from ..models.log_list import LogList; from ..enums.authenticator_type import AuthenticatorType; +from ..models.mfa_type import MfaType; from ..enums.authentication_factor import AuthenticationFactor; +from ..models.mfa_challenge import MfaChallenge; +from ..models.session import Session; +from ..models.mfa_factors import MfaFactors; +from ..models.mfa_recovery_codes import MfaRecoveryCodes; +from ..models.preferences import Preferences; +from ..models.token import Token; +from ..models.session_list import SessionList; from ..enums.o_auth_provider import OAuthProvider; class Account(Service): @@ -11,14 +23,15 @@ class Account(Service): def __init__(self, client) -> None: super(Account, self).__init__(client) - def get(self) -> Dict[str, Any]: + def get( + self ) -> User: """ Get the currently logged in user. Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -29,10 +42,18 @@ def get(self) -> Dict[str, Any]: api_path = '/account' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create(self, user_id: str, email: str, password: str, name: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def create( + self, + user_id: str, + email: str, + password: str, + name: Optional[str] = None ) -> User: """ Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). @@ -49,8 +70,8 @@ def create(self, user_id: str, email: str, password: str, name: Optional[str] = Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -70,17 +91,23 @@ def create(self, user_id: str, email: str, password: str, name: Optional[str] = raise AppwriteException('Missing required parameter: "password"') - api_params['userId'] = user_id - api_params['email'] = email - api_params['password'] = password + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_email(self, email: str, password: str) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def update_email( + self, + email: str, + password: str ) -> User: """ Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. @@ -95,8 +122,8 @@ def update_email(self, email: str, password: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -113,14 +140,20 @@ def update_email(self, email: str, password: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "password"') - api_params['email'] = email - api_params['password'] = password + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def list_identities(self, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def list_identities( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> IdentityList: """ Get the list of identities for the currently logged in user. @@ -133,8 +166,8 @@ def list_identities(self, queries: Optional[List[str]] = None, total: Optional[b Returns ------- - Dict[str, Any] - API response as a dictionary + IdentityList + API response as a typed Pydantic model Raises ------ @@ -146,14 +179,19 @@ def list_identities(self, queries: Optional[List[str]] = None, total: Optional[b api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_identity(self, identity_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=IdentityList) + + + def delete_identity( + self, + identity_id: str ) -> Dict[str, Any]: """ Delete an identity by its unique ID. @@ -178,14 +216,19 @@ def delete_identity(self, identity_id: str) -> Dict[str, Any]: if identity_id is None: raise AppwriteException('Missing required parameter: "identity_id"') - api_path = api_path.replace('{identityId}', identity_id) + api_path = api_path.replace('{identityId}', str(self._normalize_value(identity_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def create_jwt(self, duration: Optional[float] = None) -> Dict[str, Any]: + return response + + + def create_jwt( + self, + duration: Optional[float] = None ) -> Jwt: """ Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. @@ -196,8 +239,8 @@ def create_jwt(self, duration: Optional[float] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Jwt + API response as a typed Pydantic model Raises ------ @@ -209,13 +252,19 @@ def create_jwt(self, duration: Optional[float] = None) -> Dict[str, Any]: api_params = {} if duration is not None: - api_params['duration'] = duration + api_params['duration'] = self._normalize_value(duration) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def list_logs(self, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Jwt) + + + def list_logs( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> LogList: """ Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. @@ -228,8 +277,8 @@ def list_logs(self, queries: Optional[List[str]] = None, total: Optional[bool] = Returns ------- - Dict[str, Any] - API response as a dictionary + LogList + API response as a typed Pydantic model Raises ------ @@ -241,14 +290,19 @@ def list_logs(self, queries: Optional[List[str]] = None, total: Optional[bool] = api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_mfa(self, mfa: bool) -> Dict[str, Any]: + return self._parse_response(response, model=LogList) + + + def update_mfa( + self, + mfa: bool ) -> User: """ Enable or disable MFA on an account. @@ -259,8 +313,8 @@ def update_mfa(self, mfa: bool) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -274,13 +328,18 @@ def update_mfa(self, mfa: bool) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "mfa"') - api_params['mfa'] = mfa + api_params['mfa'] = self._normalize_value(mfa) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_mfa_authenticator(self, type: AuthenticatorType) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def create_mfa_authenticator( + self, + type: AuthenticatorType ) -> MfaType: """ Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. @@ -291,8 +350,8 @@ def create_mfa_authenticator(self, type: AuthenticatorType) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + MfaType + API response as a typed Pydantic model Raises ------ @@ -305,14 +364,20 @@ def create_mfa_authenticator(self, type: AuthenticatorType) -> Dict[str, Any]: if type is None: raise AppwriteException('Missing required parameter: "type"') - api_path = api_path.replace('{type}', type) + api_path = api_path.replace('{type}', str(self._normalize_value(type))) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_mfa_authenticator(self, type: AuthenticatorType, otp: str) -> Dict[str, Any]: + return self._parse_response(response, model=MfaType) + + + def update_mfa_authenticator( + self, + type: AuthenticatorType, + otp: str ) -> User: """ Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. @@ -325,8 +390,8 @@ def update_mfa_authenticator(self, type: AuthenticatorType, otp: str) -> Dict[st Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -342,15 +407,20 @@ def update_mfa_authenticator(self, type: AuthenticatorType, otp: str) -> Dict[st if otp is None: raise AppwriteException('Missing required parameter: "otp"') - api_path = api_path.replace('{type}', type) + api_path = api_path.replace('{type}', str(self._normalize_value(type))) - api_params['otp'] = otp + api_params['otp'] = self._normalize_value(otp) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete_mfa_authenticator(self, type: AuthenticatorType) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def delete_mfa_authenticator( + self, + type: AuthenticatorType ) -> Dict[str, Any]: """ Delete an authenticator for a user by ID. @@ -375,14 +445,19 @@ def delete_mfa_authenticator(self, type: AuthenticatorType) -> Dict[str, Any]: if type is None: raise AppwriteException('Missing required parameter: "type"') - api_path = api_path.replace('{type}', type) + api_path = api_path.replace('{type}', str(self._normalize_value(type))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def create_mfa_challenge(self, factor: AuthenticationFactor) -> Dict[str, Any]: + return response + + + def create_mfa_challenge( + self, + factor: AuthenticationFactor ) -> MfaChallenge: """ Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. @@ -393,8 +468,8 @@ def create_mfa_challenge(self, factor: AuthenticationFactor) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + MfaChallenge + API response as a typed Pydantic model Raises ------ @@ -408,13 +483,19 @@ def create_mfa_challenge(self, factor: AuthenticationFactor) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "factor"') - api_params['factor'] = factor + api_params['factor'] = self._normalize_value(factor) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_mfa_challenge(self, challenge_id: str, otp: str) -> Dict[str, Any]: + return self._parse_response(response, model=MfaChallenge) + + + def update_mfa_challenge( + self, + challenge_id: str, + otp: str ) -> Session: """ Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. @@ -427,8 +508,8 @@ def update_mfa_challenge(self, challenge_id: str, otp: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Session + API response as a typed Pydantic model Raises ------ @@ -445,21 +526,25 @@ def update_mfa_challenge(self, challenge_id: str, otp: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "otp"') - api_params['challengeId'] = challenge_id - api_params['otp'] = otp + api_params['challengeId'] = self._normalize_value(challenge_id) + api_params['otp'] = self._normalize_value(otp) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def list_mfa_factors(self) -> Dict[str, Any]: + return self._parse_response(response, model=Session) + + + def list_mfa_factors( + self ) -> MfaFactors: """ List the factors available on the account to be used as a MFA challange. Returns ------- - Dict[str, Any] - API response as a dictionary + MfaFactors + API response as a typed Pydantic model Raises ------ @@ -470,17 +555,21 @@ def list_mfa_factors(self) -> Dict[str, Any]: api_path = '/account/mfa/factors' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_mfa_recovery_codes(self) -> Dict[str, Any]: + return self._parse_response(response, model=MfaFactors) + + + def get_mfa_recovery_codes( + self ) -> MfaRecoveryCodes: """ Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. Returns ------- - Dict[str, Any] - API response as a dictionary + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -491,17 +580,21 @@ def get_mfa_recovery_codes(self) -> Dict[str, Any]: api_path = '/account/mfa/recovery-codes' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_mfa_recovery_codes(self) -> Dict[str, Any]: + return self._parse_response(response, model=MfaRecoveryCodes) + + + def create_mfa_recovery_codes( + self ) -> MfaRecoveryCodes: """ Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. Returns ------- - Dict[str, Any] - API response as a dictionary + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -512,18 +605,22 @@ def create_mfa_recovery_codes(self) -> Dict[str, Any]: api_path = '/account/mfa/recovery-codes' api_params = {} - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_mfa_recovery_codes(self) -> Dict[str, Any]: + return self._parse_response(response, model=MfaRecoveryCodes) + + + def update_mfa_recovery_codes( + self ) -> MfaRecoveryCodes: """ Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. Returns ------- - Dict[str, Any] - API response as a dictionary + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -534,11 +631,16 @@ def update_mfa_recovery_codes(self) -> Dict[str, Any]: api_path = '/account/mfa/recovery-codes' api_params = {} - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def update_name(self, name: str) -> Dict[str, Any]: + return self._parse_response(response, model=MfaRecoveryCodes) + + + def update_name( + self, + name: str ) -> User: """ Update currently logged in user account name. @@ -549,8 +651,8 @@ def update_name(self, name: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -564,13 +666,19 @@ def update_name(self, name: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "name"') - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def update_password(self, password: str, old_password: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def update_password( + self, + password: str, + old_password: Optional[str] = None ) -> User: """ Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. @@ -583,8 +691,8 @@ def update_password(self, password: str, old_password: Optional[str] = None) -> Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -598,15 +706,21 @@ def update_password(self, password: str, old_password: Optional[str] = None) -> raise AppwriteException('Missing required parameter: "password"') - api_params['password'] = password + api_params['password'] = self._normalize_value(password) if old_password is not None: - api_params['oldPassword'] = old_password + api_params['oldPassword'] = self._normalize_value(old_password) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def update_phone(self, phone: str, password: str) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def update_phone( + self, + phone: str, + password: str ) -> User: """ Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. @@ -619,8 +733,8 @@ def update_phone(self, phone: str, password: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -637,21 +751,25 @@ def update_phone(self, phone: str, password: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "password"') - api_params['phone'] = phone - api_params['password'] = password + api_params['phone'] = self._normalize_value(phone) + api_params['password'] = self._normalize_value(password) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def get_prefs(self) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def get_prefs( + self ) -> Preferences: """ Get the preferences as a key-value object for the currently logged in user. Returns ------- - Dict[str, Any] - API response as a dictionary + Preferences + API response as a typed Pydantic model Raises ------ @@ -662,22 +780,27 @@ def get_prefs(self) -> Dict[str, Any]: api_path = '/account/prefs' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_prefs(self, prefs: dict) -> Dict[str, Any]: + return self._parse_response(response, model=Preferences) + + + def update_prefs( + self, + prefs: Dict[str, Any] ) -> User: """ Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. Parameters ---------- - prefs : dict + prefs : Dict[str, Any] Prefs key-value JSON object. Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -691,13 +814,19 @@ def update_prefs(self, prefs: dict) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "prefs"') - api_params['prefs'] = prefs + api_params['prefs'] = self._normalize_value(prefs) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_recovery(self, email: str, url: str) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def create_recovery( + self, + email: str, + url: str ) -> Token: """ Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour. @@ -710,8 +839,8 @@ def create_recovery(self, email: str, url: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -728,14 +857,21 @@ def create_recovery(self, email: str, url: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "url"') - api_params['email'] = email - api_params['url'] = url + api_params['email'] = self._normalize_value(email) + api_params['url'] = self._normalize_value(url) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_recovery(self, user_id: str, secret: str, password: str) -> Dict[str, Any]: + return self._parse_response(response, model=Token) + + + def update_recovery( + self, + user_id: str, + secret: str, + password: str ) -> Token: """ Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint. @@ -752,8 +888,8 @@ def update_recovery(self, user_id: str, secret: str, password: str) -> Dict[str, Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -773,22 +909,26 @@ def update_recovery(self, user_id: str, secret: str, password: str) -> Dict[str, raise AppwriteException('Missing required parameter: "password"') - api_params['userId'] = user_id - api_params['secret'] = secret - api_params['password'] = password + api_params['userId'] = self._normalize_value(user_id) + api_params['secret'] = self._normalize_value(secret) + api_params['password'] = self._normalize_value(password) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def list_sessions(self) -> Dict[str, Any]: + return self._parse_response(response, model=Token) + + + def list_sessions( + self ) -> SessionList: """ Get the list of active sessions across different devices for the currently logged in user. Returns ------- - Dict[str, Any] - API response as a dictionary + SessionList + API response as a typed Pydantic model Raises ------ @@ -799,10 +939,14 @@ def list_sessions(self) -> Dict[str, Any]: api_path = '/account/sessions' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_sessions(self) -> Dict[str, Any]: + return self._parse_response(response, model=SessionList) + + + def delete_sessions( + self ) -> Dict[str, Any]: """ Delete all sessions from the user account and remove any sessions cookies from the end client. @@ -820,18 +964,22 @@ def delete_sessions(self) -> Dict[str, Any]: api_path = '/account/sessions' api_params = {} - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def create_anonymous_session(self) -> Dict[str, Any]: + return response + + + def create_anonymous_session( + self ) -> Session: """ Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). Returns ------- - Dict[str, Any] - API response as a dictionary + Session + API response as a typed Pydantic model Raises ------ @@ -842,11 +990,17 @@ def create_anonymous_session(self) -> Dict[str, Any]: api_path = '/account/sessions/anonymous' api_params = {} - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_email_password_session(self, email: str, password: str) -> Dict[str, Any]: + return self._parse_response(response, model=Session) + + + def create_email_password_session( + self, + email: str, + password: str ) -> Session: """ Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. @@ -861,8 +1015,8 @@ def create_email_password_session(self, email: str, password: str) -> Dict[str, Returns ------- - Dict[str, Any] - API response as a dictionary + Session + API response as a typed Pydantic model Raises ------ @@ -879,15 +1033,21 @@ def create_email_password_session(self, email: str, password: str) -> Dict[str, raise AppwriteException('Missing required parameter: "password"') - api_params['email'] = email - api_params['password'] = password + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Session) + + @deprecated("This API has been deprecated since 1.6.0. Please use `account.create_session` instead.") - def update_magic_url_session(self, user_id: str, secret: str) -> Dict[str, Any]: + def update_magic_url_session( + self, + user_id: str, + secret: str ) -> Session: """ Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -902,8 +1062,8 @@ def update_magic_url_session(self, user_id: str, secret: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Session + API response as a typed Pydantic model Raises ------ @@ -920,15 +1080,21 @@ def update_magic_url_session(self, user_id: str, secret: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "secret"') - api_params['userId'] = user_id - api_params['secret'] = secret + api_params['userId'] = self._normalize_value(user_id) + api_params['secret'] = self._normalize_value(secret) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Session) + + @deprecated("This API has been deprecated since 1.6.0. Please use `account.create_session` instead.") - def update_phone_session(self, user_id: str, secret: str) -> Dict[str, Any]: + def update_phone_session( + self, + user_id: str, + secret: str ) -> Session: """ Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -943,8 +1109,8 @@ def update_phone_session(self, user_id: str, secret: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Session + API response as a typed Pydantic model Raises ------ @@ -961,14 +1127,20 @@ def update_phone_session(self, user_id: str, secret: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "secret"') - api_params['userId'] = user_id - api_params['secret'] = secret + api_params['userId'] = self._normalize_value(user_id) + api_params['secret'] = self._normalize_value(secret) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def create_session(self, user_id: str, secret: str) -> Dict[str, Any]: + return self._parse_response(response, model=Session) + + + def create_session( + self, + user_id: str, + secret: str ) -> Session: """ Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -981,8 +1153,8 @@ def create_session(self, user_id: str, secret: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Session + API response as a typed Pydantic model Raises ------ @@ -999,14 +1171,19 @@ def create_session(self, user_id: str, secret: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "secret"') - api_params['userId'] = user_id - api_params['secret'] = secret + api_params['userId'] = self._normalize_value(user_id) + api_params['secret'] = self._normalize_value(secret) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_session(self, session_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Session) + + + def get_session( + self, + session_id: str ) -> Session: """ Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. @@ -1017,8 +1194,8 @@ def get_session(self, session_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Session + API response as a typed Pydantic model Raises ------ @@ -1031,13 +1208,18 @@ def get_session(self, session_id: str) -> Dict[str, Any]: if session_id is None: raise AppwriteException('Missing required parameter: "session_id"') - api_path = api_path.replace('{sessionId}', session_id) + api_path = api_path.replace('{sessionId}', str(self._normalize_value(session_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_session(self, session_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Session) + + + def update_session( + self, + session_id: str ) -> Session: """ Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. @@ -1048,8 +1230,8 @@ def update_session(self, session_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Session + API response as a typed Pydantic model Raises ------ @@ -1062,14 +1244,19 @@ def update_session(self, session_id: str) -> Dict[str, Any]: if session_id is None: raise AppwriteException('Missing required parameter: "session_id"') - api_path = api_path.replace('{sessionId}', session_id) + api_path = api_path.replace('{sessionId}', str(self._normalize_value(session_id))) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_session(self, session_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Session) + + + def delete_session( + self, + session_id: str ) -> Dict[str, Any]: """ Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. @@ -1094,21 +1281,25 @@ def delete_session(self, session_id: str) -> Dict[str, Any]: if session_id is None: raise AppwriteException('Missing required parameter: "session_id"') - api_path = api_path.replace('{sessionId}', session_id) + api_path = api_path.replace('{sessionId}', str(self._normalize_value(session_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def update_status(self) -> Dict[str, Any]: + return response + + + def update_status( + self ) -> User: """ Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -1119,11 +1310,18 @@ def update_status(self) -> Dict[str, Any]: api_path = '/account/status' api_params = {} - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_email_token(self, user_id: str, email: str, phrase: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def create_email_token( + self, + user_id: str, + email: str, + phrase: Optional[bool] = None ) -> Token: """ Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. @@ -1141,8 +1339,8 @@ def create_email_token(self, user_id: str, email: str, phrase: Optional[bool] = Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1159,16 +1357,24 @@ def create_email_token(self, user_id: str, email: str, phrase: Optional[bool] = raise AppwriteException('Missing required parameter: "email"') - api_params['userId'] = user_id - api_params['email'] = email + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) if phrase is not None: - api_params['phrase'] = phrase + api_params['phrase'] = self._normalize_value(phrase) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_magic_url_token(self, user_id: str, email: str, url: Optional[str] = None, phrase: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Token) + + + def create_magic_url_token( + self, + user_id: str, + email: str, + url: Optional[str] = None, + phrase: Optional[bool] = None ) -> Token: """ Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. @@ -1188,8 +1394,8 @@ def create_magic_url_token(self, user_id: str, email: str, url: Optional[str] = Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1206,18 +1412,26 @@ def create_magic_url_token(self, user_id: str, email: str, url: Optional[str] = raise AppwriteException('Missing required parameter: "email"') - api_params['userId'] = user_id - api_params['email'] = email + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) if url is not None: - api_params['url'] = url + api_params['url'] = self._normalize_value(url) if phrase is not None: - api_params['phrase'] = phrase + api_params['phrase'] = self._normalize_value(phrase) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_o_auth2_token(self, provider: OAuthProvider, success: Optional[str] = None, failure: Optional[str] = None, scopes: Optional[List[str]] = None) -> str: + return self._parse_response(response, model=Token) + + + def create_o_auth2_token( + self, + provider: OAuthProvider, + success: Optional[str] = None, + failure: Optional[str] = None, + scopes: Optional[List[str]] = None ) -> str: """ Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. @@ -1252,19 +1466,25 @@ def create_o_auth2_token(self, provider: OAuthProvider, success: Optional[str] = if provider is None: raise AppwriteException('Missing required parameter: "provider"') - api_path = api_path.replace('{provider}', provider) + api_path = api_path.replace('{provider}', str(self._normalize_value(provider))) if success is not None: - api_params['success'] = success + api_params['success'] = self._normalize_value(success) if failure is not None: - api_params['failure'] = failure + api_params['failure'] = self._normalize_value(failure) if scopes is not None: - api_params['scopes'] = scopes + api_params['scopes'] = self._normalize_value(scopes) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params, response_type='location') - def create_phone_token(self, user_id: str, phone: str) -> Dict[str, Any]: + return response + + + def create_phone_token( + self, + user_id: str, + phone: str ) -> Token: """ Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. @@ -1279,8 +1499,8 @@ def create_phone_token(self, user_id: str, phone: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1297,14 +1517,19 @@ def create_phone_token(self, user_id: str, phone: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "phone"') - api_params['userId'] = user_id - api_params['phone'] = phone + api_params['userId'] = self._normalize_value(user_id) + api_params['phone'] = self._normalize_value(phone) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_email_verification(self, url: str) -> Dict[str, Any]: + return self._parse_response(response, model=Token) + + + def create_email_verification( + self, + url: str ) -> Token: """ Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. @@ -1318,8 +1543,8 @@ def create_email_verification(self, url: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1333,14 +1558,19 @@ def create_email_verification(self, url: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "url"') - api_params['url'] = url + api_params['url'] = self._normalize_value(url) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Token) + + @deprecated("This API has been deprecated since 1.8.0. Please use `account.create_email_verification` instead.") - def create_verification(self, url: str) -> Dict[str, Any]: + def create_verification( + self, + url: str ) -> Token: """ Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. @@ -1356,8 +1586,8 @@ def create_verification(self, url: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1371,13 +1601,19 @@ def create_verification(self, url: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "url"') - api_params['url'] = url + api_params['url'] = self._normalize_value(url) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_email_verification(self, user_id: str, secret: str) -> Dict[str, Any]: + return self._parse_response(response, model=Token) + + + def update_email_verification( + self, + user_id: str, + secret: str ) -> Token: """ Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -1390,8 +1626,8 @@ def update_email_verification(self, user_id: str, secret: str) -> Dict[str, Any] Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1408,15 +1644,21 @@ def update_email_verification(self, user_id: str, secret: str) -> Dict[str, Any] raise AppwriteException('Missing required parameter: "secret"') - api_params['userId'] = user_id - api_params['secret'] = secret + api_params['userId'] = self._normalize_value(user_id) + api_params['secret'] = self._normalize_value(secret) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Token) + + @deprecated("This API has been deprecated since 1.8.0. Please use `account.update_email_verification` instead.") - def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]: + def update_verification( + self, + user_id: str, + secret: str ) -> Token: """ Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -1431,8 +1673,8 @@ def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1449,21 +1691,25 @@ def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "secret"') - api_params['userId'] = user_id - api_params['secret'] = secret + api_params['userId'] = self._normalize_value(user_id) + api_params['secret'] = self._normalize_value(secret) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def create_phone_verification(self) -> Dict[str, Any]: + return self._parse_response(response, model=Token) + + + def create_phone_verification( + self ) -> Token: """ Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1474,11 +1720,17 @@ def create_phone_verification(self) -> Dict[str, Any]: api_path = '/account/verifications/phone' api_params = {} - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_phone_verification(self, user_id: str, secret: str) -> Dict[str, Any]: + return self._parse_response(response, model=Token) + + + def update_phone_verification( + self, + user_id: str, + secret: str ) -> Token: """ Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -1491,8 +1743,8 @@ def update_phone_verification(self, user_id: str, secret: str) -> Dict[str, Any] Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1509,9 +1761,12 @@ def update_phone_verification(self, user_id: str, secret: str) -> Dict[str, Any] raise AppwriteException('Missing required parameter: "secret"') - api_params['userId'] = user_id - api_params['secret'] = secret + api_params['userId'] = self._normalize_value(user_id) + api_params['secret'] = self._normalize_value(secret) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) + + return self._parse_response(response, model=Token) + diff --git a/appwrite/services/activities.py b/appwrite/services/activities.py index 97a6af1..cc91583 100644 --- a/appwrite/services/activities.py +++ b/appwrite/services/activities.py @@ -1,14 +1,18 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.activity_event_list import ActivityEventList; +from ..models.activity_event import ActivityEvent; class Activities(Service): def __init__(self, client) -> None: super(Activities, self).__init__(client) - def list_events(self, queries: Optional[str] = None) -> Dict[str, Any]: + def list_events( + self, + queries: Optional[str] = None ) -> ActivityEventList: """ List all events for selected filters. @@ -19,8 +23,8 @@ def list_events(self, queries: Optional[str] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + ActivityEventList + API response as a typed Pydantic model Raises ------ @@ -32,12 +36,17 @@ def list_events(self, queries: Optional[str] = None) -> Dict[str, Any]: api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_event(self, event_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=ActivityEventList) + + + def get_event( + self, + event_id: str ) -> ActivityEvent: """ Get event by ID. @@ -49,8 +58,8 @@ def get_event(self, event_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + ActivityEvent + API response as a typed Pydantic model Raises ------ @@ -63,8 +72,11 @@ def get_event(self, event_id: str) -> Dict[str, Any]: if event_id is None: raise AppwriteException('Missing required parameter: "event_id"') - api_path = api_path.replace('{eventId}', event_id) + api_path = api_path.replace('{eventId}', str(self._normalize_value(event_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + + return self._parse_response(response, model=ActivityEvent) + diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index ef41db9..17b397b 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -1,5 +1,5 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated from ..enums.browser import Browser; @@ -15,7 +15,12 @@ class Avatars(Service): def __init__(self, client) -> None: super(Avatars, self).__init__(client) - def get_browser(self, code: Browser, width: Optional[float] = None, height: Optional[float] = None, quality: Optional[float] = None) -> bytes: + def get_browser( + self, + code: Browser, + width: Optional[float] = None, + height: Optional[float] = None, + quality: Optional[float] = None ) -> bytes: """ You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. @@ -48,19 +53,27 @@ def get_browser(self, code: Browser, width: Optional[float] = None, height: Opti if code is None: raise AppwriteException('Missing required parameter: "code"') - api_path = api_path.replace('{code}', code) + api_path = api_path.replace('{code}', str(self._normalize_value(code))) if width is not None: - api_params['width'] = width + api_params['width'] = self._normalize_value(width) if height is not None: - api_params['height'] = height + api_params['height'] = self._normalize_value(height) if quality is not None: - api_params['quality'] = quality + api_params['quality'] = self._normalize_value(quality) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_credit_card(self, code: CreditCard, width: Optional[float] = None, height: Optional[float] = None, quality: Optional[float] = None) -> bytes: + return response + + + def get_credit_card( + self, + code: CreditCard, + width: Optional[float] = None, + height: Optional[float] = None, + quality: Optional[float] = None ) -> bytes: """ The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. @@ -94,19 +107,24 @@ def get_credit_card(self, code: CreditCard, width: Optional[float] = None, heigh if code is None: raise AppwriteException('Missing required parameter: "code"') - api_path = api_path.replace('{code}', code) + api_path = api_path.replace('{code}', str(self._normalize_value(code))) if width is not None: - api_params['width'] = width + api_params['width'] = self._normalize_value(width) if height is not None: - api_params['height'] = height + api_params['height'] = self._normalize_value(height) if quality is not None: - api_params['quality'] = quality + api_params['quality'] = self._normalize_value(quality) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_favicon(self, url: str) -> bytes: + return response + + + def get_favicon( + self, + url: str ) -> bytes: """ Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. @@ -134,12 +152,20 @@ def get_favicon(self, url: str) -> bytes: raise AppwriteException('Missing required parameter: "url"') - api_params['url'] = url + api_params['url'] = self._normalize_value(url) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_flag(self, code: Flag, width: Optional[float] = None, height: Optional[float] = None, quality: Optional[float] = None) -> bytes: + return response + + + def get_flag( + self, + code: Flag, + width: Optional[float] = None, + height: Optional[float] = None, + quality: Optional[float] = None ) -> bytes: """ You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. @@ -173,19 +199,26 @@ def get_flag(self, code: Flag, width: Optional[float] = None, height: Optional[f if code is None: raise AppwriteException('Missing required parameter: "code"') - api_path = api_path.replace('{code}', code) + api_path = api_path.replace('{code}', str(self._normalize_value(code))) if width is not None: - api_params['width'] = width + api_params['width'] = self._normalize_value(width) if height is not None: - api_params['height'] = height + api_params['height'] = self._normalize_value(height) if quality is not None: - api_params['quality'] = quality + api_params['quality'] = self._normalize_value(quality) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_image(self, url: str, width: Optional[float] = None, height: Optional[float] = None) -> bytes: + return response + + + def get_image( + self, + url: str, + width: Optional[float] = None, + height: Optional[float] = None ) -> bytes: """ Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. @@ -219,16 +252,24 @@ def get_image(self, url: str, width: Optional[float] = None, height: Optional[fl raise AppwriteException('Missing required parameter: "url"') - api_params['url'] = url + api_params['url'] = self._normalize_value(url) if width is not None: - api_params['width'] = width + api_params['width'] = self._normalize_value(width) if height is not None: - api_params['height'] = height + api_params['height'] = self._normalize_value(height) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_initials(self, name: Optional[str] = None, width: Optional[float] = None, height: Optional[float] = None, background: Optional[str] = None) -> bytes: + return response + + + def get_initials( + self, + name: Optional[str] = None, + width: Optional[float] = None, + height: Optional[float] = None, + background: Optional[str] = None ) -> bytes: """ Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. @@ -263,18 +304,26 @@ def get_initials(self, name: Optional[str] = None, width: Optional[float] = None api_params = {} if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) if width is not None: - api_params['width'] = width + api_params['width'] = self._normalize_value(width) if height is not None: - api_params['height'] = height + api_params['height'] = self._normalize_value(height) if background is not None: - api_params['background'] = background + api_params['background'] = self._normalize_value(background) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_qr(self, text: str, size: Optional[float] = None, margin: Optional[float] = None, download: Optional[bool] = None) -> bytes: + return response + + + def get_qr( + self, + text: str, + size: Optional[float] = None, + margin: Optional[float] = None, + download: Optional[bool] = None ) -> bytes: """ Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. @@ -307,18 +356,42 @@ def get_qr(self, text: str, size: Optional[float] = None, margin: Optional[float raise AppwriteException('Missing required parameter: "text"') - api_params['text'] = text + api_params['text'] = self._normalize_value(text) if size is not None: - api_params['size'] = size + api_params['size'] = self._normalize_value(size) if margin is not None: - api_params['margin'] = margin + api_params['margin'] = self._normalize_value(margin) if download is not None: - api_params['download'] = download + api_params['download'] = self._normalize_value(download) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_screenshot(self, url: str, headers: Optional[dict] = None, viewport_width: Optional[float] = None, viewport_height: Optional[float] = None, scale: Optional[float] = None, theme: Optional[Theme] = None, user_agent: Optional[str] = None, fullpage: Optional[bool] = None, locale: Optional[str] = None, timezone: Optional[Timezone] = None, latitude: Optional[float] = None, longitude: Optional[float] = None, accuracy: Optional[float] = None, touch: Optional[bool] = None, permissions: Optional[List[BrowserPermission]] = None, sleep: Optional[float] = None, width: Optional[float] = None, height: Optional[float] = None, quality: Optional[float] = None, output: Optional[ImageFormat] = None) -> bytes: + return response + + + def get_screenshot( + self, + url: str, + headers: Optional[Dict[str, Any]] = None, + viewport_width: Optional[float] = None, + viewport_height: Optional[float] = None, + scale: Optional[float] = None, + theme: Optional[Theme] = None, + user_agent: Optional[str] = None, + fullpage: Optional[bool] = None, + locale: Optional[str] = None, + timezone: Optional[Timezone] = None, + latitude: Optional[float] = None, + longitude: Optional[float] = None, + accuracy: Optional[float] = None, + touch: Optional[bool] = None, + permissions: Optional[List[BrowserPermission]] = None, + sleep: Optional[float] = None, + width: Optional[float] = None, + height: Optional[float] = None, + quality: Optional[float] = None, + output: Optional[ImageFormat] = None ) -> bytes: """ Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. @@ -330,7 +403,7 @@ def get_screenshot(self, url: str, headers: Optional[dict] = None, viewport_widt ---------- url : str Website URL which you want to capture. - headers : Optional[dict] + headers : Optional[Dict[str, Any]] HTTP headers to send with the browser request. Defaults to empty. viewport_width : Optional[float] Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. @@ -386,45 +459,48 @@ def get_screenshot(self, url: str, headers: Optional[dict] = None, viewport_widt raise AppwriteException('Missing required parameter: "url"') - api_params['url'] = url + api_params['url'] = self._normalize_value(url) if headers is not None: - api_params['headers'] = headers + api_params['headers'] = self._normalize_value(headers) if viewport_width is not None: - api_params['viewportWidth'] = viewport_width + api_params['viewportWidth'] = self._normalize_value(viewport_width) if viewport_height is not None: - api_params['viewportHeight'] = viewport_height + api_params['viewportHeight'] = self._normalize_value(viewport_height) if scale is not None: - api_params['scale'] = scale + api_params['scale'] = self._normalize_value(scale) if theme is not None: - api_params['theme'] = theme + api_params['theme'] = self._normalize_value(theme) if user_agent is not None: - api_params['userAgent'] = user_agent + api_params['userAgent'] = self._normalize_value(user_agent) if fullpage is not None: - api_params['fullpage'] = fullpage + api_params['fullpage'] = self._normalize_value(fullpage) if locale is not None: - api_params['locale'] = locale + api_params['locale'] = self._normalize_value(locale) if timezone is not None: - api_params['timezone'] = timezone + api_params['timezone'] = self._normalize_value(timezone) if latitude is not None: - api_params['latitude'] = latitude + api_params['latitude'] = self._normalize_value(latitude) if longitude is not None: - api_params['longitude'] = longitude + api_params['longitude'] = self._normalize_value(longitude) if accuracy is not None: - api_params['accuracy'] = accuracy + api_params['accuracy'] = self._normalize_value(accuracy) if touch is not None: - api_params['touch'] = touch + api_params['touch'] = self._normalize_value(touch) if permissions is not None: - api_params['permissions'] = permissions + api_params['permissions'] = self._normalize_value(permissions) if sleep is not None: - api_params['sleep'] = sleep + api_params['sleep'] = self._normalize_value(sleep) if width is not None: - api_params['width'] = width + api_params['width'] = self._normalize_value(width) if height is not None: - api_params['height'] = height + api_params['height'] = self._normalize_value(height) if quality is not None: - api_params['quality'] = quality + api_params['quality'] = self._normalize_value(quality) if output is not None: - api_params['output'] = output + api_params['output'] = self._normalize_value(output) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + + return response + diff --git a/appwrite/services/backups.py b/appwrite/services/backups.py index 2e68942..154c66f 100644 --- a/appwrite/services/backups.py +++ b/appwrite/services/backups.py @@ -1,15 +1,23 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.backup_archive_list import BackupArchiveList; from ..enums.backup_services import BackupServices; +from ..models.backup_archive import BackupArchive; +from ..models.backup_policy_list import BackupPolicyList; +from ..models.backup_policy import BackupPolicy; +from ..models.backup_restoration import BackupRestoration; +from ..models.backup_restoration_list import BackupRestorationList; class Backups(Service): def __init__(self, client) -> None: super(Backups, self).__init__(client) - def list_archives(self, queries: Optional[List[str]] = None) -> Dict[str, Any]: + def list_archives( + self, + queries: Optional[List[str]] = None ) -> BackupArchiveList: """ List all archives for a project. @@ -20,8 +28,8 @@ def list_archives(self, queries: Optional[List[str]] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + BackupArchiveList + API response as a typed Pydantic model Raises ------ @@ -33,12 +41,18 @@ def list_archives(self, queries: Optional[List[str]] = None) -> Dict[str, Any]: api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_archive(self, services: List[BackupServices], resource_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=BackupArchiveList) + + + def create_archive( + self, + services: List[BackupServices], + resource_id: Optional[str] = None ) -> BackupArchive: """ Create a new archive asynchronously for a project. @@ -51,8 +65,8 @@ def create_archive(self, services: List[BackupServices], resource_id: Optional[s Returns ------- - Dict[str, Any] - API response as a dictionary + BackupArchive + API response as a typed Pydantic model Raises ------ @@ -66,14 +80,19 @@ def create_archive(self, services: List[BackupServices], resource_id: Optional[s raise AppwriteException('Missing required parameter: "services"') - api_params['services'] = services - api_params['resourceId'] = resource_id + api_params['services'] = self._normalize_value(services) + api_params['resourceId'] = self._normalize_value(resource_id) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_archive(self, archive_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=BackupArchive) + + + def get_archive( + self, + archive_id: str ) -> BackupArchive: """ Get a backup archive using it's ID. @@ -84,8 +103,8 @@ def get_archive(self, archive_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + BackupArchive + API response as a typed Pydantic model Raises ------ @@ -98,13 +117,18 @@ def get_archive(self, archive_id: str) -> Dict[str, Any]: if archive_id is None: raise AppwriteException('Missing required parameter: "archive_id"') - api_path = api_path.replace('{archiveId}', archive_id) + api_path = api_path.replace('{archiveId}', str(self._normalize_value(archive_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_archive(self, archive_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=BackupArchive) + + + def delete_archive( + self, + archive_id: str ) -> Dict[str, Any]: """ Delete an existing archive for a project. @@ -129,14 +153,19 @@ def delete_archive(self, archive_id: str) -> Dict[str, Any]: if archive_id is None: raise AppwriteException('Missing required parameter: "archive_id"') - api_path = api_path.replace('{archiveId}', archive_id) + api_path = api_path.replace('{archiveId}', str(self._normalize_value(archive_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_policies(self, queries: Optional[List[str]] = None) -> Dict[str, Any]: + return response + + + def list_policies( + self, + queries: Optional[List[str]] = None ) -> BackupPolicyList: """ List all policies for a project. @@ -147,8 +176,8 @@ def list_policies(self, queries: Optional[List[str]] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + BackupPolicyList + API response as a typed Pydantic model Raises ------ @@ -160,12 +189,23 @@ def list_policies(self, queries: Optional[List[str]] = None) -> Dict[str, Any]: api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_policy(self, policy_id: str, services: List[BackupServices], retention: float, schedule: str, name: Optional[str] = None, resource_id: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=BackupPolicyList) + + + def create_policy( + self, + policy_id: str, + services: List[BackupServices], + retention: float, + schedule: str, + name: Optional[str] = None, + resource_id: Optional[str] = None, + enabled: Optional[bool] = None ) -> BackupPolicy: """ Create a new backup policy. @@ -188,8 +228,8 @@ def create_policy(self, policy_id: str, services: List[BackupServices], retentio Returns ------- - Dict[str, Any] - API response as a dictionary + BackupPolicy + API response as a typed Pydantic model Raises ------ @@ -212,21 +252,26 @@ def create_policy(self, policy_id: str, services: List[BackupServices], retentio raise AppwriteException('Missing required parameter: "schedule"') - api_params['policyId'] = policy_id + api_params['policyId'] = self._normalize_value(policy_id) if name is not None: - api_params['name'] = name - api_params['services'] = services - api_params['resourceId'] = resource_id + api_params['name'] = self._normalize_value(name) + api_params['services'] = self._normalize_value(services) + api_params['resourceId'] = self._normalize_value(resource_id) if enabled is not None: - api_params['enabled'] = enabled - api_params['retention'] = retention - api_params['schedule'] = schedule + api_params['enabled'] = self._normalize_value(enabled) + api_params['retention'] = self._normalize_value(retention) + api_params['schedule'] = self._normalize_value(schedule) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_policy(self, policy_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=BackupPolicy) + + + def get_policy( + self, + policy_id: str ) -> BackupPolicy: """ Get a backup policy using it's ID. @@ -237,8 +282,8 @@ def get_policy(self, policy_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + BackupPolicy + API response as a typed Pydantic model Raises ------ @@ -251,13 +296,22 @@ def get_policy(self, policy_id: str) -> Dict[str, Any]: if policy_id is None: raise AppwriteException('Missing required parameter: "policy_id"') - api_path = api_path.replace('{policyId}', policy_id) + api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_policy(self, policy_id: str, name: Optional[str] = None, retention: Optional[float] = None, schedule: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=BackupPolicy) + + + def update_policy( + self, + policy_id: str, + name: Optional[str] = None, + retention: Optional[float] = None, + schedule: Optional[str] = None, + enabled: Optional[bool] = None ) -> BackupPolicy: """ Update an existing policy using it's ID. @@ -276,8 +330,8 @@ def update_policy(self, policy_id: str, name: Optional[str] = None, retention: O Returns ------- - Dict[str, Any] - API response as a dictionary + BackupPolicy + API response as a typed Pydantic model Raises ------ @@ -290,19 +344,24 @@ def update_policy(self, policy_id: str, name: Optional[str] = None, retention: O if policy_id is None: raise AppwriteException('Missing required parameter: "policy_id"') - api_path = api_path.replace('{policyId}', policy_id) + api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - api_params['name'] = name - api_params['retention'] = retention + api_params['name'] = self._normalize_value(name) + api_params['retention'] = self._normalize_value(retention) if schedule is not None: - api_params['schedule'] = schedule - api_params['enabled'] = enabled + api_params['schedule'] = self._normalize_value(schedule) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_policy(self, policy_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=BackupPolicy) + + + def delete_policy( + self, + policy_id: str ) -> Dict[str, Any]: """ Delete a policy using it's ID. @@ -327,14 +386,22 @@ def delete_policy(self, policy_id: str) -> Dict[str, Any]: if policy_id is None: raise AppwriteException('Missing required parameter: "policy_id"') - api_path = api_path.replace('{policyId}', policy_id) + api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def create_restoration(self, archive_id: str, services: List[BackupServices], new_resource_id: Optional[str] = None, new_resource_name: Optional[str] = None) -> Dict[str, Any]: + return response + + + def create_restoration( + self, + archive_id: str, + services: List[BackupServices], + new_resource_id: Optional[str] = None, + new_resource_name: Optional[str] = None ) -> BackupRestoration: """ Create and trigger a new restoration for a backup on a project. @@ -351,8 +418,8 @@ def create_restoration(self, archive_id: str, services: List[BackupServices], ne Returns ------- - Dict[str, Any] - API response as a dictionary + BackupRestoration + API response as a typed Pydantic model Raises ------ @@ -369,18 +436,23 @@ def create_restoration(self, archive_id: str, services: List[BackupServices], ne raise AppwriteException('Missing required parameter: "services"') - api_params['archiveId'] = archive_id - api_params['services'] = services + api_params['archiveId'] = self._normalize_value(archive_id) + api_params['services'] = self._normalize_value(services) if new_resource_id is not None: - api_params['newResourceId'] = new_resource_id + api_params['newResourceId'] = self._normalize_value(new_resource_id) if new_resource_name is not None: - api_params['newResourceName'] = new_resource_name + api_params['newResourceName'] = self._normalize_value(new_resource_name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def list_restorations(self, queries: Optional[List[str]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=BackupRestoration) + + + def list_restorations( + self, + queries: Optional[List[str]] = None ) -> BackupRestorationList: """ List all backup restorations for a project. @@ -391,8 +463,8 @@ def list_restorations(self, queries: Optional[List[str]] = None) -> Dict[str, An Returns ------- - Dict[str, Any] - API response as a dictionary + BackupRestorationList + API response as a typed Pydantic model Raises ------ @@ -404,12 +476,17 @@ def list_restorations(self, queries: Optional[List[str]] = None) -> Dict[str, An api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_restoration(self, restoration_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=BackupRestorationList) + + + def get_restoration( + self, + restoration_id: str ) -> BackupRestoration: """ Get the current status of a backup restoration. @@ -420,8 +497,8 @@ def get_restoration(self, restoration_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + BackupRestoration + API response as a typed Pydantic model Raises ------ @@ -434,8 +511,11 @@ def get_restoration(self, restoration_id: str) -> Dict[str, Any]: if restoration_id is None: raise AppwriteException('Missing required parameter: "restoration_id"') - api_path = api_path.replace('{restorationId}', restoration_id) + api_path = api_path.replace('{restorationId}', str(self._normalize_value(restoration_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + + return self._parse_response(response, model=BackupRestoration) + diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 376d723..b2c65bd 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -1,11 +1,39 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.database_list import DatabaseList; +from ..models.database import Database; +from ..models.transaction_list import TransactionList; +from ..models.transaction import Transaction; +from ..models.collection_list import CollectionList; +from ..models.collection import Collection; +from ..models.attribute_list import AttributeList; +from ..models.attribute_boolean import AttributeBoolean; +from ..models.attribute_datetime import AttributeDatetime; +from ..models.attribute_email import AttributeEmail; +from ..models.attribute_enum import AttributeEnum; +from ..models.attribute_float import AttributeFloat; +from ..models.attribute_integer import AttributeInteger; +from ..models.attribute_ip import AttributeIp; +from ..models.attribute_line import AttributeLine; +from ..models.attribute_longtext import AttributeLongtext; +from ..models.attribute_mediumtext import AttributeMediumtext; +from ..models.attribute_point import AttributePoint; +from ..models.attribute_polygon import AttributePolygon; from ..enums.relationship_type import RelationshipType; from ..enums.relation_mutate import RelationMutate; +from ..models.attribute_relationship import AttributeRelationship; +from ..models.attribute_string import AttributeString; +from ..models.attribute_text import AttributeText; +from ..models.attribute_url import AttributeUrl; +from ..models.attribute_varchar import AttributeVarchar; +from ..models.document_list import DocumentList; +from ..models.document import Document; +from ..models.index_list import IndexList; from ..enums.index_type import IndexType; from ..enums.order_by import OrderBy; +from ..models.index import Index; class Databases(Service): @@ -13,7 +41,11 @@ def __init__(self, client) -> None: super(Databases, self).__init__(client) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list` instead.") - def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> DatabaseList: """ Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. @@ -30,8 +62,8 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None Returns ------- - Dict[str, Any] - API response as a dictionary + DatabaseList + API response as a typed Pydantic model Raises ------ @@ -43,17 +75,24 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, model=DatabaseList) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create` instead.") - def create(self, database_id: str, name: str, enabled: Optional[bool] = None) -> Dict[str, Any]: + def create( + self, + database_id: str, + name: str, + enabled: Optional[bool] = None ) -> Database: """ Create a new Database. @@ -71,8 +110,8 @@ def create(self, database_id: str, name: str, enabled: Optional[bool] = None) -> Returns ------- - Dict[str, Any] - API response as a dictionary + Database + API response as a typed Pydantic model Raises ------ @@ -89,16 +128,21 @@ def create(self, database_id: str, name: str, enabled: Optional[bool] = None) -> raise AppwriteException('Missing required parameter: "name"') - api_params['databaseId'] = database_id - api_params['name'] = name + api_params['databaseId'] = self._normalize_value(database_id) + api_params['name'] = self._normalize_value(name) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def list_transactions(self, queries: Optional[List[str]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Database) + + + def list_transactions( + self, + queries: Optional[List[str]] = None ) -> TransactionList: """ List transactions across all databases. @@ -109,8 +153,8 @@ def list_transactions(self, queries: Optional[List[str]] = None) -> Dict[str, An Returns ------- - Dict[str, Any] - API response as a dictionary + TransactionList + API response as a typed Pydantic model Raises ------ @@ -122,12 +166,17 @@ def list_transactions(self, queries: Optional[List[str]] = None) -> Dict[str, An api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_transaction(self, ttl: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=TransactionList) + + + def create_transaction( + self, + ttl: Optional[float] = None ) -> Transaction: """ Create a new transaction. @@ -138,8 +187,8 @@ def create_transaction(self, ttl: Optional[float] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Transaction + API response as a typed Pydantic model Raises ------ @@ -151,13 +200,18 @@ def create_transaction(self, ttl: Optional[float] = None) -> Dict[str, Any]: api_params = {} if ttl is not None: - api_params['ttl'] = ttl + api_params['ttl'] = self._normalize_value(ttl) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_transaction(self, transaction_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Transaction) + + + def get_transaction( + self, + transaction_id: str ) -> Transaction: """ Get a transaction by its unique ID. @@ -168,8 +222,8 @@ def get_transaction(self, transaction_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Transaction + API response as a typed Pydantic model Raises ------ @@ -182,13 +236,20 @@ def get_transaction(self, transaction_id: str) -> Dict[str, Any]: if transaction_id is None: raise AppwriteException('Missing required parameter: "transaction_id"') - api_path = api_path.replace('{transactionId}', transaction_id) + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_transaction(self, transaction_id: str, commit: Optional[bool] = None, rollback: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Transaction) + + + def update_transaction( + self, + transaction_id: str, + commit: Optional[bool] = None, + rollback: Optional[bool] = None ) -> Transaction: """ Update a transaction, to either commit or roll back its operations. @@ -203,8 +264,8 @@ def update_transaction(self, transaction_id: str, commit: Optional[bool] = None, Returns ------- - Dict[str, Any] - API response as a dictionary + Transaction + API response as a typed Pydantic model Raises ------ @@ -217,18 +278,23 @@ def update_transaction(self, transaction_id: str, commit: Optional[bool] = None, if transaction_id is None: raise AppwriteException('Missing required parameter: "transaction_id"') - api_path = api_path.replace('{transactionId}', transaction_id) + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) if commit is not None: - api_params['commit'] = commit + api_params['commit'] = self._normalize_value(commit) if rollback is not None: - api_params['rollback'] = rollback + api_params['rollback'] = self._normalize_value(rollback) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_transaction(self, transaction_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Transaction) + + + def delete_transaction( + self, + transaction_id: str ) -> Dict[str, Any]: """ Delete a transaction by its unique ID. @@ -253,14 +319,20 @@ def delete_transaction(self, transaction_id: str) -> Dict[str, Any]: if transaction_id is None: raise AppwriteException('Missing required parameter: "transaction_id"') - api_path = api_path.replace('{transactionId}', transaction_id) + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def create_operations(self, transaction_id: str, operations: Optional[List[dict]] = None) -> Dict[str, Any]: + return response + + + def create_operations( + self, + transaction_id: str, + operations: Optional[List[Dict[str, Any]]] = None ) -> Transaction: """ Create multiple operations in a single transaction. @@ -268,13 +340,13 @@ def create_operations(self, transaction_id: str, operations: Optional[List[dict] ---------- transaction_id : str Transaction ID. - operations : Optional[List[dict]] + operations : Optional[List[Dict[str, Any]]] Array of staged operations. Returns ------- - Dict[str, Any] - API response as a dictionary + Transaction + API response as a typed Pydantic model Raises ------ @@ -287,17 +359,22 @@ def create_operations(self, transaction_id: str, operations: Optional[List[dict] if transaction_id is None: raise AppwriteException('Missing required parameter: "transaction_id"') - api_path = api_path.replace('{transactionId}', transaction_id) + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) if operations is not None: - api_params['operations'] = operations + api_params['operations'] = self._normalize_value(operations) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Transaction) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get` instead.") - def get(self, database_id: str) -> Dict[str, Any]: + def get( + self, + database_id: str ) -> Database: """ Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. @@ -310,8 +387,8 @@ def get(self, database_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Database + API response as a typed Pydantic model Raises ------ @@ -324,14 +401,21 @@ def get(self, database_id: str) -> Dict[str, Any]: if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, model=Database) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update` instead.") - def update(self, database_id: str, name: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + def update( + self, + database_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None ) -> Database: """ Update a database by its unique ID. @@ -348,8 +432,8 @@ def update(self, database_id: str, name: Optional[str] = None, enabled: Optional Returns ------- - Dict[str, Any] - API response as a dictionary + Database + API response as a typed Pydantic model Raises ------ @@ -362,19 +446,24 @@ def update(self, database_id: str, name: Optional[str] = None, enabled: Optional if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Database) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete` instead.") - def delete(self, database_id: str) -> Dict[str, Any]: + def delete( + self, + database_id: str ) -> Dict[str, Any]: """ Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. @@ -401,15 +490,23 @@ def delete(self, database_id: str) -> Dict[str, Any]: if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + return response + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_tables` instead.") - def list_collections(self, database_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list_collections( + self, + database_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> CollectionList: """ Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. @@ -428,8 +525,8 @@ def list_collections(self, database_id: str, queries: Optional[List[str]] = None Returns ------- - Dict[str, Any] - API response as a dictionary + CollectionList + API response as a typed Pydantic model Raises ------ @@ -442,20 +539,32 @@ def list_collections(self, database_id: str, queries: Optional[List[str]] = None if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, model=CollectionList) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_table` instead.") - def create_collection(self, database_id: str, collection_id: str, name: str, permissions: Optional[List[str]] = None, document_security: Optional[bool] = None, enabled: Optional[bool] = None, attributes: Optional[List[dict]] = None, indexes: Optional[List[dict]] = None) -> Dict[str, Any]: + def create_collection( + self, + database_id: str, + collection_id: str, + name: str, + permissions: Optional[List[str]] = None, + document_security: Optional[bool] = None, + enabled: Optional[bool] = None, + attributes: Optional[List[Dict[str, Any]]] = None, + indexes: Optional[List[Dict[str, Any]]] = None ) -> Collection: """ Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -475,15 +584,15 @@ def create_collection(self, database_id: str, collection_id: str, name: str, per Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). enabled : Optional[bool] Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - attributes : Optional[List[dict]] + attributes : Optional[List[Dict[str, Any]]] Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - indexes : Optional[List[dict]] + indexes : Optional[List[Dict[str, Any]]] Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). Returns ------- - Dict[str, Any] - API response as a dictionary + Collection + API response as a typed Pydantic model Raises ------ @@ -502,26 +611,32 @@ def create_collection(self, database_id: str, collection_id: str, name: str, per if name is None: raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_params['collectionId'] = collection_id - api_params['name'] = name - api_params['permissions'] = permissions + api_params['collectionId'] = self._normalize_value(collection_id) + api_params['name'] = self._normalize_value(name) + api_params['permissions'] = self._normalize_value(permissions) if document_security is not None: - api_params['documentSecurity'] = document_security + api_params['documentSecurity'] = self._normalize_value(document_security) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) if attributes is not None: - api_params['attributes'] = attributes + api_params['attributes'] = self._normalize_value(attributes) if indexes is not None: - api_params['indexes'] = indexes + api_params['indexes'] = self._normalize_value(indexes) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Collection) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_table` instead.") - def get_collection(self, database_id: str, collection_id: str) -> Dict[str, Any]: + def get_collection( + self, + database_id: str, + collection_id: str ) -> Collection: """ Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. @@ -536,8 +651,8 @@ def get_collection(self, database_id: str, collection_id: str) -> Dict[str, Any] Returns ------- - Dict[str, Any] - API response as a dictionary + Collection + API response as a typed Pydantic model Raises ------ @@ -553,15 +668,25 @@ def get_collection(self, database_id: str, collection_id: str) -> Dict[str, Any] if collection_id is None: raise AppwriteException('Missing required parameter: "collection_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, model=Collection) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_table` instead.") - def update_collection(self, database_id: str, collection_id: str, name: Optional[str] = None, permissions: Optional[List[str]] = None, document_security: Optional[bool] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + def update_collection( + self, + database_id: str, + collection_id: str, + name: Optional[str] = None, + permissions: Optional[List[str]] = None, + document_security: Optional[bool] = None, + enabled: Optional[bool] = None ) -> Collection: """ Update a collection by its unique ID. @@ -584,8 +709,8 @@ def update_collection(self, database_id: str, collection_id: str, name: Optional Returns ------- - Dict[str, Any] - API response as a dictionary + Collection + API response as a typed Pydantic model Raises ------ @@ -601,23 +726,29 @@ def update_collection(self, database_id: str, collection_id: str, name: Optional if collection_id is None: raise AppwriteException('Missing required parameter: "collection_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) if name is not None: - api_params['name'] = name - api_params['permissions'] = permissions + api_params['name'] = self._normalize_value(name) + api_params['permissions'] = self._normalize_value(permissions) if document_security is not None: - api_params['documentSecurity'] = document_security + api_params['documentSecurity'] = self._normalize_value(document_security) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Collection) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_table` instead.") - def delete_collection(self, database_id: str, collection_id: str) -> Dict[str, Any]: + def delete_collection( + self, + database_id: str, + collection_id: str ) -> Dict[str, Any]: """ Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. @@ -649,16 +780,24 @@ def delete_collection(self, database_id: str, collection_id: str) -> Dict[str, A if collection_id is None: raise AppwriteException('Missing required parameter: "collection_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + return response + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_columns` instead.") - def list_attributes(self, database_id: str, collection_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list_attributes( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> AttributeList: """ List attributes in the collection. @@ -677,8 +816,8 @@ def list_attributes(self, database_id: str, collection_id: str, queries: Optiona Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeList + API response as a typed Pydantic model Raises ------ @@ -694,19 +833,29 @@ def list_attributes(self, database_id: str, collection_id: str, queries: Optiona if collection_id is None: raise AppwriteException('Missing required parameter: "collection_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, model=AttributeList) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_boolean_column` instead.") - def create_boolean_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[bool] = None, array: Optional[bool] = None) -> Dict[str, Any]: + def create_boolean_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[bool] = None, + array: Optional[bool] = None ) -> AttributeBoolean: """ Create a boolean attribute. @@ -730,8 +879,8 @@ def create_boolean_attribute(self, database_id: str, collection_id: str, key: st Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeBoolean + API response as a typed Pydantic model Raises ------ @@ -753,21 +902,31 @@ def create_boolean_attribute(self, database_id: str, collection_id: str, key: st if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeBoolean) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_boolean_column` instead.") - def update_boolean_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[bool], new_key: Optional[str] = None) -> Dict[str, Any]: + def update_boolean_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[bool], + new_key: Optional[str] = None ) -> AttributeBoolean: """ Update a boolean attribute. Changing the `default` value will not update already existing documents. @@ -790,8 +949,8 @@ def update_boolean_attribute(self, database_id: str, collection_id: str, key: st Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeBoolean + API response as a typed Pydantic model Raises ------ @@ -813,20 +972,30 @@ def update_boolean_attribute(self, database_id: str, collection_id: str, key: st if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeBoolean) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_datetime_column` instead.") - def create_datetime_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + def create_datetime_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> AttributeDatetime: """ Create a date time attribute according to the ISO 8601 standard. @@ -849,8 +1018,8 @@ def create_datetime_attribute(self, database_id: str, collection_id: str, key: s Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeDatetime + API response as a typed Pydantic model Raises ------ @@ -872,21 +1041,31 @@ def create_datetime_attribute(self, database_id: str, collection_id: str, key: s if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeDatetime) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_datetime_column` instead.") - def update_datetime_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + def update_datetime_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> AttributeDatetime: """ Update a date time attribute. Changing the `default` value will not update already existing documents. @@ -909,8 +1088,8 @@ def update_datetime_attribute(self, database_id: str, collection_id: str, key: s Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeDatetime + API response as a typed Pydantic model Raises ------ @@ -932,20 +1111,30 @@ def update_datetime_attribute(self, database_id: str, collection_id: str, key: s if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeDatetime) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_email_column` instead.") - def create_email_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + def create_email_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> AttributeEmail: """ Create an email attribute. @@ -969,8 +1158,8 @@ def create_email_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeEmail + API response as a typed Pydantic model Raises ------ @@ -992,21 +1181,31 @@ def create_email_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeEmail) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_email_column` instead.") - def update_email_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + def update_email_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> AttributeEmail: """ Update an email attribute. Changing the `default` value will not update already existing documents. @@ -1030,8 +1229,8 @@ def update_email_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeEmail + API response as a typed Pydantic model Raises ------ @@ -1053,20 +1252,31 @@ def update_email_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeEmail) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_enum_column` instead.") - def create_enum_attribute(self, database_id: str, collection_id: str, key: str, elements: List[str], required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + def create_enum_attribute( + self, + database_id: str, + collection_id: str, + key: str, + elements: List[str], + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> AttributeEnum: """ Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. @@ -1092,8 +1302,8 @@ def create_enum_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeEnum + API response as a typed Pydantic model Raises ------ @@ -1118,22 +1328,33 @@ def create_enum_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['elements'] = elements - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['elements'] = self._normalize_value(elements) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeEnum) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_enum_column` instead.") - def update_enum_attribute(self, database_id: str, collection_id: str, key: str, elements: List[str], required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + def update_enum_attribute( + self, + database_id: str, + collection_id: str, + key: str, + elements: List[str], + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> AttributeEnum: """ Update an enum attribute. Changing the `default` value will not update already existing documents. @@ -1159,8 +1380,8 @@ def update_enum_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeEnum + API response as a typed Pydantic model Raises ------ @@ -1185,21 +1406,33 @@ def update_enum_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['elements'] = elements - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['elements'] = self._normalize_value(elements) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeEnum) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_float_column` instead.") - def create_float_attribute(self, database_id: str, collection_id: str, key: str, required: bool, min: Optional[float] = None, max: Optional[float] = None, default: Optional[float] = None, array: Optional[bool] = None) -> Dict[str, Any]: + def create_float_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + min: Optional[float] = None, + max: Optional[float] = None, + default: Optional[float] = None, + array: Optional[bool] = None ) -> AttributeFloat: """ Create a float attribute. Optionally, minimum and maximum values can be provided. @@ -1227,8 +1460,8 @@ def create_float_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeFloat + API response as a typed Pydantic model Raises ------ @@ -1250,23 +1483,35 @@ def create_float_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['min'] = self._normalize_value(min) + api_params['max'] = self._normalize_value(max) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeFloat) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_float_column` instead.") - def update_float_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[float], min: Optional[float] = None, max: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + def update_float_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[float], + min: Optional[float] = None, + max: Optional[float] = None, + new_key: Optional[str] = None ) -> AttributeFloat: """ Update a float attribute. Changing the `default` value will not update already existing documents. @@ -1294,8 +1539,8 @@ def update_float_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeFloat + API response as a typed Pydantic model Raises ------ @@ -1317,22 +1562,34 @@ def update_float_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['min'] = self._normalize_value(min) + api_params['max'] = self._normalize_value(max) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeFloat) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_integer_column` instead.") - def create_integer_attribute(self, database_id: str, collection_id: str, key: str, required: bool, min: Optional[float] = None, max: Optional[float] = None, default: Optional[float] = None, array: Optional[bool] = None) -> Dict[str, Any]: + def create_integer_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + min: Optional[float] = None, + max: Optional[float] = None, + default: Optional[float] = None, + array: Optional[bool] = None ) -> AttributeInteger: """ Create an integer attribute. Optionally, minimum and maximum values can be provided. @@ -1360,8 +1617,8 @@ def create_integer_attribute(self, database_id: str, collection_id: str, key: st Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeInteger + API response as a typed Pydantic model Raises ------ @@ -1383,23 +1640,35 @@ def create_integer_attribute(self, database_id: str, collection_id: str, key: st if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['min'] = self._normalize_value(min) + api_params['max'] = self._normalize_value(max) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeInteger) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_integer_column` instead.") - def update_integer_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[float], min: Optional[float] = None, max: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + def update_integer_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[float], + min: Optional[float] = None, + max: Optional[float] = None, + new_key: Optional[str] = None ) -> AttributeInteger: """ Update an integer attribute. Changing the `default` value will not update already existing documents. @@ -1427,8 +1696,8 @@ def update_integer_attribute(self, database_id: str, collection_id: str, key: st Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeInteger + API response as a typed Pydantic model Raises ------ @@ -1450,22 +1719,32 @@ def update_integer_attribute(self, database_id: str, collection_id: str, key: st if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['min'] = self._normalize_value(min) + api_params['max'] = self._normalize_value(max) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeInteger) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_ip_column` instead.") - def create_ip_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + def create_ip_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> AttributeIp: """ Create IP address attribute. @@ -1489,8 +1768,8 @@ def create_ip_attribute(self, database_id: str, collection_id: str, key: str, re Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeIp + API response as a typed Pydantic model Raises ------ @@ -1512,21 +1791,31 @@ def create_ip_attribute(self, database_id: str, collection_id: str, key: str, re if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeIp) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_ip_column` instead.") - def update_ip_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + def update_ip_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> AttributeIp: """ Update an ip attribute. Changing the `default` value will not update already existing documents. @@ -1550,8 +1839,8 @@ def update_ip_attribute(self, database_id: str, collection_id: str, key: str, re Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeIp + API response as a typed Pydantic model Raises ------ @@ -1573,20 +1862,29 @@ def update_ip_attribute(self, database_id: str, collection_id: str, key: str, re if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeIp) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_line_column` instead.") - def create_line_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[List[Any]] = None) -> Dict[str, Any]: + def create_line_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None ) -> AttributeLine: """ Create a geometric line attribute. @@ -1607,8 +1905,8 @@ def create_line_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeLine + API response as a typed Pydantic model Raises ------ @@ -1630,19 +1928,29 @@ def create_line_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeLine) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_line_column` instead.") - def update_line_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[List[Any]] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + def update_line_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None, + new_key: Optional[str] = None ) -> AttributeLine: """ Update a line attribute. Changing the `default` value will not update already existing documents. @@ -1665,8 +1973,8 @@ def update_line_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeLine + API response as a typed Pydantic model Raises ------ @@ -1688,19 +1996,30 @@ def update_line_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_longtext_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=AttributeLine) + + + def create_longtext_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> AttributeLongtext: """ Create a longtext attribute. @@ -1724,8 +2043,8 @@ def create_longtext_attribute(self, database_id: str, collection_id: str, key: s Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeLongtext + API response as a typed Pydantic model Raises ------ @@ -1747,22 +2066,32 @@ def create_longtext_attribute(self, database_id: str, collection_id: str, key: s if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_longtext_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=AttributeLongtext) + + + def update_longtext_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> AttributeLongtext: """ Update a longtext attribute. Changing the `default` value will not update already existing documents. @@ -1784,8 +2113,8 @@ def update_longtext_attribute(self, database_id: str, collection_id: str, key: s Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeLongtext + API response as a typed Pydantic model Raises ------ @@ -1807,19 +2136,30 @@ def update_longtext_attribute(self, database_id: str, collection_id: str, key: s if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_mediumtext_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=AttributeLongtext) + + + def create_mediumtext_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> AttributeMediumtext: """ Create a mediumtext attribute. @@ -1843,8 +2183,8 @@ def create_mediumtext_attribute(self, database_id: str, collection_id: str, key: Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeMediumtext + API response as a typed Pydantic model Raises ------ @@ -1866,22 +2206,32 @@ def create_mediumtext_attribute(self, database_id: str, collection_id: str, key: if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_mediumtext_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=AttributeMediumtext) + + + def update_mediumtext_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> AttributeMediumtext: """ Update a mediumtext attribute. Changing the `default` value will not update already existing documents. @@ -1903,8 +2253,8 @@ def update_mediumtext_attribute(self, database_id: str, collection_id: str, key: Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeMediumtext + API response as a typed Pydantic model Raises ------ @@ -1926,20 +2276,29 @@ def update_mediumtext_attribute(self, database_id: str, collection_id: str, key: if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeMediumtext) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_point_column` instead.") - def create_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[List[Any]] = None) -> Dict[str, Any]: + def create_point_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None ) -> AttributePoint: """ Create a geometric point attribute. @@ -1960,8 +2319,8 @@ def create_point_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributePoint + API response as a typed Pydantic model Raises ------ @@ -1983,19 +2342,29 @@ def create_point_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributePoint) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_point_column` instead.") - def update_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[List[Any]] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + def update_point_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None, + new_key: Optional[str] = None ) -> AttributePoint: """ Update a point attribute. Changing the `default` value will not update already existing documents. @@ -2018,8 +2387,8 @@ def update_point_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributePoint + API response as a typed Pydantic model Raises ------ @@ -2041,20 +2410,29 @@ def update_point_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributePoint) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_polygon_column` instead.") - def create_polygon_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[List[Any]] = None) -> Dict[str, Any]: + def create_polygon_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None ) -> AttributePolygon: """ Create a geometric polygon attribute. @@ -2075,8 +2453,8 @@ def create_polygon_attribute(self, database_id: str, collection_id: str, key: st Returns ------- - Dict[str, Any] - API response as a dictionary + AttributePolygon + API response as a typed Pydantic model Raises ------ @@ -2098,19 +2476,29 @@ def create_polygon_attribute(self, database_id: str, collection_id: str, key: st if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributePolygon) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_polygon_column` instead.") - def update_polygon_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[List[Any]] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + def update_polygon_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None, + new_key: Optional[str] = None ) -> AttributePolygon: """ Update a polygon attribute. Changing the `default` value will not update already existing documents. @@ -2133,8 +2521,8 @@ def update_polygon_attribute(self, database_id: str, collection_id: str, key: st Returns ------- - Dict[str, Any] - API response as a dictionary + AttributePolygon + API response as a typed Pydantic model Raises ------ @@ -2156,20 +2544,32 @@ def update_polygon_attribute(self, database_id: str, collection_id: str, key: st if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributePolygon) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_relationship_column` instead.") - def create_relationship_attribute(self, database_id: str, collection_id: str, related_collection_id: str, type: RelationshipType, two_way: Optional[bool] = None, key: Optional[str] = None, two_way_key: Optional[str] = None, on_delete: Optional[RelationMutate] = None) -> Dict[str, Any]: + def create_relationship_attribute( + self, + database_id: str, + collection_id: str, + related_collection_id: str, + type: RelationshipType, + two_way: Optional[bool] = None, + key: Optional[str] = None, + two_way_key: Optional[str] = None, + on_delete: Optional[RelationMutate] = None ) -> AttributeRelationship: """ Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -2197,8 +2597,8 @@ def create_relationship_attribute(self, database_id: str, collection_id: str, re Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeRelationship + API response as a typed Pydantic model Raises ------ @@ -2220,24 +2620,33 @@ def create_relationship_attribute(self, database_id: str, collection_id: str, re if type is None: raise AppwriteException('Missing required parameter: "type"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['relatedCollectionId'] = related_collection_id - api_params['type'] = type + api_params['relatedCollectionId'] = self._normalize_value(related_collection_id) + api_params['type'] = self._normalize_value(type) if two_way is not None: - api_params['twoWay'] = two_way - api_params['key'] = key - api_params['twoWayKey'] = two_way_key + api_params['twoWay'] = self._normalize_value(two_way) + api_params['key'] = self._normalize_value(key) + api_params['twoWayKey'] = self._normalize_value(two_way_key) if on_delete is not None: - api_params['onDelete'] = on_delete + api_params['onDelete'] = self._normalize_value(on_delete) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeRelationship) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead.") - def update_relationship_attribute(self, database_id: str, collection_id: str, key: str, on_delete: Optional[RelationMutate] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + def update_relationship_attribute( + self, + database_id: str, + collection_id: str, + key: str, + on_delete: Optional[RelationMutate] = None, + new_key: Optional[str] = None ) -> AttributeRelationship: """ Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -2259,8 +2668,8 @@ def update_relationship_attribute(self, database_id: str, collection_id: str, ke Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeRelationship + API response as a typed Pydantic model Raises ------ @@ -2279,20 +2688,32 @@ def update_relationship_attribute(self, database_id: str, collection_id: str, ke if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) if on_delete is not None: - api_params['onDelete'] = on_delete - api_params['newKey'] = new_key + api_params['onDelete'] = self._normalize_value(on_delete) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeRelationship) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_string_column` instead.") - def create_string_attribute(self, database_id: str, collection_id: str, key: str, size: float, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + def create_string_attribute( + self, + database_id: str, + collection_id: str, + key: str, + size: float, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> AttributeString: """ Create a string attribute. @@ -2320,8 +2741,8 @@ def create_string_attribute(self, database_id: str, collection_id: str, key: str Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeString + API response as a typed Pydantic model Raises ------ @@ -2346,24 +2767,35 @@ def create_string_attribute(self, database_id: str, collection_id: str, key: str if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['size'] = size - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['size'] = self._normalize_value(size) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeString) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_string_column` instead.") - def update_string_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], size: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + def update_string_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str], + size: Optional[float] = None, + new_key: Optional[str] = None ) -> AttributeString: """ Update a string attribute. Changing the `default` value will not update already existing documents. @@ -2389,8 +2821,8 @@ def update_string_attribute(self, database_id: str, collection_id: str, key: str Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeString + API response as a typed Pydantic model Raises ------ @@ -2412,20 +2844,31 @@ def update_string_attribute(self, database_id: str, collection_id: str, key: str if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['size'] = size - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['size'] = self._normalize_value(size) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_text_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=AttributeString) + + + def create_text_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> AttributeText: """ Create a text attribute. @@ -2449,8 +2892,8 @@ def create_text_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeText + API response as a typed Pydantic model Raises ------ @@ -2472,22 +2915,32 @@ def create_text_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_text_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=AttributeText) + + + def update_text_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> AttributeText: """ Update a text attribute. Changing the `default` value will not update already existing documents. @@ -2509,8 +2962,8 @@ def update_text_attribute(self, database_id: str, collection_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeText + API response as a typed Pydantic model Raises ------ @@ -2532,20 +2985,30 @@ def update_text_attribute(self, database_id: str, collection_id: str, key: str, if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeText) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_url_column` instead.") - def create_url_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + def create_url_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> AttributeUrl: """ Create a URL attribute. @@ -2569,8 +3032,8 @@ def create_url_attribute(self, database_id: str, collection_id: str, key: str, r Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeUrl + API response as a typed Pydantic model Raises ------ @@ -2592,21 +3055,31 @@ def create_url_attribute(self, database_id: str, collection_id: str, key: str, r if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeUrl) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_url_column` instead.") - def update_url_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + def update_url_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> AttributeUrl: """ Update an url attribute. Changing the `default` value will not update already existing documents. @@ -2630,8 +3103,8 @@ def update_url_attribute(self, database_id: str, collection_id: str, key: str, r Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeUrl + API response as a typed Pydantic model Raises ------ @@ -2653,19 +3126,31 @@ def update_url_attribute(self, database_id: str, collection_id: str, key: str, r if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_varchar_attribute(self, database_id: str, collection_id: str, key: str, size: float, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=AttributeUrl) + + + def create_varchar_attribute( + self, + database_id: str, + collection_id: str, + key: str, + size: float, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> AttributeVarchar: """ Create a varchar attribute. @@ -2691,8 +3176,8 @@ def create_varchar_attribute(self, database_id: str, collection_id: str, key: st Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeVarchar + API response as a typed Pydantic model Raises ------ @@ -2717,23 +3202,34 @@ def create_varchar_attribute(self, database_id: str, collection_id: str, key: st if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['size'] = size - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['size'] = self._normalize_value(size) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_varchar_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], size: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=AttributeVarchar) + + + def update_varchar_attribute( + self, + database_id: str, + collection_id: str, + key: str, + required: bool, + default: Optional[str], + size: Optional[float] = None, + new_key: Optional[str] = None ) -> AttributeVarchar: """ Update a varchar attribute. Changing the `default` value will not update already existing documents. @@ -2757,8 +3253,8 @@ def update_varchar_attribute(self, database_id: str, collection_id: str, key: st Returns ------- - Dict[str, Any] - API response as a dictionary + AttributeVarchar + API response as a typed Pydantic model Raises ------ @@ -2780,21 +3276,28 @@ def update_varchar_attribute(self, database_id: str, collection_id: str, key: st if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['size'] = size - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['size'] = self._normalize_value(size) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=AttributeVarchar) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_column` instead.") - def get_attribute(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: + def get_attribute( + self, + database_id: str, + collection_id: str, + key: str ) -> Union[AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString]: """ Get attribute by ID. @@ -2811,8 +3314,8 @@ def get_attribute(self, database_id: str, collection_id: str, key: str) -> Dict[ Returns ------- - Dict[str, Any] - API response as a dictionary + Union[AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString] + API response as one of the typed response models Raises ------ @@ -2831,16 +3334,23 @@ def get_attribute(self, database_id: str, collection_id: str, key: str) -> Dict[ if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, union_models=(AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString, )) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_column` instead.") - def delete_attribute(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: + def delete_attribute( + self, + database_id: str, + collection_id: str, + key: str ) -> Dict[str, Any]: """ Deletes an attribute. @@ -2877,17 +3387,27 @@ def delete_attribute(self, database_id: str, collection_id: str, key: str) -> Di if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + return response + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_rows` instead.") - def list_documents(self, database_id: str, collection_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, total: Optional[bool] = None, ttl: Optional[float] = None) -> Dict[str, Any]: + def list_documents( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + total: Optional[bool] = None, + ttl: Optional[float] = None ) -> DocumentList: """ Get a list of all the user's documents in a given collection. You can use the query params to filter your results. @@ -2910,8 +3430,8 @@ def list_documents(self, database_id: str, collection_id: str, queries: Optional Returns ------- - Dict[str, Any] - API response as a dictionary + DocumentList + API response as a typed Pydantic model Raises ------ @@ -2927,23 +3447,33 @@ def list_documents(self, database_id: str, collection_id: str, queries: Optional if collection_id is None: raise AppwriteException('Missing required parameter: "collection_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if transaction_id is not None: - api_params['transactionId'] = transaction_id + api_params['transactionId'] = self._normalize_value(transaction_id) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) if ttl is not None: - api_params['ttl'] = ttl + api_params['ttl'] = self._normalize_value(ttl) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, model=DocumentList) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_row` instead.") - def create_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def create_document( + self, + database_id: str, + collection_id: str, + document_id: str, + data: Dict[str, Any], + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> Document: """ Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -2957,7 +3487,7 @@ def create_document(self, database_id: str, collection_id: str, document_id: str Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. document_id : str Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - data : dict + data : Dict[str, Any] Document data as JSON object. permissions : Optional[List[str]] An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -2966,8 +3496,8 @@ def create_document(self, database_id: str, collection_id: str, document_id: str Returns ------- - Dict[str, Any] - API response as a dictionary + Document + API response as a typed Pydantic model Raises ------ @@ -2989,20 +3519,28 @@ def create_document(self, database_id: str, collection_id: str, document_id: str if data is None: raise AppwriteException('Missing required parameter: "data"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['documentId'] = document_id - api_params['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + api_params['documentId'] = self._normalize_value(document_id) + api_params['data'] = self._normalize_value(data) + api_params['permissions'] = self._normalize_value(permissions) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Document) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_rows` instead.") - def create_documents(self, database_id: str, collection_id: str, documents: List[dict], transaction_id: Optional[str] = None) -> Dict[str, Any]: + def create_documents( + self, + database_id: str, + collection_id: str, + documents: List[Dict[str, Any]], + transaction_id: Optional[str] = None ) -> DocumentList: """ Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3014,15 +3552,15 @@ def create_documents(self, database_id: str, collection_id: str, documents: List Database ID. collection_id : str Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - documents : List[dict] + documents : List[Dict[str, Any]] Array of documents data as JSON objects. transaction_id : Optional[str] Transaction ID for staging the operation. Returns ------- - Dict[str, Any] - API response as a dictionary + DocumentList + API response as a typed Pydantic model Raises ------ @@ -3041,18 +3579,26 @@ def create_documents(self, database_id: str, collection_id: str, documents: List if documents is None: raise AppwriteException('Missing required parameter: "documents"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['documents'] = documents - api_params['transactionId'] = transaction_id + api_params['documents'] = self._normalize_value(documents) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=DocumentList) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.upsert_rows` instead.") - def upsert_documents(self, database_id: str, collection_id: str, documents: List[dict], transaction_id: Optional[str] = None) -> Dict[str, Any]: + def upsert_documents( + self, + database_id: str, + collection_id: str, + documents: List[Dict[str, Any]], + transaction_id: Optional[str] = None ) -> DocumentList: """ Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3065,15 +3611,15 @@ def upsert_documents(self, database_id: str, collection_id: str, documents: List Database ID. collection_id : str Collection ID. - documents : List[dict] + documents : List[Dict[str, Any]] Array of document data as JSON objects. May contain partial documents. transaction_id : Optional[str] Transaction ID for staging the operation. Returns ------- - Dict[str, Any] - API response as a dictionary + DocumentList + API response as a typed Pydantic model Raises ------ @@ -3092,18 +3638,27 @@ def upsert_documents(self, database_id: str, collection_id: str, documents: List if documents is None: raise AppwriteException('Missing required parameter: "documents"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['documents'] = documents - api_params['transactionId'] = transaction_id + api_params['documents'] = self._normalize_value(documents) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=DocumentList) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_rows` instead.") - def update_documents(self, database_id: str, collection_id: str, data: Optional[dict] = None, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def update_documents( + self, + database_id: str, + collection_id: str, + data: Optional[Dict[str, Any]] = None, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> DocumentList: """ Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. @@ -3115,7 +3670,7 @@ def update_documents(self, database_id: str, collection_id: str, data: Optional[ Database ID. collection_id : str Collection ID. - data : Optional[dict] + data : Optional[Dict[str, Any]] Document data as JSON object. Include only attribute and value pairs to be updated. queries : Optional[List[str]] Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. @@ -3124,8 +3679,8 @@ def update_documents(self, database_id: str, collection_id: str, data: Optional[ Returns ------- - Dict[str, Any] - API response as a dictionary + DocumentList + API response as a typed Pydantic model Raises ------ @@ -3141,21 +3696,29 @@ def update_documents(self, database_id: str, collection_id: str, data: Optional[ if collection_id is None: raise AppwriteException('Missing required parameter: "collection_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) if data is not None: - api_params['data'] = data + api_params['data'] = self._normalize_value(data) if queries is not None: - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + api_params['queries'] = self._normalize_value(queries) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=DocumentList) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_rows` instead.") - def delete_documents(self, database_id: str, collection_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def delete_documents( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> DocumentList: """ Bulk delete documents using queries, if no queries are passed then all documents are deleted. @@ -3174,8 +3737,8 @@ def delete_documents(self, database_id: str, collection_id: str, queries: Option Returns ------- - Dict[str, Any] - API response as a dictionary + DocumentList + API response as a typed Pydantic model Raises ------ @@ -3191,19 +3754,28 @@ def delete_documents(self, database_id: str, collection_id: str, queries: Option if collection_id is None: raise AppwriteException('Missing required parameter: "collection_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) if queries is not None: - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + api_params['queries'] = self._normalize_value(queries) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=DocumentList) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_row` instead.") - def get_document(self, database_id: str, collection_id: str, document_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def get_document( + self, + database_id: str, + collection_id: str, + document_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> Document: """ Get a document by its unique ID. This endpoint response returns a JSON object with the document data. @@ -3224,8 +3796,8 @@ def get_document(self, database_id: str, collection_id: str, document_id: str, q Returns ------- - Dict[str, Any] - API response as a dictionary + Document + API response as a typed Pydantic model Raises ------ @@ -3244,20 +3816,30 @@ def get_document(self, database_id: str, collection_id: str, document_id: str, q if document_id is None: raise AppwriteException('Missing required parameter: "document_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{documentId}', document_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if transaction_id is not None: - api_params['transactionId'] = transaction_id + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, model=Document) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.upsert_row` instead.") - def upsert_document(self, database_id: str, collection_id: str, document_id: str, data: Optional[dict] = None, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def upsert_document( + self, + database_id: str, + collection_id: str, + document_id: str, + data: Optional[Dict[str, Any]] = None, + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> Document: """ Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3271,7 +3853,7 @@ def upsert_document(self, database_id: str, collection_id: str, document_id: str Collection ID. document_id : str Document ID. - data : Optional[dict] + data : Optional[Dict[str, Any]] Document data as JSON object. Include all required attributes of the document to be created or updated. permissions : Optional[List[str]] An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -3280,8 +3862,8 @@ def upsert_document(self, database_id: str, collection_id: str, document_id: str Returns ------- - Dict[str, Any] - API response as a dictionary + Document + API response as a typed Pydantic model Raises ------ @@ -3300,21 +3882,31 @@ def upsert_document(self, database_id: str, collection_id: str, document_id: str if document_id is None: raise AppwriteException('Missing required parameter: "document_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{documentId}', document_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) if data is not None: - api_params['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + api_params['data'] = self._normalize_value(data) + api_params['permissions'] = self._normalize_value(permissions) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Document) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_row` instead.") - def update_document(self, database_id: str, collection_id: str, document_id: str, data: Optional[dict] = None, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def update_document( + self, + database_id: str, + collection_id: str, + document_id: str, + data: Optional[Dict[str, Any]] = None, + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> Document: """ Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -3328,7 +3920,7 @@ def update_document(self, database_id: str, collection_id: str, document_id: str Collection ID. document_id : str Document ID. - data : Optional[dict] + data : Optional[Dict[str, Any]] Document data as JSON object. Include only attribute and value pairs to be updated. permissions : Optional[List[str]] An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -3337,8 +3929,8 @@ def update_document(self, database_id: str, collection_id: str, document_id: str Returns ------- - Dict[str, Any] - API response as a dictionary + Document + API response as a typed Pydantic model Raises ------ @@ -3357,21 +3949,29 @@ def update_document(self, database_id: str, collection_id: str, document_id: str if document_id is None: raise AppwriteException('Missing required parameter: "document_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{documentId}', document_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) if data is not None: - api_params['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + api_params['data'] = self._normalize_value(data) + api_params['permissions'] = self._normalize_value(permissions) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Document) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_row` instead.") - def delete_document(self, database_id: str, collection_id: str, document_id: str, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def delete_document( + self, + database_id: str, + collection_id: str, + document_id: str, + transaction_id: Optional[str] = None ) -> Dict[str, Any]: """ Delete a document by its unique ID. @@ -3410,18 +4010,29 @@ def delete_document(self, database_id: str, collection_id: str, document_id: str if document_id is None: raise AppwriteException('Missing required parameter: "document_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{documentId}', document_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - api_params['transactionId'] = transaction_id + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + return response + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.decrement_row_column` instead.") - def decrement_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: Optional[float] = None, min: Optional[float] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def decrement_document_attribute( + self, + database_id: str, + collection_id: str, + document_id: str, + attribute: str, + value: Optional[float] = None, + min: Optional[float] = None, + transaction_id: Optional[str] = None ) -> Document: """ Decrement a specific attribute of a document by a given value. @@ -3446,8 +4057,8 @@ def decrement_document_attribute(self, database_id: str, collection_id: str, doc Returns ------- - Dict[str, Any] - API response as a dictionary + Document + API response as a typed Pydantic model Raises ------ @@ -3469,22 +4080,33 @@ def decrement_document_attribute(self, database_id: str, collection_id: str, doc if attribute is None: raise AppwriteException('Missing required parameter: "attribute"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{documentId}', document_id) - api_path = api_path.replace('{attribute}', attribute) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + api_path = api_path.replace('{attribute}', str(self._normalize_value(attribute))) if value is not None: - api_params['value'] = value - api_params['min'] = min - api_params['transactionId'] = transaction_id + api_params['value'] = self._normalize_value(value) + api_params['min'] = self._normalize_value(min) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Document) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.increment_row_column` instead.") - def increment_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: Optional[float] = None, max: Optional[float] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def increment_document_attribute( + self, + database_id: str, + collection_id: str, + document_id: str, + attribute: str, + value: Optional[float] = None, + max: Optional[float] = None, + transaction_id: Optional[str] = None ) -> Document: """ Increment a specific attribute of a document by a given value. @@ -3509,8 +4131,8 @@ def increment_document_attribute(self, database_id: str, collection_id: str, doc Returns ------- - Dict[str, Any] - API response as a dictionary + Document + API response as a typed Pydantic model Raises ------ @@ -3532,22 +4154,30 @@ def increment_document_attribute(self, database_id: str, collection_id: str, doc if attribute is None: raise AppwriteException('Missing required parameter: "attribute"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{documentId}', document_id) - api_path = api_path.replace('{attribute}', attribute) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + api_path = api_path.replace('{attribute}', str(self._normalize_value(attribute))) if value is not None: - api_params['value'] = value - api_params['max'] = max - api_params['transactionId'] = transaction_id + api_params['value'] = self._normalize_value(value) + api_params['max'] = self._normalize_value(max) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Document) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_indexes` instead.") - def list_indexes(self, database_id: str, collection_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list_indexes( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> IndexList: """ List indexes in the collection. @@ -3566,8 +4196,8 @@ def list_indexes(self, database_id: str, collection_id: str, queries: Optional[L Returns ------- - Dict[str, Any] - API response as a dictionary + IndexList + API response as a typed Pydantic model Raises ------ @@ -3583,19 +4213,30 @@ def list_indexes(self, database_id: str, collection_id: str, queries: Optional[L if collection_id is None: raise AppwriteException('Missing required parameter: "collection_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, model=IndexList) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_index` instead.") - def create_index(self, database_id: str, collection_id: str, key: str, type: IndexType, attributes: List[str], orders: Optional[List[OrderBy]] = None, lengths: Optional[List[float]] = None) -> Dict[str, Any]: + def create_index( + self, + database_id: str, + collection_id: str, + key: str, + type: IndexType, + attributes: List[str], + orders: Optional[List[OrderBy]] = None, + lengths: Optional[List[float]] = None ) -> Index: """ Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. Attributes can be `key`, `fulltext`, and `unique`. @@ -3621,8 +4262,8 @@ def create_index(self, database_id: str, collection_id: str, key: str, type: Ind Returns ------- - Dict[str, Any] - API response as a dictionary + Index + API response as a typed Pydantic model Raises ------ @@ -3647,23 +4288,30 @@ def create_index(self, database_id: str, collection_id: str, key: str, type: Ind if attributes is None: raise AppwriteException('Missing required parameter: "attributes"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_params['key'] = key - api_params['type'] = type - api_params['attributes'] = attributes + api_params['key'] = self._normalize_value(key) + api_params['type'] = self._normalize_value(type) + api_params['attributes'] = self._normalize_value(attributes) if orders is not None: - api_params['orders'] = orders + api_params['orders'] = self._normalize_value(orders) if lengths is not None: - api_params['lengths'] = lengths + api_params['lengths'] = self._normalize_value(lengths) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=Index) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_index` instead.") - def get_index(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: + def get_index( + self, + database_id: str, + collection_id: str, + key: str ) -> Index: """ Get an index by its unique ID. @@ -3680,8 +4328,8 @@ def get_index(self, database_id: str, collection_id: str, key: str) -> Dict[str, Returns ------- - Dict[str, Any] - API response as a dictionary + Index + API response as a typed Pydantic model Raises ------ @@ -3700,16 +4348,23 @@ def get_index(self, database_id: str, collection_id: str, key: str) -> Dict[str, if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + return self._parse_response(response, model=Index) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_index` instead.") - def delete_index(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: + def delete_index( + self, + database_id: str, + collection_id: str, + key: str ) -> Dict[str, Any]: """ Delete an index. @@ -3746,11 +4401,14 @@ def delete_index(self, database_id: str, collection_id: str, key: str) -> Dict[s if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + + return response + diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index e4cc261..fabadba 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -1,21 +1,35 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.function_list import FunctionList; from ..enums.runtime import Runtime; from ..enums.scopes import Scopes; +from ..models.function import Function; +from ..models.runtime_list import RuntimeList; +from ..models.specification_list import SpecificationList; +from ..models.deployment_list import DeploymentList; from ..input_file import InputFile +from ..models.deployment import Deployment; from ..enums.template_reference_type import TemplateReferenceType; from ..enums.vcs_reference_type import VCSReferenceType; from ..enums.deployment_download_type import DeploymentDownloadType; +from ..models.execution_list import ExecutionList; from ..enums.execution_method import ExecutionMethod; +from ..models.execution import Execution; +from ..models.variable_list import VariableList; +from ..models.variable import Variable; class Functions(Service): def __init__(self, client) -> None: super(Functions, self).__init__(client) - def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> FunctionList: """ Get a list of all the project's functions. You can use the query params to filter your results. @@ -30,8 +44,8 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None Returns ------- - Dict[str, Any] - API response as a dictionary + FunctionList + API response as a typed Pydantic model Raises ------ @@ -43,16 +57,38 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create(self, function_id: str, name: str, runtime: Runtime, execute: Optional[List[str]] = None, events: Optional[List[str]] = None, schedule: Optional[str] = None, timeout: Optional[float] = None, enabled: Optional[bool] = None, logging: Optional[bool] = None, entrypoint: Optional[str] = None, commands: Optional[str] = None, scopes: Optional[List[Scopes]] = None, installation_id: Optional[str] = None, provider_repository_id: Optional[str] = None, provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, specification: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=FunctionList) + + + def create( + self, + function_id: str, + name: str, + runtime: Runtime, + execute: Optional[List[str]] = None, + events: Optional[List[str]] = None, + schedule: Optional[str] = None, + timeout: Optional[float] = None, + enabled: Optional[bool] = None, + logging: Optional[bool] = None, + entrypoint: Optional[str] = None, + commands: Optional[str] = None, + scopes: Optional[List[Scopes]] = None, + installation_id: Optional[str] = None, + provider_repository_id: Optional[str] = None, + provider_branch: Optional[str] = None, + provider_silent_mode: Optional[bool] = None, + provider_root_directory: Optional[str] = None, + specification: Optional[str] = None ) -> Function: """ Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. @@ -97,8 +133,8 @@ def create(self, function_id: str, name: str, runtime: Runtime, execute: Optiona Returns ------- - Dict[str, Any] - API response as a dictionary + Function + API response as a typed Pydantic model Raises ------ @@ -118,52 +154,56 @@ def create(self, function_id: str, name: str, runtime: Runtime, execute: Optiona raise AppwriteException('Missing required parameter: "runtime"') - api_params['functionId'] = function_id - api_params['name'] = name - api_params['runtime'] = runtime + api_params['functionId'] = self._normalize_value(function_id) + api_params['name'] = self._normalize_value(name) + api_params['runtime'] = self._normalize_value(runtime) if execute is not None: - api_params['execute'] = execute + api_params['execute'] = self._normalize_value(execute) if events is not None: - api_params['events'] = events + api_params['events'] = self._normalize_value(events) if schedule is not None: - api_params['schedule'] = schedule + api_params['schedule'] = self._normalize_value(schedule) if timeout is not None: - api_params['timeout'] = timeout + api_params['timeout'] = self._normalize_value(timeout) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) if logging is not None: - api_params['logging'] = logging + api_params['logging'] = self._normalize_value(logging) if entrypoint is not None: - api_params['entrypoint'] = entrypoint + api_params['entrypoint'] = self._normalize_value(entrypoint) if commands is not None: - api_params['commands'] = commands + api_params['commands'] = self._normalize_value(commands) if scopes is not None: - api_params['scopes'] = scopes + api_params['scopes'] = self._normalize_value(scopes) if installation_id is not None: - api_params['installationId'] = installation_id + api_params['installationId'] = self._normalize_value(installation_id) if provider_repository_id is not None: - api_params['providerRepositoryId'] = provider_repository_id + api_params['providerRepositoryId'] = self._normalize_value(provider_repository_id) if provider_branch is not None: - api_params['providerBranch'] = provider_branch + api_params['providerBranch'] = self._normalize_value(provider_branch) if provider_silent_mode is not None: - api_params['providerSilentMode'] = provider_silent_mode + api_params['providerSilentMode'] = self._normalize_value(provider_silent_mode) if provider_root_directory is not None: - api_params['providerRootDirectory'] = provider_root_directory + api_params['providerRootDirectory'] = self._normalize_value(provider_root_directory) if specification is not None: - api_params['specification'] = specification + api_params['specification'] = self._normalize_value(specification) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def list_runtimes(self) -> Dict[str, Any]: + return self._parse_response(response, model=Function) + + + def list_runtimes( + self ) -> RuntimeList: """ Get a list of all runtimes that are currently active on your instance. Returns ------- - Dict[str, Any] - API response as a dictionary + RuntimeList + API response as a typed Pydantic model Raises ------ @@ -174,17 +214,21 @@ def list_runtimes(self) -> Dict[str, Any]: api_path = '/functions/runtimes' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_specifications(self) -> Dict[str, Any]: + return self._parse_response(response, model=RuntimeList) + + + def list_specifications( + self ) -> SpecificationList: """ List allowed function specifications for this instance. Returns ------- - Dict[str, Any] - API response as a dictionary + SpecificationList + API response as a typed Pydantic model Raises ------ @@ -195,10 +239,15 @@ def list_specifications(self) -> Dict[str, Any]: api_path = '/functions/specifications' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get(self, function_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=SpecificationList) + + + def get( + self, + function_id: str ) -> Function: """ Get a function by its unique ID. @@ -209,8 +258,8 @@ def get(self, function_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Function + API response as a typed Pydantic model Raises ------ @@ -223,13 +272,35 @@ def get(self, function_id: str) -> Dict[str, Any]: if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update(self, function_id: str, name: str, runtime: Optional[Runtime] = None, execute: Optional[List[str]] = None, events: Optional[List[str]] = None, schedule: Optional[str] = None, timeout: Optional[float] = None, enabled: Optional[bool] = None, logging: Optional[bool] = None, entrypoint: Optional[str] = None, commands: Optional[str] = None, scopes: Optional[List[Scopes]] = None, installation_id: Optional[str] = None, provider_repository_id: Optional[str] = None, provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, specification: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Function) + + + def update( + self, + function_id: str, + name: str, + runtime: Optional[Runtime] = None, + execute: Optional[List[str]] = None, + events: Optional[List[str]] = None, + schedule: Optional[str] = None, + timeout: Optional[float] = None, + enabled: Optional[bool] = None, + logging: Optional[bool] = None, + entrypoint: Optional[str] = None, + commands: Optional[str] = None, + scopes: Optional[List[Scopes]] = None, + installation_id: Optional[str] = None, + provider_repository_id: Optional[str] = None, + provider_branch: Optional[str] = None, + provider_silent_mode: Optional[bool] = None, + provider_root_directory: Optional[str] = None, + specification: Optional[str] = None ) -> Function: """ Update function by its unique ID. @@ -274,8 +345,8 @@ def update(self, function_id: str, name: str, runtime: Optional[Runtime] = None, Returns ------- - Dict[str, Any] - API response as a dictionary + Function + API response as a typed Pydantic model Raises ------ @@ -291,46 +362,51 @@ def update(self, function_id: str, name: str, runtime: Optional[Runtime] = None, if name is None: raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - api_params['name'] = name + api_params['name'] = self._normalize_value(name) if runtime is not None: - api_params['runtime'] = runtime + api_params['runtime'] = self._normalize_value(runtime) if execute is not None: - api_params['execute'] = execute + api_params['execute'] = self._normalize_value(execute) if events is not None: - api_params['events'] = events + api_params['events'] = self._normalize_value(events) if schedule is not None: - api_params['schedule'] = schedule + api_params['schedule'] = self._normalize_value(schedule) if timeout is not None: - api_params['timeout'] = timeout + api_params['timeout'] = self._normalize_value(timeout) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) if logging is not None: - api_params['logging'] = logging + api_params['logging'] = self._normalize_value(logging) if entrypoint is not None: - api_params['entrypoint'] = entrypoint + api_params['entrypoint'] = self._normalize_value(entrypoint) if commands is not None: - api_params['commands'] = commands + api_params['commands'] = self._normalize_value(commands) if scopes is not None: - api_params['scopes'] = scopes + api_params['scopes'] = self._normalize_value(scopes) if installation_id is not None: - api_params['installationId'] = installation_id - api_params['providerRepositoryId'] = provider_repository_id + api_params['installationId'] = self._normalize_value(installation_id) + api_params['providerRepositoryId'] = self._normalize_value(provider_repository_id) if provider_branch is not None: - api_params['providerBranch'] = provider_branch + api_params['providerBranch'] = self._normalize_value(provider_branch) if provider_silent_mode is not None: - api_params['providerSilentMode'] = provider_silent_mode + api_params['providerSilentMode'] = self._normalize_value(provider_silent_mode) if provider_root_directory is not None: - api_params['providerRootDirectory'] = provider_root_directory + api_params['providerRootDirectory'] = self._normalize_value(provider_root_directory) if specification is not None: - api_params['specification'] = specification + api_params['specification'] = self._normalize_value(specification) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete(self, function_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Function) + + + def delete( + self, + function_id: str ) -> Dict[str, Any]: """ Delete a function by its unique ID. @@ -355,14 +431,20 @@ def delete(self, function_id: str) -> Dict[str, Any]: if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def update_function_deployment(self, function_id: str, deployment_id: str) -> Dict[str, Any]: + return response + + + def update_function_deployment( + self, + function_id: str, + deployment_id: str ) -> Function: """ Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. @@ -375,8 +457,8 @@ def update_function_deployment(self, function_id: str, deployment_id: str) -> Di Returns ------- - Dict[str, Any] - API response as a dictionary + Function + API response as a typed Pydantic model Raises ------ @@ -392,15 +474,23 @@ def update_function_deployment(self, function_id: str, deployment_id: str) -> Di if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - api_params['deploymentId'] = deployment_id + api_params['deploymentId'] = self._normalize_value(deployment_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def list_deployments(self, function_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Function) + + + def list_deployments( + self, + function_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> DeploymentList: """ Get a list of all the function's code deployments. You can use the query params to filter your results. @@ -417,8 +507,8 @@ def list_deployments(self, function_id: str, queries: Optional[List[str]] = None Returns ------- - Dict[str, Any] - API response as a dictionary + DeploymentList + API response as a typed Pydantic model Raises ------ @@ -431,19 +521,29 @@ def list_deployments(self, function_id: str, queries: Optional[List[str]] = None if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_deployment(self, function_id: str, code: InputFile, activate: bool, entrypoint: Optional[str] = None, commands: Optional[str] = None, on_progress = None) -> Dict[str, Any]: + return self._parse_response(response, model=DeploymentList) + + + def create_deployment( + self, + function_id: str, + code: InputFile, + activate: bool, + entrypoint: Optional[str] = None, + commands: Optional[str] = None, + on_progress = None ) -> Deployment: """ Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. @@ -468,8 +568,8 @@ def create_deployment(self, function_id: str, code: InputFile, activate: bool, e Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -488,25 +588,32 @@ def create_deployment(self, function_id: str, code: InputFile, activate: bool, e if activate is None: raise AppwriteException('Missing required parameter: "activate"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) if entrypoint is not None: - api_params['entrypoint'] = entrypoint + api_params['entrypoint'] = self._normalize_value(entrypoint) if commands is not None: - api_params['commands'] = commands - api_params['code'] = code - api_params['activate'] = str(activate).lower() if type(activate) is bool else activate + api_params['commands'] = self._normalize_value(commands) + api_params['code'] = self._normalize_value(code) + api_params['activate'] = self._normalize_value(str(activate).lower() if type(activate) is bool else activate) param_name = 'code' upload_id = '' - return self.client.chunked_upload(api_path, { + response = self.client.chunked_upload(api_path, { 'content-type': 'multipart/form-data', }, api_params, param_name, on_progress, upload_id) - def create_duplicate_deployment(self, function_id: str, deployment_id: str, build_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def create_duplicate_deployment( + self, + function_id: str, + deployment_id: str, + build_id: Optional[str] = None ) -> Deployment: """ Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. @@ -521,8 +628,8 @@ def create_duplicate_deployment(self, function_id: str, deployment_id: str, buil Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -538,17 +645,28 @@ def create_duplicate_deployment(self, function_id: str, deployment_id: str, buil if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - api_params['deploymentId'] = deployment_id + api_params['deploymentId'] = self._normalize_value(deployment_id) if build_id is not None: - api_params['buildId'] = build_id + api_params['buildId'] = self._normalize_value(build_id) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_template_deployment(self, function_id: str, repository: str, owner: str, root_directory: str, type: TemplateReferenceType, reference: str, activate: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def create_template_deployment( + self, + function_id: str, + repository: str, + owner: str, + root_directory: str, + type: TemplateReferenceType, + reference: str, + activate: Optional[bool] = None ) -> Deployment: """ Create a deployment based on a template. @@ -573,8 +691,8 @@ def create_template_deployment(self, function_id: str, repository: str, owner: s Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -602,21 +720,29 @@ def create_template_deployment(self, function_id: str, repository: str, owner: s if reference is None: raise AppwriteException('Missing required parameter: "reference"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - api_params['repository'] = repository - api_params['owner'] = owner - api_params['rootDirectory'] = root_directory - api_params['type'] = type - api_params['reference'] = reference + api_params['repository'] = self._normalize_value(repository) + api_params['owner'] = self._normalize_value(owner) + api_params['rootDirectory'] = self._normalize_value(root_directory) + api_params['type'] = self._normalize_value(type) + api_params['reference'] = self._normalize_value(reference) if activate is not None: - api_params['activate'] = activate + api_params['activate'] = self._normalize_value(activate) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_vcs_deployment(self, function_id: str, type: VCSReferenceType, reference: str, activate: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def create_vcs_deployment( + self, + function_id: str, + type: VCSReferenceType, + reference: str, + activate: Optional[bool] = None ) -> Deployment: """ Create a deployment when a function is connected to VCS. @@ -635,8 +761,8 @@ def create_vcs_deployment(self, function_id: str, type: VCSReferenceType, refere Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -655,18 +781,24 @@ def create_vcs_deployment(self, function_id: str, type: VCSReferenceType, refere if reference is None: raise AppwriteException('Missing required parameter: "reference"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - api_params['type'] = type - api_params['reference'] = reference + api_params['type'] = self._normalize_value(type) + api_params['reference'] = self._normalize_value(reference) if activate is not None: - api_params['activate'] = activate + api_params['activate'] = self._normalize_value(activate) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_deployment(self, function_id: str, deployment_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def get_deployment( + self, + function_id: str, + deployment_id: str ) -> Deployment: """ Get a function deployment by its unique ID. @@ -679,8 +811,8 @@ def get_deployment(self, function_id: str, deployment_id: str) -> Dict[str, Any] Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -696,14 +828,20 @@ def get_deployment(self, function_id: str, deployment_id: str) -> Dict[str, Any] if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{functionId}', function_id) - api_path = api_path.replace('{deploymentId}', deployment_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_deployment(self, function_id: str, deployment_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def delete_deployment( + self, + function_id: str, + deployment_id: str ) -> Dict[str, Any]: """ Delete a code deployment by its unique ID. @@ -733,15 +871,22 @@ def delete_deployment(self, function_id: str, deployment_id: str) -> Dict[str, A if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{functionId}', function_id) - api_path = api_path.replace('{deploymentId}', deployment_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def get_deployment_download(self, function_id: str, deployment_id: str, type: Optional[DeploymentDownloadType] = None) -> bytes: + return response + + + def get_deployment_download( + self, + function_id: str, + deployment_id: str, + type: Optional[DeploymentDownloadType] = None ) -> bytes: """ Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. @@ -773,16 +918,22 @@ def get_deployment_download(self, function_id: str, deployment_id: str, type: Op if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{functionId}', function_id) - api_path = api_path.replace('{deploymentId}', deployment_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) if type is not None: - api_params['type'] = type + api_params['type'] = self._normalize_value(type) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_deployment_status(self, function_id: str, deployment_id: str) -> Dict[str, Any]: + return response + + + def update_deployment_status( + self, + function_id: str, + deployment_id: str ) -> Deployment: """ Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. @@ -795,8 +946,8 @@ def update_deployment_status(self, function_id: str, deployment_id: str) -> Dict Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -812,15 +963,22 @@ def update_deployment_status(self, function_id: str, deployment_id: str) -> Dict if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{functionId}', function_id) - api_path = api_path.replace('{deploymentId}', deployment_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def list_executions(self, function_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def list_executions( + self, + function_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> ExecutionList: """ Get a list of all the current user function execution logs. You can use the query params to filter your results. @@ -835,8 +993,8 @@ def list_executions(self, function_id: str, queries: Optional[List[str]] = None, Returns ------- - Dict[str, Any] - API response as a dictionary + ExecutionList + API response as a typed Pydantic model Raises ------ @@ -849,17 +1007,28 @@ def list_executions(self, function_id: str, queries: Optional[List[str]] = None, if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_execution(self, function_id: str, body: Optional[str] = None, xasync: Optional[bool] = None, path: Optional[str] = None, method: Optional[ExecutionMethod] = None, headers: Optional[dict] = None, scheduled_at: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ExecutionList) + + + def create_execution( + self, + function_id: str, + body: Optional[str] = None, + xasync: Optional[bool] = None, + path: Optional[str] = None, + method: Optional[ExecutionMethod] = None, + headers: Optional[Dict[str, Any]] = None, + scheduled_at: Optional[str] = None ) -> Execution: """ Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. @@ -875,15 +1044,15 @@ def create_execution(self, function_id: str, body: Optional[str] = None, xasync: HTTP path of execution. Path can include query params. Default value is / method : Optional[ExecutionMethod] HTTP method of execution. Default value is POST. - headers : Optional[dict] + headers : Optional[Dict[str, Any]] HTTP headers of execution. Defaults to empty. scheduled_at : Optional[str] Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. Returns ------- - Dict[str, Any] - API response as a dictionary + Execution + API response as a typed Pydantic model Raises ------ @@ -896,25 +1065,31 @@ def create_execution(self, function_id: str, body: Optional[str] = None, xasync: if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) if body is not None: - api_params['body'] = body + api_params['body'] = self._normalize_value(body) if xasync is not None: - api_params['async'] = xasync + api_params['async'] = self._normalize_value(xasync) if path is not None: - api_params['path'] = path + api_params['path'] = self._normalize_value(path) if method is not None: - api_params['method'] = method + api_params['method'] = self._normalize_value(method) if headers is not None: - api_params['headers'] = headers - api_params['scheduledAt'] = scheduled_at + api_params['headers'] = self._normalize_value(headers) + api_params['scheduledAt'] = self._normalize_value(scheduled_at) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_execution(self, function_id: str, execution_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Execution) + + + def get_execution( + self, + function_id: str, + execution_id: str ) -> Execution: """ Get a function execution log by its unique ID. @@ -927,8 +1102,8 @@ def get_execution(self, function_id: str, execution_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Execution + API response as a typed Pydantic model Raises ------ @@ -944,14 +1119,20 @@ def get_execution(self, function_id: str, execution_id: str) -> Dict[str, Any]: if execution_id is None: raise AppwriteException('Missing required parameter: "execution_id"') - api_path = api_path.replace('{functionId}', function_id) - api_path = api_path.replace('{executionId}', execution_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_path = api_path.replace('{executionId}', str(self._normalize_value(execution_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_execution(self, function_id: str, execution_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Execution) + + + def delete_execution( + self, + function_id: str, + execution_id: str ) -> Dict[str, Any]: """ Delete a function execution by its unique ID. @@ -981,15 +1162,20 @@ def delete_execution(self, function_id: str, execution_id: str) -> Dict[str, Any if execution_id is None: raise AppwriteException('Missing required parameter: "execution_id"') - api_path = api_path.replace('{functionId}', function_id) - api_path = api_path.replace('{executionId}', execution_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_path = api_path.replace('{executionId}', str(self._normalize_value(execution_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_variables(self, function_id: str) -> Dict[str, Any]: + return response + + + def list_variables( + self, + function_id: str ) -> VariableList: """ Get a list of all variables of a specific function. @@ -1000,8 +1186,8 @@ def list_variables(self, function_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + VariableList + API response as a typed Pydantic model Raises ------ @@ -1014,13 +1200,21 @@ def list_variables(self, function_id: str) -> Dict[str, Any]: if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_variable(self, function_id: str, key: str, value: str, secret: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=VariableList) + + + def create_variable( + self, + function_id: str, + key: str, + value: str, + secret: Optional[bool] = None ) -> Variable: """ Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. @@ -1037,8 +1231,8 @@ def create_variable(self, function_id: str, key: str, value: str, secret: Option Returns ------- - Dict[str, Any] - API response as a dictionary + Variable + API response as a typed Pydantic model Raises ------ @@ -1057,18 +1251,24 @@ def create_variable(self, function_id: str, key: str, value: str, secret: Option if value is None: raise AppwriteException('Missing required parameter: "value"') - api_path = api_path.replace('{functionId}', function_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) - api_params['key'] = key - api_params['value'] = value + api_params['key'] = self._normalize_value(key) + api_params['value'] = self._normalize_value(value) if secret is not None: - api_params['secret'] = secret + api_params['secret'] = self._normalize_value(secret) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_variable(self, function_id: str, variable_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Variable) + + + def get_variable( + self, + function_id: str, + variable_id: str ) -> Variable: """ Get a variable by its unique ID. @@ -1081,8 +1281,8 @@ def get_variable(self, function_id: str, variable_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Variable + API response as a typed Pydantic model Raises ------ @@ -1098,14 +1298,23 @@ def get_variable(self, function_id: str, variable_id: str) -> Dict[str, Any]: if variable_id is None: raise AppwriteException('Missing required parameter: "variable_id"') - api_path = api_path.replace('{functionId}', function_id) - api_path = api_path.replace('{variableId}', variable_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_variable(self, function_id: str, variable_id: str, key: str, value: Optional[str] = None, secret: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Variable) + + + def update_variable( + self, + function_id: str, + variable_id: str, + key: str, + value: Optional[str] = None, + secret: Optional[bool] = None ) -> Variable: """ Update variable by its unique ID. @@ -1124,8 +1333,8 @@ def update_variable(self, function_id: str, variable_id: str, key: str, value: O Returns ------- - Dict[str, Any] - API response as a dictionary + Variable + API response as a typed Pydantic model Raises ------ @@ -1144,18 +1353,24 @@ def update_variable(self, function_id: str, variable_id: str, key: str, value: O if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{functionId}', function_id) - api_path = api_path.replace('{variableId}', variable_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - api_params['key'] = key - api_params['value'] = value - api_params['secret'] = secret + api_params['key'] = self._normalize_value(key) + api_params['value'] = self._normalize_value(value) + api_params['secret'] = self._normalize_value(secret) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete_variable(self, function_id: str, variable_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Variable) + + + def delete_variable( + self, + function_id: str, + variable_id: str ) -> Dict[str, Any]: """ Delete a variable by its unique ID. @@ -1185,10 +1400,13 @@ def delete_variable(self, function_id: str, variable_id: str) -> Dict[str, Any]: if variable_id is None: raise AppwriteException('Missing required parameter: "variable_id"') - api_path = api_path.replace('{functionId}', function_id) - api_path = api_path.replace('{variableId}', variable_id) + api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + + return response + diff --git a/appwrite/services/graphql.py b/appwrite/services/graphql.py index a4849b0..7ea15c1 100644 --- a/appwrite/services/graphql.py +++ b/appwrite/services/graphql.py @@ -1,5 +1,5 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated @@ -8,13 +8,15 @@ class Graphql(Service): def __init__(self, client) -> None: super(Graphql, self).__init__(client) - def query(self, query: dict) -> Dict[str, Any]: + def query( + self, + query: Dict[str, Any] ) -> Dict[str, Any]: """ Execute a GraphQL mutation. Parameters ---------- - query : dict + query : Dict[str, Any] The query or queries to execute. Returns @@ -34,20 +36,25 @@ def query(self, query: dict) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "query"') - api_params['query'] = query + api_params['query'] = self._normalize_value(query) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }, api_params) - def mutation(self, query: dict) -> Dict[str, Any]: + return response + + + def mutation( + self, + query: Dict[str, Any] ) -> Dict[str, Any]: """ Execute a GraphQL mutation. Parameters ---------- - query : dict + query : Dict[str, Any] The query or queries to execute. Returns @@ -67,9 +74,12 @@ def mutation(self, query: dict) -> Dict[str, Any]: raise AppwriteException('Missing required parameter: "query"') - api_params['query'] = query + api_params['query'] = self._normalize_value(query) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }, api_params) + + return response + diff --git a/appwrite/services/health.py b/appwrite/services/health.py index b0ba18b..7249b67 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -1,22 +1,29 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.health_status import HealthStatus; +from ..models.health_antivirus import HealthAntivirus; +from ..models.health_status_list import HealthStatusList; +from ..models.health_certificate import HealthCertificate; +from ..models.health_queue import HealthQueue; from ..enums.name import Name; +from ..models.health_time import HealthTime; class Health(Service): def __init__(self, client) -> None: super(Health, self).__init__(client) - def get(self) -> Dict[str, Any]: + def get( + self ) -> HealthStatus: """ Check the Appwrite HTTP server is up and responsive. Returns ------- - Dict[str, Any] - API response as a dictionary + HealthStatus + API response as a typed Pydantic model Raises ------ @@ -27,17 +34,21 @@ def get(self) -> Dict[str, Any]: api_path = '/health' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_antivirus(self) -> Dict[str, Any]: + return self._parse_response(response, model=HealthStatus) + + + def get_antivirus( + self ) -> HealthAntivirus: """ Check the Appwrite Antivirus server is up and connection is successful. Returns ------- - Dict[str, Any] - API response as a dictionary + HealthAntivirus + API response as a typed Pydantic model Raises ------ @@ -48,17 +59,21 @@ def get_antivirus(self) -> Dict[str, Any]: api_path = '/health/anti-virus' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_cache(self) -> Dict[str, Any]: + return self._parse_response(response, model=HealthAntivirus) + + + def get_cache( + self ) -> HealthStatusList: """ Check the Appwrite in-memory cache servers are up and connection is successful. Returns ------- - Dict[str, Any] - API response as a dictionary + HealthStatusList + API response as a typed Pydantic model Raises ------ @@ -69,10 +84,15 @@ def get_cache(self) -> Dict[str, Any]: api_path = '/health/cache' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_certificate(self, domain: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthStatusList) + + + def get_certificate( + self, + domain: Optional[str] = None ) -> HealthCertificate: """ Get the SSL certificate for a domain @@ -83,8 +103,8 @@ def get_certificate(self, domain: Optional[str] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + HealthCertificate + API response as a typed Pydantic model Raises ------ @@ -96,12 +116,18 @@ def get_certificate(self, domain: Optional[str] = None) -> Dict[str, Any]: api_params = {} if domain is not None: - api_params['domain'] = domain + api_params['domain'] = self._normalize_value(domain) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_console_pausing(self, threshold: Optional[float] = None, inactivity_days: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthCertificate) + + + def get_console_pausing( + self, + threshold: Optional[float] = None, + inactivity_days: Optional[float] = None ) -> HealthStatus: """ Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking. @@ -115,8 +141,8 @@ def get_console_pausing(self, threshold: Optional[float] = None, inactivity_days Returns ------- - Dict[str, Any] - API response as a dictionary + HealthStatus + API response as a typed Pydantic model Raises ------ @@ -128,21 +154,25 @@ def get_console_pausing(self, threshold: Optional[float] = None, inactivity_days api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) if inactivity_days is not None: - api_params['inactivityDays'] = inactivity_days + api_params['inactivityDays'] = self._normalize_value(inactivity_days) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_db(self) -> Dict[str, Any]: + return self._parse_response(response, model=HealthStatus) + + + def get_db( + self ) -> HealthStatusList: """ Check the Appwrite database servers are up and connection is successful. Returns ------- - Dict[str, Any] - API response as a dictionary + HealthStatusList + API response as a typed Pydantic model Raises ------ @@ -153,17 +183,21 @@ def get_db(self) -> Dict[str, Any]: api_path = '/health/db' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_pub_sub(self) -> Dict[str, Any]: + return self._parse_response(response, model=HealthStatusList) + + + def get_pub_sub( + self ) -> HealthStatusList: """ Check the Appwrite pub-sub servers are up and connection is successful. Returns ------- - Dict[str, Any] - API response as a dictionary + HealthStatusList + API response as a typed Pydantic model Raises ------ @@ -174,10 +208,15 @@ def get_pub_sub(self) -> Dict[str, Any]: api_path = '/health/pubsub' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_audits(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthStatusList) + + + def get_queue_audits( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server. @@ -188,8 +227,8 @@ def get_queue_audits(self, threshold: Optional[float] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -201,12 +240,17 @@ def get_queue_audits(self, threshold: Optional[float] = None) -> Dict[str, Any]: api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_billing_project_aggregation(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_billing_project_aggregation( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get billing project aggregation queue. @@ -217,8 +261,8 @@ def get_queue_billing_project_aggregation(self, threshold: Optional[float] = Non Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -230,12 +274,17 @@ def get_queue_billing_project_aggregation(self, threshold: Optional[float] = Non api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_billing_team_aggregation(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_billing_team_aggregation( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get billing team aggregation queue. @@ -246,8 +295,8 @@ def get_queue_billing_team_aggregation(self, threshold: Optional[float] = None) Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -259,12 +308,17 @@ def get_queue_billing_team_aggregation(self, threshold: Optional[float] = None) api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_builds(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_builds( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of builds that are waiting to be processed in the Appwrite internal queue server. @@ -275,8 +329,8 @@ def get_queue_builds(self, threshold: Optional[float] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -288,12 +342,17 @@ def get_queue_builds(self, threshold: Optional[float] = None) -> Dict[str, Any]: api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_priority_builds(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_priority_builds( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the priority builds queue size. @@ -304,8 +363,8 @@ def get_queue_priority_builds(self, threshold: Optional[float] = None) -> Dict[s Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -317,12 +376,17 @@ def get_queue_priority_builds(self, threshold: Optional[float] = None) -> Dict[s api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_certificates(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_certificates( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. @@ -333,8 +397,8 @@ def get_queue_certificates(self, threshold: Optional[float] = None) -> Dict[str, Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -346,12 +410,18 @@ def get_queue_certificates(self, threshold: Optional[float] = None) -> Dict[str, api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_databases(self, name: Optional[str] = None, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_databases( + self, + name: Optional[str] = None, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. @@ -364,8 +434,8 @@ def get_queue_databases(self, name: Optional[str] = None, threshold: Optional[fl Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -377,14 +447,19 @@ def get_queue_databases(self, name: Optional[str] = None, threshold: Optional[fl api_params = {} if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_deletes(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_deletes( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. @@ -395,8 +470,8 @@ def get_queue_deletes(self, threshold: Optional[float] = None) -> Dict[str, Any] Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -408,12 +483,18 @@ def get_queue_deletes(self, threshold: Optional[float] = None) -> Dict[str, Any] api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_failed_jobs(self, name: Name, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_failed_jobs( + self, + name: Name, + threshold: Optional[float] = None ) -> HealthQueue: """ Returns the amount of failed jobs in a given queue. @@ -427,8 +508,8 @@ def get_failed_jobs(self, name: Name, threshold: Optional[float] = None) -> Dict Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -441,15 +522,20 @@ def get_failed_jobs(self, name: Name, threshold: Optional[float] = None) -> Dict if name is None: raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{name}', name) + api_path = api_path.replace('{name}', str(self._normalize_value(name))) if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_functions(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_functions( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of function executions that are waiting to be processed in the Appwrite internal queue server. @@ -460,8 +546,8 @@ def get_queue_functions(self, threshold: Optional[float] = None) -> Dict[str, An Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -473,12 +559,17 @@ def get_queue_functions(self, threshold: Optional[float] = None) -> Dict[str, An api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_logs(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_logs( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of logs that are waiting to be processed in the Appwrite internal queue server. @@ -489,8 +580,8 @@ def get_queue_logs(self, threshold: Optional[float] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -502,12 +593,17 @@ def get_queue_logs(self, threshold: Optional[float] = None) -> Dict[str, Any]: api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_mails(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_mails( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of mails that are waiting to be processed in the Appwrite internal queue server. @@ -518,8 +614,8 @@ def get_queue_mails(self, threshold: Optional[float] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -531,12 +627,17 @@ def get_queue_mails(self, threshold: Optional[float] = None) -> Dict[str, Any]: api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_messaging(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_messaging( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of messages that are waiting to be processed in the Appwrite internal queue server. @@ -547,8 +648,8 @@ def get_queue_messaging(self, threshold: Optional[float] = None) -> Dict[str, An Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -560,12 +661,17 @@ def get_queue_messaging(self, threshold: Optional[float] = None) -> Dict[str, An api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_migrations(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_migrations( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. @@ -576,8 +682,8 @@ def get_queue_migrations(self, threshold: Optional[float] = None) -> Dict[str, A Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -589,12 +695,17 @@ def get_queue_migrations(self, threshold: Optional[float] = None) -> Dict[str, A api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_region_manager(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_region_manager( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get region manager queue. @@ -605,8 +716,8 @@ def get_queue_region_manager(self, threshold: Optional[float] = None) -> Dict[st Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -618,12 +729,17 @@ def get_queue_region_manager(self, threshold: Optional[float] = None) -> Dict[st api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_stats_resources(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_stats_resources( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. @@ -634,8 +750,8 @@ def get_queue_stats_resources(self, threshold: Optional[float] = None) -> Dict[s Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -647,12 +763,17 @@ def get_queue_stats_resources(self, threshold: Optional[float] = None) -> Dict[s api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_usage(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_usage( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of metrics that are waiting to be processed in the Appwrite internal queue server. @@ -663,8 +784,8 @@ def get_queue_usage(self, threshold: Optional[float] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -676,12 +797,17 @@ def get_queue_usage(self, threshold: Optional[float] = None) -> Dict[str, Any]: api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_threats(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_threats( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get threats queue. @@ -692,8 +818,8 @@ def get_queue_threats(self, threshold: Optional[float] = None) -> Dict[str, Any] Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -705,12 +831,17 @@ def get_queue_threats(self, threshold: Optional[float] = None) -> Dict[str, Any] api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_queue_webhooks(self, threshold: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_queue_webhooks( + self, + threshold: Optional[float] = None ) -> HealthQueue: """ Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. @@ -721,8 +852,8 @@ def get_queue_webhooks(self, threshold: Optional[float] = None) -> Dict[str, Any Returns ------- - Dict[str, Any] - API response as a dictionary + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -734,19 +865,23 @@ def get_queue_webhooks(self, threshold: Optional[float] = None) -> Dict[str, Any api_params = {} if threshold is not None: - api_params['threshold'] = threshold + api_params['threshold'] = self._normalize_value(threshold) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_storage(self) -> Dict[str, Any]: + return self._parse_response(response, model=HealthQueue) + + + def get_storage( + self ) -> HealthStatus: """ Check the Appwrite storage device is up and connection is successful. Returns ------- - Dict[str, Any] - API response as a dictionary + HealthStatus + API response as a typed Pydantic model Raises ------ @@ -757,17 +892,21 @@ def get_storage(self) -> Dict[str, Any]: api_path = '/health/storage' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_storage_local(self) -> Dict[str, Any]: + return self._parse_response(response, model=HealthStatus) + + + def get_storage_local( + self ) -> HealthStatus: """ Check the Appwrite local storage device is up and connection is successful. Returns ------- - Dict[str, Any] - API response as a dictionary + HealthStatus + API response as a typed Pydantic model Raises ------ @@ -778,17 +917,21 @@ def get_storage_local(self) -> Dict[str, Any]: api_path = '/health/storage/local' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_time(self) -> Dict[str, Any]: + return self._parse_response(response, model=HealthStatus) + + + def get_time( + self ) -> HealthTime: """ Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP. Returns ------- - Dict[str, Any] - API response as a dictionary + HealthTime + API response as a typed Pydantic model Raises ------ @@ -799,5 +942,8 @@ def get_time(self) -> Dict[str, Any]: api_path = '/health/time' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + + return self._parse_response(response, model=HealthTime) + diff --git a/appwrite/services/locale.py b/appwrite/services/locale.py index ea3e083..4f835c9 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -1,14 +1,22 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.locale import Locale as LocaleModel; +from ..models.locale_code_list import LocaleCodeList; +from ..models.continent_list import ContinentList; +from ..models.country_list import CountryList; +from ..models.phone_list import PhoneList; +from ..models.currency_list import CurrencyList; +from ..models.language_list import LanguageList; class Locale(Service): def __init__(self, client) -> None: super(Locale, self).__init__(client) - def get(self) -> Dict[str, Any]: + def get( + self ) -> LocaleModel: """ Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. @@ -16,8 +24,8 @@ def get(self) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Locale + API response as a typed Pydantic model Raises ------ @@ -28,17 +36,21 @@ def get(self) -> Dict[str, Any]: api_path = '/locale' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_codes(self) -> Dict[str, Any]: + return self._parse_response(response, model=LocaleModel) + + + def list_codes( + self ) -> LocaleCodeList: """ List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). Returns ------- - Dict[str, Any] - API response as a dictionary + LocaleCodeList + API response as a typed Pydantic model Raises ------ @@ -49,17 +61,21 @@ def list_codes(self) -> Dict[str, Any]: api_path = '/locale/codes' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_continents(self) -> Dict[str, Any]: + return self._parse_response(response, model=LocaleCodeList) + + + def list_continents( + self ) -> ContinentList: """ List of all continents. You can use the locale header to get the data in a supported language. Returns ------- - Dict[str, Any] - API response as a dictionary + ContinentList + API response as a typed Pydantic model Raises ------ @@ -70,17 +86,21 @@ def list_continents(self) -> Dict[str, Any]: api_path = '/locale/continents' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_countries(self) -> Dict[str, Any]: + return self._parse_response(response, model=ContinentList) + + + def list_countries( + self ) -> CountryList: """ List of all countries. You can use the locale header to get the data in a supported language. Returns ------- - Dict[str, Any] - API response as a dictionary + CountryList + API response as a typed Pydantic model Raises ------ @@ -91,17 +111,21 @@ def list_countries(self) -> Dict[str, Any]: api_path = '/locale/countries' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_countries_eu(self) -> Dict[str, Any]: + return self._parse_response(response, model=CountryList) + + + def list_countries_eu( + self ) -> CountryList: """ List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. Returns ------- - Dict[str, Any] - API response as a dictionary + CountryList + API response as a typed Pydantic model Raises ------ @@ -112,17 +136,21 @@ def list_countries_eu(self) -> Dict[str, Any]: api_path = '/locale/countries/eu' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_countries_phones(self) -> Dict[str, Any]: + return self._parse_response(response, model=CountryList) + + + def list_countries_phones( + self ) -> PhoneList: """ List of all countries phone codes. You can use the locale header to get the data in a supported language. Returns ------- - Dict[str, Any] - API response as a dictionary + PhoneList + API response as a typed Pydantic model Raises ------ @@ -133,17 +161,21 @@ def list_countries_phones(self) -> Dict[str, Any]: api_path = '/locale/countries/phones' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_currencies(self) -> Dict[str, Any]: + return self._parse_response(response, model=PhoneList) + + + def list_currencies( + self ) -> CurrencyList: """ List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language. Returns ------- - Dict[str, Any] - API response as a dictionary + CurrencyList + API response as a typed Pydantic model Raises ------ @@ -154,17 +186,21 @@ def list_currencies(self) -> Dict[str, Any]: api_path = '/locale/currencies' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_languages(self) -> Dict[str, Any]: + return self._parse_response(response, model=CurrencyList) + + + def list_languages( + self ) -> LanguageList: """ List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language. Returns ------- - Dict[str, Any] - API response as a dictionary + LanguageList + API response as a typed Pydantic model Raises ------ @@ -175,5 +211,8 @@ def list_languages(self) -> Dict[str, Any]: api_path = '/locale/languages' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + + return self._parse_response(response, model=LanguageList) + diff --git a/appwrite/services/messaging.py b/appwrite/services/messaging.py index b412775..7c66f5f 100644 --- a/appwrite/services/messaging.py +++ b/appwrite/services/messaging.py @@ -1,16 +1,30 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.message_list import MessageList; +from ..models.message import Message; from ..enums.message_priority import MessagePriority; +from ..models.log_list import LogList; +from ..models.target_list import TargetList; +from ..models.provider_list import ProviderList; +from ..models.provider import Provider; from ..enums.smtp_encryption import SmtpEncryption; +from ..models.topic_list import TopicList; +from ..models.topic import Topic; +from ..models.subscriber_list import SubscriberList; +from ..models.subscriber import Subscriber; class Messaging(Service): def __init__(self, client) -> None: super(Messaging, self).__init__(client) - def list_messages(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list_messages( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> MessageList: """ Get a list of all messages from the current Appwrite project. @@ -25,8 +39,8 @@ def list_messages(self, queries: Optional[List[str]] = None, search: Optional[st Returns ------- - Dict[str, Any] - API response as a dictionary + MessageList + API response as a typed Pydantic model Raises ------ @@ -38,16 +52,32 @@ def list_messages(self, queries: Optional[List[str]] = None, search: Optional[st api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_email(self, message_id: str, subject: str, content: str, topics: Optional[List[str]] = None, users: Optional[List[str]] = None, targets: Optional[List[str]] = None, cc: Optional[List[str]] = None, bcc: Optional[List[str]] = None, attachments: Optional[List[str]] = None, draft: Optional[bool] = None, html: Optional[bool] = None, scheduled_at: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=MessageList) + + + def create_email( + self, + message_id: str, + subject: str, + content: str, + topics: Optional[List[str]] = None, + users: Optional[List[str]] = None, + targets: Optional[List[str]] = None, + cc: Optional[List[str]] = None, + bcc: Optional[List[str]] = None, + attachments: Optional[List[str]] = None, + draft: Optional[bool] = None, + html: Optional[bool] = None, + scheduled_at: Optional[str] = None ) -> Message: """ Create a new email message. @@ -80,8 +110,8 @@ def create_email(self, message_id: str, subject: str, content: str, topics: Opti Returns ------- - Dict[str, Any] - API response as a dictionary + Message + API response as a typed Pydantic model Raises ------ @@ -101,32 +131,48 @@ def create_email(self, message_id: str, subject: str, content: str, topics: Opti raise AppwriteException('Missing required parameter: "content"') - api_params['messageId'] = message_id - api_params['subject'] = subject - api_params['content'] = content + api_params['messageId'] = self._normalize_value(message_id) + api_params['subject'] = self._normalize_value(subject) + api_params['content'] = self._normalize_value(content) if topics is not None: - api_params['topics'] = topics + api_params['topics'] = self._normalize_value(topics) if users is not None: - api_params['users'] = users + api_params['users'] = self._normalize_value(users) if targets is not None: - api_params['targets'] = targets + api_params['targets'] = self._normalize_value(targets) if cc is not None: - api_params['cc'] = cc + api_params['cc'] = self._normalize_value(cc) if bcc is not None: - api_params['bcc'] = bcc + api_params['bcc'] = self._normalize_value(bcc) if attachments is not None: - api_params['attachments'] = attachments + api_params['attachments'] = self._normalize_value(attachments) if draft is not None: - api_params['draft'] = draft + api_params['draft'] = self._normalize_value(draft) if html is not None: - api_params['html'] = html - api_params['scheduledAt'] = scheduled_at + api_params['html'] = self._normalize_value(html) + api_params['scheduledAt'] = self._normalize_value(scheduled_at) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_email(self, message_id: str, topics: Optional[List[str]] = None, users: Optional[List[str]] = None, targets: Optional[List[str]] = None, subject: Optional[str] = None, content: Optional[str] = None, draft: Optional[bool] = None, html: Optional[bool] = None, cc: Optional[List[str]] = None, bcc: Optional[List[str]] = None, scheduled_at: Optional[str] = None, attachments: Optional[List[str]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Message) + + + def update_email( + self, + message_id: str, + topics: Optional[List[str]] = None, + users: Optional[List[str]] = None, + targets: Optional[List[str]] = None, + subject: Optional[str] = None, + content: Optional[str] = None, + draft: Optional[bool] = None, + html: Optional[bool] = None, + cc: Optional[List[str]] = None, + bcc: Optional[List[str]] = None, + scheduled_at: Optional[str] = None, + attachments: Optional[List[str]] = None ) -> Message: """ Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. @@ -160,8 +206,8 @@ def update_email(self, message_id: str, topics: Optional[List[str]] = None, user Returns ------- - Dict[str, Any] - API response as a dictionary + Message + API response as a typed Pydantic model Raises ------ @@ -174,25 +220,48 @@ def update_email(self, message_id: str, topics: Optional[List[str]] = None, user if message_id is None: raise AppwriteException('Missing required parameter: "message_id"') - api_path = api_path.replace('{messageId}', message_id) - - api_params['topics'] = topics - api_params['users'] = users - api_params['targets'] = targets - api_params['subject'] = subject - api_params['content'] = content - api_params['draft'] = draft - api_params['html'] = html - api_params['cc'] = cc - api_params['bcc'] = bcc - api_params['scheduledAt'] = scheduled_at - api_params['attachments'] = attachments - - return self.client.call('patch', api_path, { + api_path = api_path.replace('{messageId}', str(self._normalize_value(message_id))) + + api_params['topics'] = self._normalize_value(topics) + api_params['users'] = self._normalize_value(users) + api_params['targets'] = self._normalize_value(targets) + api_params['subject'] = self._normalize_value(subject) + api_params['content'] = self._normalize_value(content) + api_params['draft'] = self._normalize_value(draft) + api_params['html'] = self._normalize_value(html) + api_params['cc'] = self._normalize_value(cc) + api_params['bcc'] = self._normalize_value(bcc) + api_params['scheduledAt'] = self._normalize_value(scheduled_at) + api_params['attachments'] = self._normalize_value(attachments) + + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_push(self, message_id: str, title: Optional[str] = None, body: Optional[str] = None, topics: Optional[List[str]] = None, users: Optional[List[str]] = None, targets: Optional[List[str]] = None, data: Optional[dict] = None, action: Optional[str] = None, image: Optional[str] = None, icon: Optional[str] = None, sound: Optional[str] = None, color: Optional[str] = None, tag: Optional[str] = None, badge: Optional[float] = None, draft: Optional[bool] = None, scheduled_at: Optional[str] = None, content_available: Optional[bool] = None, critical: Optional[bool] = None, priority: Optional[MessagePriority] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Message) + + + def create_push( + self, + message_id: str, + title: Optional[str] = None, + body: Optional[str] = None, + topics: Optional[List[str]] = None, + users: Optional[List[str]] = None, + targets: Optional[List[str]] = None, + data: Optional[Dict[str, Any]] = None, + action: Optional[str] = None, + image: Optional[str] = None, + icon: Optional[str] = None, + sound: Optional[str] = None, + color: Optional[str] = None, + tag: Optional[str] = None, + badge: Optional[float] = None, + draft: Optional[bool] = None, + scheduled_at: Optional[str] = None, + content_available: Optional[bool] = None, + critical: Optional[bool] = None, + priority: Optional[MessagePriority] = None ) -> Message: """ Create a new push notification. @@ -210,7 +279,7 @@ def create_push(self, message_id: str, title: Optional[str] = None, body: Option List of User IDs. targets : Optional[List[str]] List of Targets IDs. - data : Optional[dict] + data : Optional[Dict[str, Any]] Additional key-value pair data for push notification. action : Optional[str] Action for push notification. @@ -239,8 +308,8 @@ def create_push(self, message_id: str, title: Optional[str] = None, body: Option Returns ------- - Dict[str, Any] - API response as a dictionary + Message + API response as a typed Pydantic model Raises ------ @@ -254,47 +323,70 @@ def create_push(self, message_id: str, title: Optional[str] = None, body: Option raise AppwriteException('Missing required parameter: "message_id"') - api_params['messageId'] = message_id + api_params['messageId'] = self._normalize_value(message_id) if title is not None: - api_params['title'] = title + api_params['title'] = self._normalize_value(title) if body is not None: - api_params['body'] = body + api_params['body'] = self._normalize_value(body) if topics is not None: - api_params['topics'] = topics + api_params['topics'] = self._normalize_value(topics) if users is not None: - api_params['users'] = users + api_params['users'] = self._normalize_value(users) if targets is not None: - api_params['targets'] = targets - api_params['data'] = data + api_params['targets'] = self._normalize_value(targets) + api_params['data'] = self._normalize_value(data) if action is not None: - api_params['action'] = action + api_params['action'] = self._normalize_value(action) if image is not None: - api_params['image'] = image + api_params['image'] = self._normalize_value(image) if icon is not None: - api_params['icon'] = icon + api_params['icon'] = self._normalize_value(icon) if sound is not None: - api_params['sound'] = sound + api_params['sound'] = self._normalize_value(sound) if color is not None: - api_params['color'] = color + api_params['color'] = self._normalize_value(color) if tag is not None: - api_params['tag'] = tag + api_params['tag'] = self._normalize_value(tag) if badge is not None: - api_params['badge'] = badge + api_params['badge'] = self._normalize_value(badge) if draft is not None: - api_params['draft'] = draft - api_params['scheduledAt'] = scheduled_at + api_params['draft'] = self._normalize_value(draft) + api_params['scheduledAt'] = self._normalize_value(scheduled_at) if content_available is not None: - api_params['contentAvailable'] = content_available + api_params['contentAvailable'] = self._normalize_value(content_available) if critical is not None: - api_params['critical'] = critical + api_params['critical'] = self._normalize_value(critical) if priority is not None: - api_params['priority'] = priority + api_params['priority'] = self._normalize_value(priority) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_push(self, message_id: str, topics: Optional[List[str]] = None, users: Optional[List[str]] = None, targets: Optional[List[str]] = None, title: Optional[str] = None, body: Optional[str] = None, data: Optional[dict] = None, action: Optional[str] = None, image: Optional[str] = None, icon: Optional[str] = None, sound: Optional[str] = None, color: Optional[str] = None, tag: Optional[str] = None, badge: Optional[float] = None, draft: Optional[bool] = None, scheduled_at: Optional[str] = None, content_available: Optional[bool] = None, critical: Optional[bool] = None, priority: Optional[MessagePriority] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Message) + + + def update_push( + self, + message_id: str, + topics: Optional[List[str]] = None, + users: Optional[List[str]] = None, + targets: Optional[List[str]] = None, + title: Optional[str] = None, + body: Optional[str] = None, + data: Optional[Dict[str, Any]] = None, + action: Optional[str] = None, + image: Optional[str] = None, + icon: Optional[str] = None, + sound: Optional[str] = None, + color: Optional[str] = None, + tag: Optional[str] = None, + badge: Optional[float] = None, + draft: Optional[bool] = None, + scheduled_at: Optional[str] = None, + content_available: Optional[bool] = None, + critical: Optional[bool] = None, + priority: Optional[MessagePriority] = None ) -> Message: """ Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. @@ -313,7 +405,7 @@ def update_push(self, message_id: str, topics: Optional[List[str]] = None, users Title for push notification. body : Optional[str] Body for push notification. - data : Optional[dict] + data : Optional[Dict[str, Any]] Additional Data for push notification. action : Optional[str] Action for push notification. @@ -342,8 +434,8 @@ def update_push(self, message_id: str, topics: Optional[List[str]] = None, users Returns ------- - Dict[str, Any] - API response as a dictionary + Message + API response as a typed Pydantic model Raises ------ @@ -356,32 +448,43 @@ def update_push(self, message_id: str, topics: Optional[List[str]] = None, users if message_id is None: raise AppwriteException('Missing required parameter: "message_id"') - api_path = api_path.replace('{messageId}', message_id) - - api_params['topics'] = topics - api_params['users'] = users - api_params['targets'] = targets - api_params['title'] = title - api_params['body'] = body - api_params['data'] = data - api_params['action'] = action - api_params['image'] = image - api_params['icon'] = icon - api_params['sound'] = sound - api_params['color'] = color - api_params['tag'] = tag - api_params['badge'] = badge - api_params['draft'] = draft - api_params['scheduledAt'] = scheduled_at - api_params['contentAvailable'] = content_available - api_params['critical'] = critical - api_params['priority'] = priority - - return self.client.call('patch', api_path, { + api_path = api_path.replace('{messageId}', str(self._normalize_value(message_id))) + + api_params['topics'] = self._normalize_value(topics) + api_params['users'] = self._normalize_value(users) + api_params['targets'] = self._normalize_value(targets) + api_params['title'] = self._normalize_value(title) + api_params['body'] = self._normalize_value(body) + api_params['data'] = self._normalize_value(data) + api_params['action'] = self._normalize_value(action) + api_params['image'] = self._normalize_value(image) + api_params['icon'] = self._normalize_value(icon) + api_params['sound'] = self._normalize_value(sound) + api_params['color'] = self._normalize_value(color) + api_params['tag'] = self._normalize_value(tag) + api_params['badge'] = self._normalize_value(badge) + api_params['draft'] = self._normalize_value(draft) + api_params['scheduledAt'] = self._normalize_value(scheduled_at) + api_params['contentAvailable'] = self._normalize_value(content_available) + api_params['critical'] = self._normalize_value(critical) + api_params['priority'] = self._normalize_value(priority) + + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_sms(self, message_id: str, content: str, topics: Optional[List[str]] = None, users: Optional[List[str]] = None, targets: Optional[List[str]] = None, draft: Optional[bool] = None, scheduled_at: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Message) + + + def create_sms( + self, + message_id: str, + content: str, + topics: Optional[List[str]] = None, + users: Optional[List[str]] = None, + targets: Optional[List[str]] = None, + draft: Optional[bool] = None, + scheduled_at: Optional[str] = None ) -> Message: """ Create a new SMS message. @@ -404,8 +507,8 @@ def create_sms(self, message_id: str, content: str, topics: Optional[List[str]] Returns ------- - Dict[str, Any] - API response as a dictionary + Message + API response as a typed Pydantic model Raises ------ @@ -422,23 +525,34 @@ def create_sms(self, message_id: str, content: str, topics: Optional[List[str]] raise AppwriteException('Missing required parameter: "content"') - api_params['messageId'] = message_id - api_params['content'] = content + api_params['messageId'] = self._normalize_value(message_id) + api_params['content'] = self._normalize_value(content) if topics is not None: - api_params['topics'] = topics + api_params['topics'] = self._normalize_value(topics) if users is not None: - api_params['users'] = users + api_params['users'] = self._normalize_value(users) if targets is not None: - api_params['targets'] = targets + api_params['targets'] = self._normalize_value(targets) if draft is not None: - api_params['draft'] = draft - api_params['scheduledAt'] = scheduled_at + api_params['draft'] = self._normalize_value(draft) + api_params['scheduledAt'] = self._normalize_value(scheduled_at) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_sms(self, message_id: str, topics: Optional[List[str]] = None, users: Optional[List[str]] = None, targets: Optional[List[str]] = None, content: Optional[str] = None, draft: Optional[bool] = None, scheduled_at: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Message) + + + def update_sms( + self, + message_id: str, + topics: Optional[List[str]] = None, + users: Optional[List[str]] = None, + targets: Optional[List[str]] = None, + content: Optional[str] = None, + draft: Optional[bool] = None, + scheduled_at: Optional[str] = None ) -> Message: """ Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. @@ -462,8 +576,8 @@ def update_sms(self, message_id: str, topics: Optional[List[str]] = None, users: Returns ------- - Dict[str, Any] - API response as a dictionary + Message + API response as a typed Pydantic model Raises ------ @@ -476,20 +590,25 @@ def update_sms(self, message_id: str, topics: Optional[List[str]] = None, users: if message_id is None: raise AppwriteException('Missing required parameter: "message_id"') - api_path = api_path.replace('{messageId}', message_id) + api_path = api_path.replace('{messageId}', str(self._normalize_value(message_id))) - api_params['topics'] = topics - api_params['users'] = users - api_params['targets'] = targets - api_params['content'] = content - api_params['draft'] = draft - api_params['scheduledAt'] = scheduled_at + api_params['topics'] = self._normalize_value(topics) + api_params['users'] = self._normalize_value(users) + api_params['targets'] = self._normalize_value(targets) + api_params['content'] = self._normalize_value(content) + api_params['draft'] = self._normalize_value(draft) + api_params['scheduledAt'] = self._normalize_value(scheduled_at) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def get_message(self, message_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Message) + + + def get_message( + self, + message_id: str ) -> Message: """ Get a message by its unique ID. @@ -501,8 +620,8 @@ def get_message(self, message_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Message + API response as a typed Pydantic model Raises ------ @@ -515,13 +634,18 @@ def get_message(self, message_id: str) -> Dict[str, Any]: if message_id is None: raise AppwriteException('Missing required parameter: "message_id"') - api_path = api_path.replace('{messageId}', message_id) + api_path = api_path.replace('{messageId}', str(self._normalize_value(message_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete(self, message_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Message) + + + def delete( + self, + message_id: str ) -> Dict[str, Any]: """ Delete a message. If the message is not a draft or scheduled, but has been sent, this will not recall the message. @@ -546,14 +670,21 @@ def delete(self, message_id: str) -> Dict[str, Any]: if message_id is None: raise AppwriteException('Missing required parameter: "message_id"') - api_path = api_path.replace('{messageId}', message_id) + api_path = api_path.replace('{messageId}', str(self._normalize_value(message_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_message_logs(self, message_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return response + + + def list_message_logs( + self, + message_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> LogList: """ Get the message activity logs listed by its unique ID. @@ -568,8 +699,8 @@ def list_message_logs(self, message_id: str, queries: Optional[List[str]] = None Returns ------- - Dict[str, Any] - API response as a dictionary + LogList + API response as a typed Pydantic model Raises ------ @@ -582,17 +713,24 @@ def list_message_logs(self, message_id: str, queries: Optional[List[str]] = None if message_id is None: raise AppwriteException('Missing required parameter: "message_id"') - api_path = api_path.replace('{messageId}', message_id) + api_path = api_path.replace('{messageId}', str(self._normalize_value(message_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_targets(self, message_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=LogList) + + + def list_targets( + self, + message_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> TargetList: """ Get a list of the targets associated with a message. @@ -607,8 +745,8 @@ def list_targets(self, message_id: str, queries: Optional[List[str]] = None, tot Returns ------- - Dict[str, Any] - API response as a dictionary + TargetList + API response as a typed Pydantic model Raises ------ @@ -621,17 +759,24 @@ def list_targets(self, message_id: str, queries: Optional[List[str]] = None, tot if message_id is None: raise AppwriteException('Missing required parameter: "message_id"') - api_path = api_path.replace('{messageId}', message_id) + api_path = api_path.replace('{messageId}', str(self._normalize_value(message_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_providers(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=TargetList) + + + def list_providers( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> ProviderList: """ Get a list of all providers from the current Appwrite project. @@ -646,8 +791,8 @@ def list_providers(self, queries: Optional[List[str]] = None, search: Optional[s Returns ------- - Dict[str, Any] - API response as a dictionary + ProviderList + API response as a typed Pydantic model Raises ------ @@ -659,16 +804,28 @@ def list_providers(self, queries: Optional[List[str]] = None, search: Optional[s api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_apns_provider(self, provider_id: str, name: str, auth_key: Optional[str] = None, auth_key_id: Optional[str] = None, team_id: Optional[str] = None, bundle_id: Optional[str] = None, sandbox: Optional[bool] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ProviderList) + + + def create_apns_provider( + self, + provider_id: str, + name: str, + auth_key: Optional[str] = None, + auth_key_id: Optional[str] = None, + team_id: Optional[str] = None, + bundle_id: Optional[str] = None, + sandbox: Optional[bool] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new Apple Push Notification service provider. @@ -693,8 +850,8 @@ def create_apns_provider(self, provider_id: str, name: str, auth_key: Optional[s Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -711,25 +868,37 @@ def create_apns_provider(self, provider_id: str, name: str, auth_key: Optional[s raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) if auth_key is not None: - api_params['authKey'] = auth_key + api_params['authKey'] = self._normalize_value(auth_key) if auth_key_id is not None: - api_params['authKeyId'] = auth_key_id + api_params['authKeyId'] = self._normalize_value(auth_key_id) if team_id is not None: - api_params['teamId'] = team_id + api_params['teamId'] = self._normalize_value(team_id) if bundle_id is not None: - api_params['bundleId'] = bundle_id + api_params['bundleId'] = self._normalize_value(bundle_id) if sandbox is not None: - api_params['sandbox'] = sandbox - api_params['enabled'] = enabled + api_params['sandbox'] = self._normalize_value(sandbox) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_apns_provider(self, provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, auth_key: Optional[str] = None, auth_key_id: Optional[str] = None, team_id: Optional[str] = None, bundle_id: Optional[str] = None, sandbox: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_apns_provider( + self, + provider_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None, + auth_key: Optional[str] = None, + auth_key_id: Optional[str] = None, + team_id: Optional[str] = None, + bundle_id: Optional[str] = None, + sandbox: Optional[bool] = None ) -> Provider: """ Update a Apple Push Notification service provider by its unique ID. @@ -754,8 +923,8 @@ def update_apns_provider(self, provider_id: str, name: Optional[str] = None, ena Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -768,26 +937,34 @@ def update_apns_provider(self, provider_id: str, name: Optional[str] = None, ena if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name - api_params['enabled'] = enabled + api_params['name'] = self._normalize_value(name) + api_params['enabled'] = self._normalize_value(enabled) if auth_key is not None: - api_params['authKey'] = auth_key + api_params['authKey'] = self._normalize_value(auth_key) if auth_key_id is not None: - api_params['authKeyId'] = auth_key_id + api_params['authKeyId'] = self._normalize_value(auth_key_id) if team_id is not None: - api_params['teamId'] = team_id + api_params['teamId'] = self._normalize_value(team_id) if bundle_id is not None: - api_params['bundleId'] = bundle_id - api_params['sandbox'] = sandbox + api_params['bundleId'] = self._normalize_value(bundle_id) + api_params['sandbox'] = self._normalize_value(sandbox) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_fcm_provider(self, provider_id: str, name: str, service_account_json: Optional[dict] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_fcm_provider( + self, + provider_id: str, + name: str, + service_account_json: Optional[Dict[str, Any]] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new Firebase Cloud Messaging provider. @@ -797,15 +974,15 @@ def create_fcm_provider(self, provider_id: str, name: str, service_account_json: Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. name : str Provider name. - service_account_json : Optional[dict] + service_account_json : Optional[Dict[str, Any]] FCM service account JSON. enabled : Optional[bool] Set as enabled. Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -822,16 +999,24 @@ def create_fcm_provider(self, provider_id: str, name: str, service_account_json: raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name - api_params['serviceAccountJSON'] = service_account_json - api_params['enabled'] = enabled + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) + api_params['serviceAccountJSON'] = self._normalize_value(service_account_json) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_fcm_provider(self, provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, service_account_json: Optional[dict] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_fcm_provider( + self, + provider_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None, + service_account_json: Optional[Dict[str, Any]] = None ) -> Provider: """ Update a Firebase Cloud Messaging provider by its unique ID. @@ -843,13 +1028,13 @@ def update_fcm_provider(self, provider_id: str, name: Optional[str] = None, enab Provider name. enabled : Optional[bool] Set as enabled. - service_account_json : Optional[dict] + service_account_json : Optional[Dict[str, Any]] FCM service account JSON. Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -862,18 +1047,32 @@ def update_fcm_provider(self, provider_id: str, name: Optional[str] = None, enab if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name - api_params['enabled'] = enabled - api_params['serviceAccountJSON'] = service_account_json + api_params['name'] = self._normalize_value(name) + api_params['enabled'] = self._normalize_value(enabled) + api_params['serviceAccountJSON'] = self._normalize_value(service_account_json) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_mailgun_provider(self, provider_id: str, name: str, api_key: Optional[str] = None, domain: Optional[str] = None, is_eu_region: Optional[bool] = None, from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_mailgun_provider( + self, + provider_id: str, + name: str, + api_key: Optional[str] = None, + domain: Optional[str] = None, + is_eu_region: Optional[bool] = None, + from_name: Optional[str] = None, + from_email: Optional[str] = None, + reply_to_name: Optional[str] = None, + reply_to_email: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new Mailgun provider. @@ -902,8 +1101,8 @@ def create_mailgun_provider(self, provider_id: str, name: str, api_key: Optional Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -920,28 +1119,42 @@ def create_mailgun_provider(self, provider_id: str, name: str, api_key: Optional raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if domain is not None: - api_params['domain'] = domain - api_params['isEuRegion'] = is_eu_region + api_params['domain'] = self._normalize_value(domain) + api_params['isEuRegion'] = self._normalize_value(is_eu_region) if from_name is not None: - api_params['fromName'] = from_name + api_params['fromName'] = self._normalize_value(from_name) if from_email is not None: - api_params['fromEmail'] = from_email + api_params['fromEmail'] = self._normalize_value(from_email) if reply_to_name is not None: - api_params['replyToName'] = reply_to_name + api_params['replyToName'] = self._normalize_value(reply_to_name) if reply_to_email is not None: - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + api_params['replyToEmail'] = self._normalize_value(reply_to_email) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_mailgun_provider(self, provider_id: str, name: Optional[str] = None, api_key: Optional[str] = None, domain: Optional[str] = None, is_eu_region: Optional[bool] = None, enabled: Optional[bool] = None, from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_mailgun_provider( + self, + provider_id: str, + name: Optional[str] = None, + api_key: Optional[str] = None, + domain: Optional[str] = None, + is_eu_region: Optional[bool] = None, + enabled: Optional[bool] = None, + from_name: Optional[str] = None, + from_email: Optional[str] = None, + reply_to_name: Optional[str] = None, + reply_to_email: Optional[str] = None ) -> Provider: """ Update a Mailgun provider by its unique ID. @@ -970,8 +1183,8 @@ def update_mailgun_provider(self, provider_id: str, name: Optional[str] = None, Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -984,30 +1197,40 @@ def update_mailgun_provider(self, provider_id: str, name: Optional[str] = None, if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if domain is not None: - api_params['domain'] = domain - api_params['isEuRegion'] = is_eu_region - api_params['enabled'] = enabled + api_params['domain'] = self._normalize_value(domain) + api_params['isEuRegion'] = self._normalize_value(is_eu_region) + api_params['enabled'] = self._normalize_value(enabled) if from_name is not None: - api_params['fromName'] = from_name + api_params['fromName'] = self._normalize_value(from_name) if from_email is not None: - api_params['fromEmail'] = from_email + api_params['fromEmail'] = self._normalize_value(from_email) if reply_to_name is not None: - api_params['replyToName'] = reply_to_name + api_params['replyToName'] = self._normalize_value(reply_to_name) if reply_to_email is not None: - api_params['replyToEmail'] = reply_to_email + api_params['replyToEmail'] = self._normalize_value(reply_to_email) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_msg91_provider(self, provider_id: str, name: str, template_id: Optional[str] = None, sender_id: Optional[str] = None, auth_key: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_msg91_provider( + self, + provider_id: str, + name: str, + template_id: Optional[str] = None, + sender_id: Optional[str] = None, + auth_key: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new MSG91 provider. @@ -1028,8 +1251,8 @@ def create_msg91_provider(self, provider_id: str, name: str, template_id: Option Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1046,21 +1269,31 @@ def create_msg91_provider(self, provider_id: str, name: str, template_id: Option raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) if template_id is not None: - api_params['templateId'] = template_id + api_params['templateId'] = self._normalize_value(template_id) if sender_id is not None: - api_params['senderId'] = sender_id + api_params['senderId'] = self._normalize_value(sender_id) if auth_key is not None: - api_params['authKey'] = auth_key - api_params['enabled'] = enabled + api_params['authKey'] = self._normalize_value(auth_key) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_msg91_provider(self, provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, template_id: Optional[str] = None, sender_id: Optional[str] = None, auth_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_msg91_provider( + self, + provider_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None, + template_id: Optional[str] = None, + sender_id: Optional[str] = None, + auth_key: Optional[str] = None ) -> Provider: """ Update a MSG91 provider by its unique ID. @@ -1081,8 +1314,8 @@ def update_msg91_provider(self, provider_id: str, name: Optional[str] = None, en Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1095,23 +1328,35 @@ def update_msg91_provider(self, provider_id: str, name: Optional[str] = None, en if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name - api_params['enabled'] = enabled + api_params['name'] = self._normalize_value(name) + api_params['enabled'] = self._normalize_value(enabled) if template_id is not None: - api_params['templateId'] = template_id + api_params['templateId'] = self._normalize_value(template_id) if sender_id is not None: - api_params['senderId'] = sender_id + api_params['senderId'] = self._normalize_value(sender_id) if auth_key is not None: - api_params['authKey'] = auth_key + api_params['authKey'] = self._normalize_value(auth_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_resend_provider(self, provider_id: str, name: str, api_key: Optional[str] = None, from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_resend_provider( + self, + provider_id: str, + name: str, + api_key: Optional[str] = None, + from_name: Optional[str] = None, + from_email: Optional[str] = None, + reply_to_name: Optional[str] = None, + reply_to_email: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new Resend provider. @@ -1136,8 +1381,8 @@ def create_resend_provider(self, provider_id: str, name: str, api_key: Optional[ Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1154,25 +1399,37 @@ def create_resend_provider(self, provider_id: str, name: str, api_key: Optional[ raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if from_name is not None: - api_params['fromName'] = from_name + api_params['fromName'] = self._normalize_value(from_name) if from_email is not None: - api_params['fromEmail'] = from_email + api_params['fromEmail'] = self._normalize_value(from_email) if reply_to_name is not None: - api_params['replyToName'] = reply_to_name + api_params['replyToName'] = self._normalize_value(reply_to_name) if reply_to_email is not None: - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + api_params['replyToEmail'] = self._normalize_value(reply_to_email) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_resend_provider(self, provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, api_key: Optional[str] = None, from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_resend_provider( + self, + provider_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None, + api_key: Optional[str] = None, + from_name: Optional[str] = None, + from_email: Optional[str] = None, + reply_to_name: Optional[str] = None, + reply_to_email: Optional[str] = None ) -> Provider: """ Update a Resend provider by its unique ID. @@ -1197,8 +1454,8 @@ def update_resend_provider(self, provider_id: str, name: Optional[str] = None, e Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1211,27 +1468,39 @@ def update_resend_provider(self, provider_id: str, name: Optional[str] = None, e if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name - api_params['enabled'] = enabled + api_params['name'] = self._normalize_value(name) + api_params['enabled'] = self._normalize_value(enabled) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if from_name is not None: - api_params['fromName'] = from_name + api_params['fromName'] = self._normalize_value(from_name) if from_email is not None: - api_params['fromEmail'] = from_email + api_params['fromEmail'] = self._normalize_value(from_email) if reply_to_name is not None: - api_params['replyToName'] = reply_to_name + api_params['replyToName'] = self._normalize_value(reply_to_name) if reply_to_email is not None: - api_params['replyToEmail'] = reply_to_email + api_params['replyToEmail'] = self._normalize_value(reply_to_email) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_sendgrid_provider(self, provider_id: str, name: str, api_key: Optional[str] = None, from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_sendgrid_provider( + self, + provider_id: str, + name: str, + api_key: Optional[str] = None, + from_name: Optional[str] = None, + from_email: Optional[str] = None, + reply_to_name: Optional[str] = None, + reply_to_email: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new Sendgrid provider. @@ -1256,8 +1525,8 @@ def create_sendgrid_provider(self, provider_id: str, name: str, api_key: Optiona Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1274,25 +1543,37 @@ def create_sendgrid_provider(self, provider_id: str, name: str, api_key: Optiona raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if from_name is not None: - api_params['fromName'] = from_name + api_params['fromName'] = self._normalize_value(from_name) if from_email is not None: - api_params['fromEmail'] = from_email + api_params['fromEmail'] = self._normalize_value(from_email) if reply_to_name is not None: - api_params['replyToName'] = reply_to_name + api_params['replyToName'] = self._normalize_value(reply_to_name) if reply_to_email is not None: - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + api_params['replyToEmail'] = self._normalize_value(reply_to_email) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_sendgrid_provider(self, provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, api_key: Optional[str] = None, from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_sendgrid_provider( + self, + provider_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None, + api_key: Optional[str] = None, + from_name: Optional[str] = None, + from_email: Optional[str] = None, + reply_to_name: Optional[str] = None, + reply_to_email: Optional[str] = None ) -> Provider: """ Update a Sendgrid provider by its unique ID. @@ -1317,8 +1598,8 @@ def update_sendgrid_provider(self, provider_id: str, name: Optional[str] = None, Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1331,27 +1612,45 @@ def update_sendgrid_provider(self, provider_id: str, name: Optional[str] = None, if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name - api_params['enabled'] = enabled + api_params['name'] = self._normalize_value(name) + api_params['enabled'] = self._normalize_value(enabled) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if from_name is not None: - api_params['fromName'] = from_name + api_params['fromName'] = self._normalize_value(from_name) if from_email is not None: - api_params['fromEmail'] = from_email + api_params['fromEmail'] = self._normalize_value(from_email) if reply_to_name is not None: - api_params['replyToName'] = reply_to_name + api_params['replyToName'] = self._normalize_value(reply_to_name) if reply_to_email is not None: - api_params['replyToEmail'] = reply_to_email + api_params['replyToEmail'] = self._normalize_value(reply_to_email) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_smtp_provider(self, provider_id: str, name: str, host: str, port: Optional[float] = None, username: Optional[str] = None, password: Optional[str] = None, encryption: Optional[SmtpEncryption] = None, auto_tls: Optional[bool] = None, mailer: Optional[str] = None, from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_smtp_provider( + self, + provider_id: str, + name: str, + host: str, + port: Optional[float] = None, + username: Optional[str] = None, + password: Optional[str] = None, + encryption: Optional[SmtpEncryption] = None, + auto_tls: Optional[bool] = None, + mailer: Optional[str] = None, + from_name: Optional[str] = None, + from_email: Optional[str] = None, + reply_to_name: Optional[str] = None, + reply_to_email: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new SMTP provider. @@ -1388,8 +1687,8 @@ def create_smtp_provider(self, provider_id: str, name: str, host: str, port: Opt Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1409,36 +1708,54 @@ def create_smtp_provider(self, provider_id: str, name: str, host: str, port: Opt raise AppwriteException('Missing required parameter: "host"') - api_params['providerId'] = provider_id - api_params['name'] = name - api_params['host'] = host + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) + api_params['host'] = self._normalize_value(host) if port is not None: - api_params['port'] = port + api_params['port'] = self._normalize_value(port) if username is not None: - api_params['username'] = username + api_params['username'] = self._normalize_value(username) if password is not None: - api_params['password'] = password + api_params['password'] = self._normalize_value(password) if encryption is not None: - api_params['encryption'] = encryption + api_params['encryption'] = self._normalize_value(encryption) if auto_tls is not None: - api_params['autoTLS'] = auto_tls + api_params['autoTLS'] = self._normalize_value(auto_tls) if mailer is not None: - api_params['mailer'] = mailer + api_params['mailer'] = self._normalize_value(mailer) if from_name is not None: - api_params['fromName'] = from_name + api_params['fromName'] = self._normalize_value(from_name) if from_email is not None: - api_params['fromEmail'] = from_email + api_params['fromEmail'] = self._normalize_value(from_email) if reply_to_name is not None: - api_params['replyToName'] = reply_to_name + api_params['replyToName'] = self._normalize_value(reply_to_name) if reply_to_email is not None: - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + api_params['replyToEmail'] = self._normalize_value(reply_to_email) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_smtp_provider(self, provider_id: str, name: Optional[str] = None, host: Optional[str] = None, port: Optional[float] = None, username: Optional[str] = None, password: Optional[str] = None, encryption: Optional[SmtpEncryption] = None, auto_tls: Optional[bool] = None, mailer: Optional[str] = None, from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_smtp_provider( + self, + provider_id: str, + name: Optional[str] = None, + host: Optional[str] = None, + port: Optional[float] = None, + username: Optional[str] = None, + password: Optional[str] = None, + encryption: Optional[SmtpEncryption] = None, + auto_tls: Optional[bool] = None, + mailer: Optional[str] = None, + from_name: Optional[str] = None, + from_email: Optional[str] = None, + reply_to_name: Optional[str] = None, + reply_to_email: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Update a SMTP provider by its unique ID. @@ -1475,8 +1792,8 @@ def update_smtp_provider(self, provider_id: str, name: Optional[str] = None, hos Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1489,37 +1806,47 @@ def update_smtp_provider(self, provider_id: str, name: Optional[str] = None, hos if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) if host is not None: - api_params['host'] = host - api_params['port'] = port + api_params['host'] = self._normalize_value(host) + api_params['port'] = self._normalize_value(port) if username is not None: - api_params['username'] = username + api_params['username'] = self._normalize_value(username) if password is not None: - api_params['password'] = password + api_params['password'] = self._normalize_value(password) if encryption is not None: - api_params['encryption'] = encryption - api_params['autoTLS'] = auto_tls + api_params['encryption'] = self._normalize_value(encryption) + api_params['autoTLS'] = self._normalize_value(auto_tls) if mailer is not None: - api_params['mailer'] = mailer + api_params['mailer'] = self._normalize_value(mailer) if from_name is not None: - api_params['fromName'] = from_name + api_params['fromName'] = self._normalize_value(from_name) if from_email is not None: - api_params['fromEmail'] = from_email + api_params['fromEmail'] = self._normalize_value(from_email) if reply_to_name is not None: - api_params['replyToName'] = reply_to_name + api_params['replyToName'] = self._normalize_value(reply_to_name) if reply_to_email is not None: - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + api_params['replyToEmail'] = self._normalize_value(reply_to_email) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_telesign_provider(self, provider_id: str, name: str, xfrom: Optional[str] = None, customer_id: Optional[str] = None, api_key: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_telesign_provider( + self, + provider_id: str, + name: str, + xfrom: Optional[str] = None, + customer_id: Optional[str] = None, + api_key: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new Telesign provider. @@ -1540,8 +1867,8 @@ def create_telesign_provider(self, provider_id: str, name: str, xfrom: Optional[ Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1558,21 +1885,31 @@ def create_telesign_provider(self, provider_id: str, name: str, xfrom: Optional[ raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) if xfrom is not None: - api_params['from'] = xfrom + api_params['from'] = self._normalize_value(xfrom) if customer_id is not None: - api_params['customerId'] = customer_id + api_params['customerId'] = self._normalize_value(customer_id) if api_key is not None: - api_params['apiKey'] = api_key - api_params['enabled'] = enabled + api_params['apiKey'] = self._normalize_value(api_key) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_telesign_provider(self, provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, customer_id: Optional[str] = None, api_key: Optional[str] = None, xfrom: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_telesign_provider( + self, + provider_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None, + customer_id: Optional[str] = None, + api_key: Optional[str] = None, + xfrom: Optional[str] = None ) -> Provider: """ Update a Telesign provider by its unique ID. @@ -1593,8 +1930,8 @@ def update_telesign_provider(self, provider_id: str, name: Optional[str] = None, Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1607,23 +1944,33 @@ def update_telesign_provider(self, provider_id: str, name: Optional[str] = None, if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name - api_params['enabled'] = enabled + api_params['name'] = self._normalize_value(name) + api_params['enabled'] = self._normalize_value(enabled) if customer_id is not None: - api_params['customerId'] = customer_id + api_params['customerId'] = self._normalize_value(customer_id) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if xfrom is not None: - api_params['from'] = xfrom + api_params['from'] = self._normalize_value(xfrom) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_textmagic_provider(self, provider_id: str, name: str, xfrom: Optional[str] = None, username: Optional[str] = None, api_key: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_textmagic_provider( + self, + provider_id: str, + name: str, + xfrom: Optional[str] = None, + username: Optional[str] = None, + api_key: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new Textmagic provider. @@ -1644,8 +1991,8 @@ def create_textmagic_provider(self, provider_id: str, name: str, xfrom: Optional Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1662,21 +2009,31 @@ def create_textmagic_provider(self, provider_id: str, name: str, xfrom: Optional raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) if xfrom is not None: - api_params['from'] = xfrom + api_params['from'] = self._normalize_value(xfrom) if username is not None: - api_params['username'] = username + api_params['username'] = self._normalize_value(username) if api_key is not None: - api_params['apiKey'] = api_key - api_params['enabled'] = enabled + api_params['apiKey'] = self._normalize_value(api_key) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_textmagic_provider(self, provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, username: Optional[str] = None, api_key: Optional[str] = None, xfrom: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_textmagic_provider( + self, + provider_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None, + username: Optional[str] = None, + api_key: Optional[str] = None, + xfrom: Optional[str] = None ) -> Provider: """ Update a Textmagic provider by its unique ID. @@ -1697,8 +2054,8 @@ def update_textmagic_provider(self, provider_id: str, name: Optional[str] = None Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1711,23 +2068,33 @@ def update_textmagic_provider(self, provider_id: str, name: Optional[str] = None if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name - api_params['enabled'] = enabled + api_params['name'] = self._normalize_value(name) + api_params['enabled'] = self._normalize_value(enabled) if username is not None: - api_params['username'] = username + api_params['username'] = self._normalize_value(username) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if xfrom is not None: - api_params['from'] = xfrom + api_params['from'] = self._normalize_value(xfrom) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_twilio_provider(self, provider_id: str, name: str, xfrom: Optional[str] = None, account_sid: Optional[str] = None, auth_token: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_twilio_provider( + self, + provider_id: str, + name: str, + xfrom: Optional[str] = None, + account_sid: Optional[str] = None, + auth_token: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new Twilio provider. @@ -1748,8 +2115,8 @@ def create_twilio_provider(self, provider_id: str, name: str, xfrom: Optional[st Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1766,21 +2133,31 @@ def create_twilio_provider(self, provider_id: str, name: str, xfrom: Optional[st raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) if xfrom is not None: - api_params['from'] = xfrom + api_params['from'] = self._normalize_value(xfrom) if account_sid is not None: - api_params['accountSid'] = account_sid + api_params['accountSid'] = self._normalize_value(account_sid) if auth_token is not None: - api_params['authToken'] = auth_token - api_params['enabled'] = enabled + api_params['authToken'] = self._normalize_value(auth_token) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_twilio_provider(self, provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, account_sid: Optional[str] = None, auth_token: Optional[str] = None, xfrom: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_twilio_provider( + self, + provider_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None, + account_sid: Optional[str] = None, + auth_token: Optional[str] = None, + xfrom: Optional[str] = None ) -> Provider: """ Update a Twilio provider by its unique ID. @@ -1801,8 +2178,8 @@ def update_twilio_provider(self, provider_id: str, name: Optional[str] = None, e Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1815,23 +2192,33 @@ def update_twilio_provider(self, provider_id: str, name: Optional[str] = None, e if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name - api_params['enabled'] = enabled + api_params['name'] = self._normalize_value(name) + api_params['enabled'] = self._normalize_value(enabled) if account_sid is not None: - api_params['accountSid'] = account_sid + api_params['accountSid'] = self._normalize_value(account_sid) if auth_token is not None: - api_params['authToken'] = auth_token + api_params['authToken'] = self._normalize_value(auth_token) if xfrom is not None: - api_params['from'] = xfrom + api_params['from'] = self._normalize_value(xfrom) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_vonage_provider(self, provider_id: str, name: str, xfrom: Optional[str] = None, api_key: Optional[str] = None, api_secret: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def create_vonage_provider( + self, + provider_id: str, + name: str, + xfrom: Optional[str] = None, + api_key: Optional[str] = None, + api_secret: Optional[str] = None, + enabled: Optional[bool] = None ) -> Provider: """ Create a new Vonage provider. @@ -1852,8 +2239,8 @@ def create_vonage_provider(self, provider_id: str, name: str, xfrom: Optional[st Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1870,21 +2257,31 @@ def create_vonage_provider(self, provider_id: str, name: str, xfrom: Optional[st raise AppwriteException('Missing required parameter: "name"') - api_params['providerId'] = provider_id - api_params['name'] = name + api_params['providerId'] = self._normalize_value(provider_id) + api_params['name'] = self._normalize_value(name) if xfrom is not None: - api_params['from'] = xfrom + api_params['from'] = self._normalize_value(xfrom) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if api_secret is not None: - api_params['apiSecret'] = api_secret - api_params['enabled'] = enabled + api_params['apiSecret'] = self._normalize_value(api_secret) + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_vonage_provider(self, provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, api_key: Optional[str] = None, api_secret: Optional[str] = None, xfrom: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def update_vonage_provider( + self, + provider_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None, + api_key: Optional[str] = None, + api_secret: Optional[str] = None, + xfrom: Optional[str] = None ) -> Provider: """ Update a Vonage provider by its unique ID. @@ -1905,8 +2302,8 @@ def update_vonage_provider(self, provider_id: str, name: Optional[str] = None, e Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1919,23 +2316,28 @@ def update_vonage_provider(self, provider_id: str, name: Optional[str] = None, e if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if name is not None: - api_params['name'] = name - api_params['enabled'] = enabled + api_params['name'] = self._normalize_value(name) + api_params['enabled'] = self._normalize_value(enabled) if api_key is not None: - api_params['apiKey'] = api_key + api_params['apiKey'] = self._normalize_value(api_key) if api_secret is not None: - api_params['apiSecret'] = api_secret + api_params['apiSecret'] = self._normalize_value(api_secret) if xfrom is not None: - api_params['from'] = xfrom + api_params['from'] = self._normalize_value(xfrom) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def get_provider(self, provider_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def get_provider( + self, + provider_id: str ) -> Provider: """ Get a provider by its unique ID. @@ -1947,8 +2349,8 @@ def get_provider(self, provider_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Provider + API response as a typed Pydantic model Raises ------ @@ -1961,13 +2363,18 @@ def get_provider(self, provider_id: str) -> Dict[str, Any]: if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_provider(self, provider_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Provider) + + + def delete_provider( + self, + provider_id: str ) -> Dict[str, Any]: """ Delete a provider by its unique ID. @@ -1992,14 +2399,21 @@ def delete_provider(self, provider_id: str) -> Dict[str, Any]: if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_provider_logs(self, provider_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return response + + + def list_provider_logs( + self, + provider_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> LogList: """ Get the provider activity logs listed by its unique ID. @@ -2014,8 +2428,8 @@ def list_provider_logs(self, provider_id: str, queries: Optional[List[str]] = No Returns ------- - Dict[str, Any] - API response as a dictionary + LogList + API response as a typed Pydantic model Raises ------ @@ -2028,17 +2442,24 @@ def list_provider_logs(self, provider_id: str, queries: Optional[List[str]] = No if provider_id is None: raise AppwriteException('Missing required parameter: "provider_id"') - api_path = api_path.replace('{providerId}', provider_id) + api_path = api_path.replace('{providerId}', str(self._normalize_value(provider_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_subscriber_logs(self, subscriber_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=LogList) + + + def list_subscriber_logs( + self, + subscriber_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> LogList: """ Get the subscriber activity logs listed by its unique ID. @@ -2053,8 +2474,8 @@ def list_subscriber_logs(self, subscriber_id: str, queries: Optional[List[str]] Returns ------- - Dict[str, Any] - API response as a dictionary + LogList + API response as a typed Pydantic model Raises ------ @@ -2067,17 +2488,24 @@ def list_subscriber_logs(self, subscriber_id: str, queries: Optional[List[str]] if subscriber_id is None: raise AppwriteException('Missing required parameter: "subscriber_id"') - api_path = api_path.replace('{subscriberId}', subscriber_id) + api_path = api_path.replace('{subscriberId}', str(self._normalize_value(subscriber_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_topics(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=LogList) + + + def list_topics( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> TopicList: """ Get a list of all topics from the current Appwrite project. @@ -2092,8 +2520,8 @@ def list_topics(self, queries: Optional[List[str]] = None, search: Optional[str] Returns ------- - Dict[str, Any] - API response as a dictionary + TopicList + API response as a typed Pydantic model Raises ------ @@ -2105,16 +2533,23 @@ def list_topics(self, queries: Optional[List[str]] = None, search: Optional[str] api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_topic(self, topic_id: str, name: str, subscribe: Optional[List[str]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=TopicList) + + + def create_topic( + self, + topic_id: str, + name: str, + subscribe: Optional[List[str]] = None ) -> Topic: """ Create a new topic. @@ -2129,8 +2564,8 @@ def create_topic(self, topic_id: str, name: str, subscribe: Optional[List[str]] Returns ------- - Dict[str, Any] - API response as a dictionary + Topic + API response as a typed Pydantic model Raises ------ @@ -2147,16 +2582,21 @@ def create_topic(self, topic_id: str, name: str, subscribe: Optional[List[str]] raise AppwriteException('Missing required parameter: "name"') - api_params['topicId'] = topic_id - api_params['name'] = name + api_params['topicId'] = self._normalize_value(topic_id) + api_params['name'] = self._normalize_value(name) if subscribe is not None: - api_params['subscribe'] = subscribe + api_params['subscribe'] = self._normalize_value(subscribe) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_topic(self, topic_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Topic) + + + def get_topic( + self, + topic_id: str ) -> Topic: """ Get a topic by its unique ID. @@ -2168,8 +2608,8 @@ def get_topic(self, topic_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Topic + API response as a typed Pydantic model Raises ------ @@ -2182,13 +2622,20 @@ def get_topic(self, topic_id: str) -> Dict[str, Any]: if topic_id is None: raise AppwriteException('Missing required parameter: "topic_id"') - api_path = api_path.replace('{topicId}', topic_id) + api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_topic(self, topic_id: str, name: Optional[str] = None, subscribe: Optional[List[str]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Topic) + + + def update_topic( + self, + topic_id: str, + name: Optional[str] = None, + subscribe: Optional[List[str]] = None ) -> Topic: """ Update a topic by its unique ID. @@ -2204,8 +2651,8 @@ def update_topic(self, topic_id: str, name: Optional[str] = None, subscribe: Opt Returns ------- - Dict[str, Any] - API response as a dictionary + Topic + API response as a typed Pydantic model Raises ------ @@ -2218,16 +2665,21 @@ def update_topic(self, topic_id: str, name: Optional[str] = None, subscribe: Opt if topic_id is None: raise AppwriteException('Missing required parameter: "topic_id"') - api_path = api_path.replace('{topicId}', topic_id) + api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) - api_params['name'] = name - api_params['subscribe'] = subscribe + api_params['name'] = self._normalize_value(name) + api_params['subscribe'] = self._normalize_value(subscribe) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_topic(self, topic_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Topic) + + + def delete_topic( + self, + topic_id: str ) -> Dict[str, Any]: """ Delete a topic by its unique ID. @@ -2252,14 +2704,21 @@ def delete_topic(self, topic_id: str) -> Dict[str, Any]: if topic_id is None: raise AppwriteException('Missing required parameter: "topic_id"') - api_path = api_path.replace('{topicId}', topic_id) + api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_topic_logs(self, topic_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return response + + + def list_topic_logs( + self, + topic_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> LogList: """ Get the topic activity logs listed by its unique ID. @@ -2274,8 +2733,8 @@ def list_topic_logs(self, topic_id: str, queries: Optional[List[str]] = None, to Returns ------- - Dict[str, Any] - API response as a dictionary + LogList + API response as a typed Pydantic model Raises ------ @@ -2288,17 +2747,25 @@ def list_topic_logs(self, topic_id: str, queries: Optional[List[str]] = None, to if topic_id is None: raise AppwriteException('Missing required parameter: "topic_id"') - api_path = api_path.replace('{topicId}', topic_id) + api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_subscribers(self, topic_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=LogList) + + + def list_subscribers( + self, + topic_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> SubscriberList: """ Get a list of all subscribers from the current Appwrite project. @@ -2315,8 +2782,8 @@ def list_subscribers(self, topic_id: str, queries: Optional[List[str]] = None, s Returns ------- - Dict[str, Any] - API response as a dictionary + SubscriberList + API response as a typed Pydantic model Raises ------ @@ -2329,19 +2796,26 @@ def list_subscribers(self, topic_id: str, queries: Optional[List[str]] = None, s if topic_id is None: raise AppwriteException('Missing required parameter: "topic_id"') - api_path = api_path.replace('{topicId}', topic_id) + api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_subscriber(self, topic_id: str, subscriber_id: str, target_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=SubscriberList) + + + def create_subscriber( + self, + topic_id: str, + subscriber_id: str, + target_id: str ) -> Subscriber: """ Create a new subscriber. @@ -2356,8 +2830,8 @@ def create_subscriber(self, topic_id: str, subscriber_id: str, target_id: str) - Returns ------- - Dict[str, Any] - API response as a dictionary + Subscriber + API response as a typed Pydantic model Raises ------ @@ -2376,16 +2850,22 @@ def create_subscriber(self, topic_id: str, subscriber_id: str, target_id: str) - if target_id is None: raise AppwriteException('Missing required parameter: "target_id"') - api_path = api_path.replace('{topicId}', topic_id) + api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) - api_params['subscriberId'] = subscriber_id - api_params['targetId'] = target_id + api_params['subscriberId'] = self._normalize_value(subscriber_id) + api_params['targetId'] = self._normalize_value(target_id) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_subscriber(self, topic_id: str, subscriber_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Subscriber) + + + def get_subscriber( + self, + topic_id: str, + subscriber_id: str ) -> Subscriber: """ Get a subscriber by its unique ID. @@ -2399,8 +2879,8 @@ def get_subscriber(self, topic_id: str, subscriber_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Subscriber + API response as a typed Pydantic model Raises ------ @@ -2416,14 +2896,20 @@ def get_subscriber(self, topic_id: str, subscriber_id: str) -> Dict[str, Any]: if subscriber_id is None: raise AppwriteException('Missing required parameter: "subscriber_id"') - api_path = api_path.replace('{topicId}', topic_id) - api_path = api_path.replace('{subscriberId}', subscriber_id) + api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) + api_path = api_path.replace('{subscriberId}', str(self._normalize_value(subscriber_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_subscriber(self, topic_id: str, subscriber_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Subscriber) + + + def delete_subscriber( + self, + topic_id: str, + subscriber_id: str ) -> Dict[str, Any]: """ Delete a subscriber by its unique ID. @@ -2453,10 +2939,13 @@ def delete_subscriber(self, topic_id: str, subscriber_id: str) -> Dict[str, Any] if subscriber_id is None: raise AppwriteException('Missing required parameter: "subscriber_id"') - api_path = api_path.replace('{topicId}', topic_id) - api_path = api_path.replace('{subscriberId}', subscriber_id) + api_path = api_path.replace('{topicId}', str(self._normalize_value(topic_id))) + api_path = api_path.replace('{subscriberId}', str(self._normalize_value(subscriber_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + + return response + diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index 8567479..efe4503 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -1,21 +1,35 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.site_list import SiteList; from ..enums.framework import Framework; from ..enums.build_runtime import BuildRuntime; from ..enums.adapter import Adapter; +from ..models.site import Site; +from ..models.framework_list import FrameworkList; +from ..models.specification_list import SpecificationList; +from ..models.deployment_list import DeploymentList; from ..input_file import InputFile +from ..models.deployment import Deployment; from ..enums.template_reference_type import TemplateReferenceType; from ..enums.vcs_reference_type import VCSReferenceType; from ..enums.deployment_download_type import DeploymentDownloadType; +from ..models.execution_list import ExecutionList; +from ..models.execution import Execution; +from ..models.variable_list import VariableList; +from ..models.variable import Variable; class Sites(Service): def __init__(self, client) -> None: super(Sites, self).__init__(client) - def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> SiteList: """ Get a list of all the project's sites. You can use the query params to filter your results. @@ -30,8 +44,8 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None Returns ------- - Dict[str, Any] - API response as a dictionary + SiteList + API response as a typed Pydantic model Raises ------ @@ -43,16 +57,38 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create(self, site_id: str, name: str, framework: Framework, build_runtime: BuildRuntime, enabled: Optional[bool] = None, logging: Optional[bool] = None, timeout: Optional[float] = None, install_command: Optional[str] = None, build_command: Optional[str] = None, output_directory: Optional[str] = None, adapter: Optional[Adapter] = None, installation_id: Optional[str] = None, fallback_file: Optional[str] = None, provider_repository_id: Optional[str] = None, provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, specification: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=SiteList) + + + def create( + self, + site_id: str, + name: str, + framework: Framework, + build_runtime: BuildRuntime, + enabled: Optional[bool] = None, + logging: Optional[bool] = None, + timeout: Optional[float] = None, + install_command: Optional[str] = None, + build_command: Optional[str] = None, + output_directory: Optional[str] = None, + adapter: Optional[Adapter] = None, + installation_id: Optional[str] = None, + fallback_file: Optional[str] = None, + provider_repository_id: Optional[str] = None, + provider_branch: Optional[str] = None, + provider_silent_mode: Optional[bool] = None, + provider_root_directory: Optional[str] = None, + specification: Optional[str] = None ) -> Site: """ Create a new site. @@ -97,8 +133,8 @@ def create(self, site_id: str, name: str, framework: Framework, build_runtime: B Returns ------- - Dict[str, Any] - API response as a dictionary + Site + API response as a typed Pydantic model Raises ------ @@ -121,51 +157,55 @@ def create(self, site_id: str, name: str, framework: Framework, build_runtime: B raise AppwriteException('Missing required parameter: "build_runtime"') - api_params['siteId'] = site_id - api_params['name'] = name - api_params['framework'] = framework + api_params['siteId'] = self._normalize_value(site_id) + api_params['name'] = self._normalize_value(name) + api_params['framework'] = self._normalize_value(framework) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) if logging is not None: - api_params['logging'] = logging + api_params['logging'] = self._normalize_value(logging) if timeout is not None: - api_params['timeout'] = timeout + api_params['timeout'] = self._normalize_value(timeout) if install_command is not None: - api_params['installCommand'] = install_command + api_params['installCommand'] = self._normalize_value(install_command) if build_command is not None: - api_params['buildCommand'] = build_command + api_params['buildCommand'] = self._normalize_value(build_command) if output_directory is not None: - api_params['outputDirectory'] = output_directory - api_params['buildRuntime'] = build_runtime + api_params['outputDirectory'] = self._normalize_value(output_directory) + api_params['buildRuntime'] = self._normalize_value(build_runtime) if adapter is not None: - api_params['adapter'] = adapter + api_params['adapter'] = self._normalize_value(adapter) if installation_id is not None: - api_params['installationId'] = installation_id + api_params['installationId'] = self._normalize_value(installation_id) if fallback_file is not None: - api_params['fallbackFile'] = fallback_file + api_params['fallbackFile'] = self._normalize_value(fallback_file) if provider_repository_id is not None: - api_params['providerRepositoryId'] = provider_repository_id + api_params['providerRepositoryId'] = self._normalize_value(provider_repository_id) if provider_branch is not None: - api_params['providerBranch'] = provider_branch + api_params['providerBranch'] = self._normalize_value(provider_branch) if provider_silent_mode is not None: - api_params['providerSilentMode'] = provider_silent_mode + api_params['providerSilentMode'] = self._normalize_value(provider_silent_mode) if provider_root_directory is not None: - api_params['providerRootDirectory'] = provider_root_directory + api_params['providerRootDirectory'] = self._normalize_value(provider_root_directory) if specification is not None: - api_params['specification'] = specification + api_params['specification'] = self._normalize_value(specification) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def list_frameworks(self) -> Dict[str, Any]: + return self._parse_response(response, model=Site) + + + def list_frameworks( + self ) -> FrameworkList: """ Get a list of all frameworks that are currently available on the server instance. Returns ------- - Dict[str, Any] - API response as a dictionary + FrameworkList + API response as a typed Pydantic model Raises ------ @@ -176,17 +216,21 @@ def list_frameworks(self) -> Dict[str, Any]: api_path = '/sites/frameworks' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_specifications(self) -> Dict[str, Any]: + return self._parse_response(response, model=FrameworkList) + + + def list_specifications( + self ) -> SpecificationList: """ List allowed site specifications for this instance. Returns ------- - Dict[str, Any] - API response as a dictionary + SpecificationList + API response as a typed Pydantic model Raises ------ @@ -197,10 +241,15 @@ def list_specifications(self) -> Dict[str, Any]: api_path = '/sites/specifications' api_params = {} - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get(self, site_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=SpecificationList) + + + def get( + self, + site_id: str ) -> Site: """ Get a site by its unique ID. @@ -211,8 +260,8 @@ def get(self, site_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Site + API response as a typed Pydantic model Raises ------ @@ -225,13 +274,35 @@ def get(self, site_id: str) -> Dict[str, Any]: if site_id is None: raise AppwriteException('Missing required parameter: "site_id"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update(self, site_id: str, name: str, framework: Framework, enabled: Optional[bool] = None, logging: Optional[bool] = None, timeout: Optional[float] = None, install_command: Optional[str] = None, build_command: Optional[str] = None, output_directory: Optional[str] = None, build_runtime: Optional[BuildRuntime] = None, adapter: Optional[Adapter] = None, fallback_file: Optional[str] = None, installation_id: Optional[str] = None, provider_repository_id: Optional[str] = None, provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, specification: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Site) + + + def update( + self, + site_id: str, + name: str, + framework: Framework, + enabled: Optional[bool] = None, + logging: Optional[bool] = None, + timeout: Optional[float] = None, + install_command: Optional[str] = None, + build_command: Optional[str] = None, + output_directory: Optional[str] = None, + build_runtime: Optional[BuildRuntime] = None, + adapter: Optional[Adapter] = None, + fallback_file: Optional[str] = None, + installation_id: Optional[str] = None, + provider_repository_id: Optional[str] = None, + provider_branch: Optional[str] = None, + provider_silent_mode: Optional[bool] = None, + provider_root_directory: Optional[str] = None, + specification: Optional[str] = None ) -> Site: """ Update site by its unique ID. @@ -276,8 +347,8 @@ def update(self, site_id: str, name: str, framework: Framework, enabled: Optiona Returns ------- - Dict[str, Any] - API response as a dictionary + Site + API response as a typed Pydantic model Raises ------ @@ -296,46 +367,51 @@ def update(self, site_id: str, name: str, framework: Framework, enabled: Optiona if framework is None: raise AppwriteException('Missing required parameter: "framework"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - api_params['name'] = name - api_params['framework'] = framework + api_params['name'] = self._normalize_value(name) + api_params['framework'] = self._normalize_value(framework) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) if logging is not None: - api_params['logging'] = logging + api_params['logging'] = self._normalize_value(logging) if timeout is not None: - api_params['timeout'] = timeout + api_params['timeout'] = self._normalize_value(timeout) if install_command is not None: - api_params['installCommand'] = install_command + api_params['installCommand'] = self._normalize_value(install_command) if build_command is not None: - api_params['buildCommand'] = build_command + api_params['buildCommand'] = self._normalize_value(build_command) if output_directory is not None: - api_params['outputDirectory'] = output_directory + api_params['outputDirectory'] = self._normalize_value(output_directory) if build_runtime is not None: - api_params['buildRuntime'] = build_runtime + api_params['buildRuntime'] = self._normalize_value(build_runtime) if adapter is not None: - api_params['adapter'] = adapter + api_params['adapter'] = self._normalize_value(adapter) if fallback_file is not None: - api_params['fallbackFile'] = fallback_file + api_params['fallbackFile'] = self._normalize_value(fallback_file) if installation_id is not None: - api_params['installationId'] = installation_id + api_params['installationId'] = self._normalize_value(installation_id) if provider_repository_id is not None: - api_params['providerRepositoryId'] = provider_repository_id + api_params['providerRepositoryId'] = self._normalize_value(provider_repository_id) if provider_branch is not None: - api_params['providerBranch'] = provider_branch + api_params['providerBranch'] = self._normalize_value(provider_branch) if provider_silent_mode is not None: - api_params['providerSilentMode'] = provider_silent_mode + api_params['providerSilentMode'] = self._normalize_value(provider_silent_mode) if provider_root_directory is not None: - api_params['providerRootDirectory'] = provider_root_directory + api_params['providerRootDirectory'] = self._normalize_value(provider_root_directory) if specification is not None: - api_params['specification'] = specification + api_params['specification'] = self._normalize_value(specification) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete(self, site_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Site) + + + def delete( + self, + site_id: str ) -> Dict[str, Any]: """ Delete a site by its unique ID. @@ -360,14 +436,20 @@ def delete(self, site_id: str) -> Dict[str, Any]: if site_id is None: raise AppwriteException('Missing required parameter: "site_id"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def update_site_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + return response + + + def update_site_deployment( + self, + site_id: str, + deployment_id: str ) -> Site: """ Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. @@ -380,8 +462,8 @@ def update_site_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Returns ------- - Dict[str, Any] - API response as a dictionary + Site + API response as a typed Pydantic model Raises ------ @@ -397,15 +479,23 @@ def update_site_deployment(self, site_id: str, deployment_id: str) -> Dict[str, if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - api_params['deploymentId'] = deployment_id + api_params['deploymentId'] = self._normalize_value(deployment_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def list_deployments(self, site_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Site) + + + def list_deployments( + self, + site_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> DeploymentList: """ Get a list of all the site's code deployments. You can use the query params to filter your results. @@ -422,8 +512,8 @@ def list_deployments(self, site_id: str, queries: Optional[List[str]] = None, se Returns ------- - Dict[str, Any] - API response as a dictionary + DeploymentList + API response as a typed Pydantic model Raises ------ @@ -436,19 +526,30 @@ def list_deployments(self, site_id: str, queries: Optional[List[str]] = None, se if site_id is None: raise AppwriteException('Missing required parameter: "site_id"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_deployment(self, site_id: str, code: InputFile, install_command: Optional[str] = None, build_command: Optional[str] = None, output_directory: Optional[str] = None, activate: Optional[bool] = None, on_progress = None) -> Dict[str, Any]: + return self._parse_response(response, model=DeploymentList) + + + def create_deployment( + self, + site_id: str, + code: InputFile, + install_command: Optional[str] = None, + build_command: Optional[str] = None, + output_directory: Optional[str] = None, + activate: Optional[bool] = None, + on_progress = None ) -> Deployment: """ Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID. @@ -471,8 +572,8 @@ def create_deployment(self, site_id: str, code: InputFile, install_command: Opti Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -488,28 +589,34 @@ def create_deployment(self, site_id: str, code: InputFile, install_command: Opti if code is None: raise AppwriteException('Missing required parameter: "code"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) if install_command is not None: - api_params['installCommand'] = install_command + api_params['installCommand'] = self._normalize_value(install_command) if build_command is not None: - api_params['buildCommand'] = build_command + api_params['buildCommand'] = self._normalize_value(build_command) if output_directory is not None: - api_params['outputDirectory'] = output_directory - api_params['code'] = code + api_params['outputDirectory'] = self._normalize_value(output_directory) + api_params['code'] = self._normalize_value(code) if activate is not None: - api_params['activate'] = str(activate).lower() if type(activate) is bool else activate + api_params['activate'] = self._normalize_value(str(activate).lower() if type(activate) is bool else activate) param_name = 'code' upload_id = '' - return self.client.chunked_upload(api_path, { + response = self.client.chunked_upload(api_path, { 'content-type': 'multipart/form-data', }, api_params, param_name, on_progress, upload_id) - def create_duplicate_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def create_duplicate_deployment( + self, + site_id: str, + deployment_id: str ) -> Deployment: """ Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. @@ -522,8 +629,8 @@ def create_duplicate_deployment(self, site_id: str, deployment_id: str) -> Dict[ Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -539,15 +646,26 @@ def create_duplicate_deployment(self, site_id: str, deployment_id: str) -> Dict[ if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - api_params['deploymentId'] = deployment_id + api_params['deploymentId'] = self._normalize_value(deployment_id) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_template_deployment(self, site_id: str, repository: str, owner: str, root_directory: str, type: TemplateReferenceType, reference: str, activate: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def create_template_deployment( + self, + site_id: str, + repository: str, + owner: str, + root_directory: str, + type: TemplateReferenceType, + reference: str, + activate: Optional[bool] = None ) -> Deployment: """ Create a deployment based on a template. @@ -572,8 +690,8 @@ def create_template_deployment(self, site_id: str, repository: str, owner: str, Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -601,21 +719,29 @@ def create_template_deployment(self, site_id: str, repository: str, owner: str, if reference is None: raise AppwriteException('Missing required parameter: "reference"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - api_params['repository'] = repository - api_params['owner'] = owner - api_params['rootDirectory'] = root_directory - api_params['type'] = type - api_params['reference'] = reference + api_params['repository'] = self._normalize_value(repository) + api_params['owner'] = self._normalize_value(owner) + api_params['rootDirectory'] = self._normalize_value(root_directory) + api_params['type'] = self._normalize_value(type) + api_params['reference'] = self._normalize_value(reference) if activate is not None: - api_params['activate'] = activate + api_params['activate'] = self._normalize_value(activate) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_vcs_deployment(self, site_id: str, type: VCSReferenceType, reference: str, activate: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def create_vcs_deployment( + self, + site_id: str, + type: VCSReferenceType, + reference: str, + activate: Optional[bool] = None ) -> Deployment: """ Create a deployment when a site is connected to VCS. @@ -634,8 +760,8 @@ def create_vcs_deployment(self, site_id: str, type: VCSReferenceType, reference: Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -654,18 +780,24 @@ def create_vcs_deployment(self, site_id: str, type: VCSReferenceType, reference: if reference is None: raise AppwriteException('Missing required parameter: "reference"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - api_params['type'] = type - api_params['reference'] = reference + api_params['type'] = self._normalize_value(type) + api_params['reference'] = self._normalize_value(reference) if activate is not None: - api_params['activate'] = activate + api_params['activate'] = self._normalize_value(activate) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def get_deployment( + self, + site_id: str, + deployment_id: str ) -> Deployment: """ Get a site deployment by its unique ID. @@ -678,8 +810,8 @@ def get_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -695,14 +827,20 @@ def get_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{siteId}', site_id) - api_path = api_path.replace('{deploymentId}', deployment_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def delete_deployment( + self, + site_id: str, + deployment_id: str ) -> Dict[str, Any]: """ Delete a site deployment by its unique ID. @@ -732,15 +870,22 @@ def delete_deployment(self, site_id: str, deployment_id: str) -> Dict[str, Any]: if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{siteId}', site_id) - api_path = api_path.replace('{deploymentId}', deployment_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def get_deployment_download(self, site_id: str, deployment_id: str, type: Optional[DeploymentDownloadType] = None) -> bytes: + return response + + + def get_deployment_download( + self, + site_id: str, + deployment_id: str, + type: Optional[DeploymentDownloadType] = None ) -> bytes: """ Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. @@ -772,16 +917,22 @@ def get_deployment_download(self, site_id: str, deployment_id: str, type: Option if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{siteId}', site_id) - api_path = api_path.replace('{deploymentId}', deployment_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) if type is not None: - api_params['type'] = type + api_params['type'] = self._normalize_value(type) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_deployment_status(self, site_id: str, deployment_id: str) -> Dict[str, Any]: + return response + + + def update_deployment_status( + self, + site_id: str, + deployment_id: str ) -> Deployment: """ Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. @@ -794,8 +945,8 @@ def update_deployment_status(self, site_id: str, deployment_id: str) -> Dict[str Returns ------- - Dict[str, Any] - API response as a dictionary + Deployment + API response as a typed Pydantic model Raises ------ @@ -811,15 +962,22 @@ def update_deployment_status(self, site_id: str, deployment_id: str) -> Dict[str if deployment_id is None: raise AppwriteException('Missing required parameter: "deployment_id"') - api_path = api_path.replace('{siteId}', site_id) - api_path = api_path.replace('{deploymentId}', deployment_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_path = api_path.replace('{deploymentId}', str(self._normalize_value(deployment_id))) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def list_logs(self, site_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Deployment) + + + def list_logs( + self, + site_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> ExecutionList: """ Get a list of all site logs. You can use the query params to filter your results. @@ -834,8 +992,8 @@ def list_logs(self, site_id: str, queries: Optional[List[str]] = None, total: Op Returns ------- - Dict[str, Any] - API response as a dictionary + ExecutionList + API response as a typed Pydantic model Raises ------ @@ -848,17 +1006,23 @@ def list_logs(self, site_id: str, queries: Optional[List[str]] = None, total: Op if site_id is None: raise AppwriteException('Missing required parameter: "site_id"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_log(self, site_id: str, log_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=ExecutionList) + + + def get_log( + self, + site_id: str, + log_id: str ) -> Execution: """ Get a site request log by its unique ID. @@ -871,8 +1035,8 @@ def get_log(self, site_id: str, log_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Execution + API response as a typed Pydantic model Raises ------ @@ -888,14 +1052,20 @@ def get_log(self, site_id: str, log_id: str) -> Dict[str, Any]: if log_id is None: raise AppwriteException('Missing required parameter: "log_id"') - api_path = api_path.replace('{siteId}', site_id) - api_path = api_path.replace('{logId}', log_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_path = api_path.replace('{logId}', str(self._normalize_value(log_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_log(self, site_id: str, log_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Execution) + + + def delete_log( + self, + site_id: str, + log_id: str ) -> Dict[str, Any]: """ Delete a site log by its unique ID. @@ -925,15 +1095,20 @@ def delete_log(self, site_id: str, log_id: str) -> Dict[str, Any]: if log_id is None: raise AppwriteException('Missing required parameter: "log_id"') - api_path = api_path.replace('{siteId}', site_id) - api_path = api_path.replace('{logId}', log_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_path = api_path.replace('{logId}', str(self._normalize_value(log_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_variables(self, site_id: str) -> Dict[str, Any]: + return response + + + def list_variables( + self, + site_id: str ) -> VariableList: """ Get a list of all variables of a specific site. @@ -944,8 +1119,8 @@ def list_variables(self, site_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + VariableList + API response as a typed Pydantic model Raises ------ @@ -958,13 +1133,21 @@ def list_variables(self, site_id: str) -> Dict[str, Any]: if site_id is None: raise AppwriteException('Missing required parameter: "site_id"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_variable(self, site_id: str, key: str, value: str, secret: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=VariableList) + + + def create_variable( + self, + site_id: str, + key: str, + value: str, + secret: Optional[bool] = None ) -> Variable: """ Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. @@ -981,8 +1164,8 @@ def create_variable(self, site_id: str, key: str, value: str, secret: Optional[b Returns ------- - Dict[str, Any] - API response as a dictionary + Variable + API response as a typed Pydantic model Raises ------ @@ -1001,18 +1184,24 @@ def create_variable(self, site_id: str, key: str, value: str, secret: Optional[b if value is None: raise AppwriteException('Missing required parameter: "value"') - api_path = api_path.replace('{siteId}', site_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) - api_params['key'] = key - api_params['value'] = value + api_params['key'] = self._normalize_value(key) + api_params['value'] = self._normalize_value(value) if secret is not None: - api_params['secret'] = secret + api_params['secret'] = self._normalize_value(secret) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_variable(self, site_id: str, variable_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Variable) + + + def get_variable( + self, + site_id: str, + variable_id: str ) -> Variable: """ Get a variable by its unique ID. @@ -1025,8 +1214,8 @@ def get_variable(self, site_id: str, variable_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Variable + API response as a typed Pydantic model Raises ------ @@ -1042,14 +1231,23 @@ def get_variable(self, site_id: str, variable_id: str) -> Dict[str, Any]: if variable_id is None: raise AppwriteException('Missing required parameter: "variable_id"') - api_path = api_path.replace('{siteId}', site_id) - api_path = api_path.replace('{variableId}', variable_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_variable(self, site_id: str, variable_id: str, key: str, value: Optional[str] = None, secret: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Variable) + + + def update_variable( + self, + site_id: str, + variable_id: str, + key: str, + value: Optional[str] = None, + secret: Optional[bool] = None ) -> Variable: """ Update variable by its unique ID. @@ -1068,8 +1266,8 @@ def update_variable(self, site_id: str, variable_id: str, key: str, value: Optio Returns ------- - Dict[str, Any] - API response as a dictionary + Variable + API response as a typed Pydantic model Raises ------ @@ -1088,18 +1286,24 @@ def update_variable(self, site_id: str, variable_id: str, key: str, value: Optio if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{siteId}', site_id) - api_path = api_path.replace('{variableId}', variable_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - api_params['key'] = key - api_params['value'] = value - api_params['secret'] = secret + api_params['key'] = self._normalize_value(key) + api_params['value'] = self._normalize_value(value) + api_params['secret'] = self._normalize_value(secret) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete_variable(self, site_id: str, variable_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Variable) + + + def delete_variable( + self, + site_id: str, + variable_id: str ) -> Dict[str, Any]: """ Delete a variable by its unique ID. @@ -1129,10 +1333,13 @@ def delete_variable(self, site_id: str, variable_id: str) -> Dict[str, Any]: if variable_id is None: raise AppwriteException('Missing required parameter: "variable_id"') - api_path = api_path.replace('{siteId}', site_id) - api_path = api_path.replace('{variableId}', variable_id) + api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + + return response + diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index 36f993d..9569288 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -1,9 +1,13 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.bucket_list import BucketList; from ..enums.compression import Compression; +from ..models.bucket import Bucket; +from ..models.file_list import FileList; from ..input_file import InputFile +from ..models.file import File; from ..enums.image_gravity import ImageGravity; from ..enums.image_format import ImageFormat; @@ -12,7 +16,11 @@ class Storage(Service): def __init__(self, client) -> None: super(Storage, self).__init__(client) - def list_buckets(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list_buckets( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> BucketList: """ Get a list of all the storage buckets. You can use the query params to filter your results. @@ -27,8 +35,8 @@ def list_buckets(self, queries: Optional[List[str]] = None, search: Optional[str Returns ------- - Dict[str, Any] - API response as a dictionary + BucketList + API response as a typed Pydantic model Raises ------ @@ -40,16 +48,31 @@ def list_buckets(self, queries: Optional[List[str]] = None, search: Optional[str api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_bucket(self, bucket_id: str, name: str, permissions: Optional[List[str]] = None, file_security: Optional[bool] = None, enabled: Optional[bool] = None, maximum_file_size: Optional[float] = None, allowed_file_extensions: Optional[List[str]] = None, compression: Optional[Compression] = None, encryption: Optional[bool] = None, antivirus: Optional[bool] = None, transformations: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=BucketList) + + + def create_bucket( + self, + bucket_id: str, + name: str, + permissions: Optional[List[str]] = None, + file_security: Optional[bool] = None, + enabled: Optional[bool] = None, + maximum_file_size: Optional[float] = None, + allowed_file_extensions: Optional[List[str]] = None, + compression: Optional[Compression] = None, + encryption: Optional[bool] = None, + antivirus: Optional[bool] = None, + transformations: Optional[bool] = None ) -> Bucket: """ Create a new storage bucket. @@ -80,8 +103,8 @@ def create_bucket(self, bucket_id: str, name: str, permissions: Optional[List[st Returns ------- - Dict[str, Any] - API response as a dictionary + Bucket + API response as a typed Pydantic model Raises ------ @@ -98,31 +121,36 @@ def create_bucket(self, bucket_id: str, name: str, permissions: Optional[List[st raise AppwriteException('Missing required parameter: "name"') - api_params['bucketId'] = bucket_id - api_params['name'] = name - api_params['permissions'] = permissions + api_params['bucketId'] = self._normalize_value(bucket_id) + api_params['name'] = self._normalize_value(name) + api_params['permissions'] = self._normalize_value(permissions) if file_security is not None: - api_params['fileSecurity'] = file_security + api_params['fileSecurity'] = self._normalize_value(file_security) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) if maximum_file_size is not None: - api_params['maximumFileSize'] = maximum_file_size + api_params['maximumFileSize'] = self._normalize_value(maximum_file_size) if allowed_file_extensions is not None: - api_params['allowedFileExtensions'] = allowed_file_extensions + api_params['allowedFileExtensions'] = self._normalize_value(allowed_file_extensions) if compression is not None: - api_params['compression'] = compression + api_params['compression'] = self._normalize_value(compression) if encryption is not None: - api_params['encryption'] = encryption + api_params['encryption'] = self._normalize_value(encryption) if antivirus is not None: - api_params['antivirus'] = antivirus + api_params['antivirus'] = self._normalize_value(antivirus) if transformations is not None: - api_params['transformations'] = transformations + api_params['transformations'] = self._normalize_value(transformations) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_bucket(self, bucket_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Bucket) + + + def get_bucket( + self, + bucket_id: str ) -> Bucket: """ Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata. @@ -133,8 +161,8 @@ def get_bucket(self, bucket_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Bucket + API response as a typed Pydantic model Raises ------ @@ -147,13 +175,28 @@ def get_bucket(self, bucket_id: str) -> Dict[str, Any]: if bucket_id is None: raise AppwriteException('Missing required parameter: "bucket_id"') - api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_bucket(self, bucket_id: str, name: str, permissions: Optional[List[str]] = None, file_security: Optional[bool] = None, enabled: Optional[bool] = None, maximum_file_size: Optional[float] = None, allowed_file_extensions: Optional[List[str]] = None, compression: Optional[Compression] = None, encryption: Optional[bool] = None, antivirus: Optional[bool] = None, transformations: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Bucket) + + + def update_bucket( + self, + bucket_id: str, + name: str, + permissions: Optional[List[str]] = None, + file_security: Optional[bool] = None, + enabled: Optional[bool] = None, + maximum_file_size: Optional[float] = None, + allowed_file_extensions: Optional[List[str]] = None, + compression: Optional[Compression] = None, + encryption: Optional[bool] = None, + antivirus: Optional[bool] = None, + transformations: Optional[bool] = None ) -> Bucket: """ Update a storage bucket by its unique ID. @@ -184,8 +227,8 @@ def update_bucket(self, bucket_id: str, name: str, permissions: Optional[List[st Returns ------- - Dict[str, Any] - API response as a dictionary + Bucket + API response as a typed Pydantic model Raises ------ @@ -201,32 +244,37 @@ def update_bucket(self, bucket_id: str, name: str, permissions: Optional[List[st if name is None: raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) - api_params['name'] = name - api_params['permissions'] = permissions + api_params['name'] = self._normalize_value(name) + api_params['permissions'] = self._normalize_value(permissions) if file_security is not None: - api_params['fileSecurity'] = file_security + api_params['fileSecurity'] = self._normalize_value(file_security) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) if maximum_file_size is not None: - api_params['maximumFileSize'] = maximum_file_size + api_params['maximumFileSize'] = self._normalize_value(maximum_file_size) if allowed_file_extensions is not None: - api_params['allowedFileExtensions'] = allowed_file_extensions + api_params['allowedFileExtensions'] = self._normalize_value(allowed_file_extensions) if compression is not None: - api_params['compression'] = compression + api_params['compression'] = self._normalize_value(compression) if encryption is not None: - api_params['encryption'] = encryption + api_params['encryption'] = self._normalize_value(encryption) if antivirus is not None: - api_params['antivirus'] = antivirus + api_params['antivirus'] = self._normalize_value(antivirus) if transformations is not None: - api_params['transformations'] = transformations + api_params['transformations'] = self._normalize_value(transformations) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete_bucket(self, bucket_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Bucket) + + + def delete_bucket( + self, + bucket_id: str ) -> Dict[str, Any]: """ Delete a storage bucket by its unique ID. @@ -251,14 +299,22 @@ def delete_bucket(self, bucket_id: str) -> Dict[str, Any]: if bucket_id is None: raise AppwriteException('Missing required parameter: "bucket_id"') - api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_files(self, bucket_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return response + + + def list_files( + self, + bucket_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> FileList: """ Get a list of all the user files. You can use the query params to filter your results. @@ -275,8 +331,8 @@ def list_files(self, bucket_id: str, queries: Optional[List[str]] = None, search Returns ------- - Dict[str, Any] - API response as a dictionary + FileList + API response as a typed Pydantic model Raises ------ @@ -289,19 +345,28 @@ def list_files(self, bucket_id: str, queries: Optional[List[str]] = None, search if bucket_id is None: raise AppwriteException('Missing required parameter: "bucket_id"') - api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_file(self, bucket_id: str, file_id: str, file: InputFile, permissions: Optional[List[str]] = None, on_progress = None) -> Dict[str, Any]: + return self._parse_response(response, model=FileList) + + + def create_file( + self, + bucket_id: str, + file_id: str, + file: InputFile, + permissions: Optional[List[str]] = None, + on_progress = None ) -> File: """ Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. @@ -327,8 +392,8 @@ def create_file(self, bucket_id: str, file_id: str, file: InputFile, permissions Returns ------- - Dict[str, Any] - API response as a dictionary + File + API response as a typed Pydantic model Raises ------ @@ -347,12 +412,12 @@ def create_file(self, bucket_id: str, file_id: str, file: InputFile, permissions if file is None: raise AppwriteException('Missing required parameter: "file"') - api_path = api_path.replace('{bucketId}', bucket_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) - api_params['fileId'] = file_id - api_params['file'] = file + api_params['fileId'] = self._normalize_value(file_id) + api_params['file'] = self._normalize_value(file) if permissions is not None: - api_params['permissions'] = permissions + api_params['permissions'] = self._normalize_value(permissions) param_name = 'file' @@ -360,11 +425,17 @@ def create_file(self, bucket_id: str, file_id: str, file: InputFile, permissions upload_id = '' upload_id = file_id - return self.client.chunked_upload(api_path, { + response = self.client.chunked_upload(api_path, { 'content-type': 'multipart/form-data', }, api_params, param_name, on_progress, upload_id) - def get_file(self, bucket_id: str, file_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=File) + + + def get_file( + self, + bucket_id: str, + file_id: str ) -> File: """ Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. @@ -377,8 +448,8 @@ def get_file(self, bucket_id: str, file_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + File + API response as a typed Pydantic model Raises ------ @@ -394,14 +465,22 @@ def get_file(self, bucket_id: str, file_id: str) -> Dict[str, Any]: if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - api_path = api_path.replace('{bucketId}', bucket_id) - api_path = api_path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) + api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_file(self, bucket_id: str, file_id: str, name: Optional[str] = None, permissions: Optional[List[str]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=File) + + + def update_file( + self, + bucket_id: str, + file_id: str, + name: Optional[str] = None, + permissions: Optional[List[str]] = None ) -> File: """ Update a file by its unique ID. Only users with write permissions have access to update this resource. @@ -418,8 +497,8 @@ def update_file(self, bucket_id: str, file_id: str, name: Optional[str] = None, Returns ------- - Dict[str, Any] - API response as a dictionary + File + API response as a typed Pydantic model Raises ------ @@ -435,18 +514,24 @@ def update_file(self, bucket_id: str, file_id: str, name: Optional[str] = None, if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - api_path = api_path.replace('{bucketId}', bucket_id) - api_path = api_path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) + api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) if name is not None: - api_params['name'] = name - api_params['permissions'] = permissions + api_params['name'] = self._normalize_value(name) + api_params['permissions'] = self._normalize_value(permissions) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete_file(self, bucket_id: str, file_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=File) + + + def delete_file( + self, + bucket_id: str, + file_id: str ) -> Dict[str, Any]: """ Delete a file by its unique ID. Only users with write permissions have access to delete this resource. @@ -476,15 +561,22 @@ def delete_file(self, bucket_id: str, file_id: str) -> Dict[str, Any]: if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - api_path = api_path.replace('{bucketId}', bucket_id) - api_path = api_path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) + api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def get_file_download(self, bucket_id: str, file_id: str, token: Optional[str] = None) -> bytes: + return response + + + def get_file_download( + self, + bucket_id: str, + file_id: str, + token: Optional[str] = None ) -> bytes: """ Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. @@ -516,16 +608,34 @@ def get_file_download(self, bucket_id: str, file_id: str, token: Optional[str] = if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - api_path = api_path.replace('{bucketId}', bucket_id) - api_path = api_path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) + api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) if token is not None: - api_params['token'] = token + api_params['token'] = self._normalize_value(token) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_file_preview(self, bucket_id: str, file_id: str, width: Optional[float] = None, height: Optional[float] = None, gravity: Optional[ImageGravity] = None, quality: Optional[float] = None, border_width: Optional[float] = None, border_color: Optional[str] = None, border_radius: Optional[float] = None, opacity: Optional[float] = None, rotation: Optional[float] = None, background: Optional[str] = None, output: Optional[ImageFormat] = None, token: Optional[str] = None) -> bytes: + return response + + + def get_file_preview( + self, + bucket_id: str, + file_id: str, + width: Optional[float] = None, + height: Optional[float] = None, + gravity: Optional[ImageGravity] = None, + quality: Optional[float] = None, + border_width: Optional[float] = None, + border_color: Optional[str] = None, + border_radius: Optional[float] = None, + opacity: Optional[float] = None, + rotation: Optional[float] = None, + background: Optional[str] = None, + output: Optional[ImageFormat] = None, + token: Optional[str] = None ) -> bytes: """ Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB. @@ -579,38 +689,45 @@ def get_file_preview(self, bucket_id: str, file_id: str, width: Optional[float] if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - api_path = api_path.replace('{bucketId}', bucket_id) - api_path = api_path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) + api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) if width is not None: - api_params['width'] = width + api_params['width'] = self._normalize_value(width) if height is not None: - api_params['height'] = height + api_params['height'] = self._normalize_value(height) if gravity is not None: - api_params['gravity'] = gravity + api_params['gravity'] = self._normalize_value(gravity) if quality is not None: - api_params['quality'] = quality + api_params['quality'] = self._normalize_value(quality) if border_width is not None: - api_params['borderWidth'] = border_width + api_params['borderWidth'] = self._normalize_value(border_width) if border_color is not None: - api_params['borderColor'] = border_color + api_params['borderColor'] = self._normalize_value(border_color) if border_radius is not None: - api_params['borderRadius'] = border_radius + api_params['borderRadius'] = self._normalize_value(border_radius) if opacity is not None: - api_params['opacity'] = opacity + api_params['opacity'] = self._normalize_value(opacity) if rotation is not None: - api_params['rotation'] = rotation + api_params['rotation'] = self._normalize_value(rotation) if background is not None: - api_params['background'] = background + api_params['background'] = self._normalize_value(background) if output is not None: - api_params['output'] = output + api_params['output'] = self._normalize_value(output) if token is not None: - api_params['token'] = token + api_params['token'] = self._normalize_value(token) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_file_view(self, bucket_id: str, file_id: str, token: Optional[str] = None) -> bytes: + return response + + + def get_file_view( + self, + bucket_id: str, + file_id: str, + token: Optional[str] = None ) -> bytes: """ Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. @@ -642,11 +759,14 @@ def get_file_view(self, bucket_id: str, file_id: str, token: Optional[str] = Non if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - api_path = api_path.replace('{bucketId}', bucket_id) - api_path = api_path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) + api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) if token is not None: - api_params['token'] = token + api_params['token'] = self._normalize_value(token) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) + + return response + diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index 08dc69b..8eb7149 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -1,18 +1,50 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.database_list import DatabaseList; +from ..models.database import Database; +from ..models.transaction_list import TransactionList; +from ..models.transaction import Transaction; +from ..models.table_list import TableList; +from ..models.table import Table; +from ..models.column_list import ColumnList; +from ..models.column_boolean import ColumnBoolean; +from ..models.column_datetime import ColumnDatetime; +from ..models.column_email import ColumnEmail; +from ..models.column_enum import ColumnEnum; +from ..models.column_float import ColumnFloat; +from ..models.column_integer import ColumnInteger; +from ..models.column_ip import ColumnIp; +from ..models.column_line import ColumnLine; +from ..models.column_longtext import ColumnLongtext; +from ..models.column_mediumtext import ColumnMediumtext; +from ..models.column_point import ColumnPoint; +from ..models.column_polygon import ColumnPolygon; from ..enums.relationship_type import RelationshipType; from ..enums.relation_mutate import RelationMutate; +from ..models.column_relationship import ColumnRelationship; +from ..models.column_string import ColumnString; +from ..models.column_text import ColumnText; +from ..models.column_url import ColumnUrl; +from ..models.column_varchar import ColumnVarchar; +from ..models.column_index_list import ColumnIndexList; from ..enums.index_type import IndexType; from ..enums.order_by import OrderBy; +from ..models.column_index import ColumnIndex; +from ..models.row_list import RowList; +from ..models.row import Row; class TablesDB(Service): def __init__(self, client) -> None: super(TablesDB, self).__init__(client) - def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> DatabaseList: """ Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. @@ -27,8 +59,8 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None Returns ------- - Dict[str, Any] - API response as a dictionary + DatabaseList + API response as a typed Pydantic model Raises ------ @@ -40,16 +72,23 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create(self, database_id: str, name: str, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=DatabaseList) + + + def create( + self, + database_id: str, + name: str, + enabled: Optional[bool] = None ) -> Database: """ Create a new Database. @@ -65,8 +104,8 @@ def create(self, database_id: str, name: str, enabled: Optional[bool] = None) -> Returns ------- - Dict[str, Any] - API response as a dictionary + Database + API response as a typed Pydantic model Raises ------ @@ -83,16 +122,21 @@ def create(self, database_id: str, name: str, enabled: Optional[bool] = None) -> raise AppwriteException('Missing required parameter: "name"') - api_params['databaseId'] = database_id - api_params['name'] = name + api_params['databaseId'] = self._normalize_value(database_id) + api_params['name'] = self._normalize_value(name) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def list_transactions(self, queries: Optional[List[str]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Database) + + + def list_transactions( + self, + queries: Optional[List[str]] = None ) -> TransactionList: """ List transactions across all databases. @@ -103,8 +147,8 @@ def list_transactions(self, queries: Optional[List[str]] = None) -> Dict[str, An Returns ------- - Dict[str, Any] - API response as a dictionary + TransactionList + API response as a typed Pydantic model Raises ------ @@ -116,12 +160,17 @@ def list_transactions(self, queries: Optional[List[str]] = None) -> Dict[str, An api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_transaction(self, ttl: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=TransactionList) + + + def create_transaction( + self, + ttl: Optional[float] = None ) -> Transaction: """ Create a new transaction. @@ -132,8 +181,8 @@ def create_transaction(self, ttl: Optional[float] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Transaction + API response as a typed Pydantic model Raises ------ @@ -145,13 +194,18 @@ def create_transaction(self, ttl: Optional[float] = None) -> Dict[str, Any]: api_params = {} if ttl is not None: - api_params['ttl'] = ttl + api_params['ttl'] = self._normalize_value(ttl) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_transaction(self, transaction_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Transaction) + + + def get_transaction( + self, + transaction_id: str ) -> Transaction: """ Get a transaction by its unique ID. @@ -162,8 +216,8 @@ def get_transaction(self, transaction_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Transaction + API response as a typed Pydantic model Raises ------ @@ -176,13 +230,20 @@ def get_transaction(self, transaction_id: str) -> Dict[str, Any]: if transaction_id is None: raise AppwriteException('Missing required parameter: "transaction_id"') - api_path = api_path.replace('{transactionId}', transaction_id) + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_transaction(self, transaction_id: str, commit: Optional[bool] = None, rollback: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Transaction) + + + def update_transaction( + self, + transaction_id: str, + commit: Optional[bool] = None, + rollback: Optional[bool] = None ) -> Transaction: """ Update a transaction, to either commit or roll back its operations. @@ -197,8 +258,8 @@ def update_transaction(self, transaction_id: str, commit: Optional[bool] = None, Returns ------- - Dict[str, Any] - API response as a dictionary + Transaction + API response as a typed Pydantic model Raises ------ @@ -211,18 +272,23 @@ def update_transaction(self, transaction_id: str, commit: Optional[bool] = None, if transaction_id is None: raise AppwriteException('Missing required parameter: "transaction_id"') - api_path = api_path.replace('{transactionId}', transaction_id) + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) if commit is not None: - api_params['commit'] = commit + api_params['commit'] = self._normalize_value(commit) if rollback is not None: - api_params['rollback'] = rollback + api_params['rollback'] = self._normalize_value(rollback) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_transaction(self, transaction_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Transaction) + + + def delete_transaction( + self, + transaction_id: str ) -> Dict[str, Any]: """ Delete a transaction by its unique ID. @@ -247,14 +313,20 @@ def delete_transaction(self, transaction_id: str) -> Dict[str, Any]: if transaction_id is None: raise AppwriteException('Missing required parameter: "transaction_id"') - api_path = api_path.replace('{transactionId}', transaction_id) + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def create_operations(self, transaction_id: str, operations: Optional[List[dict]] = None) -> Dict[str, Any]: + return response + + + def create_operations( + self, + transaction_id: str, + operations: Optional[List[Dict[str, Any]]] = None ) -> Transaction: """ Create multiple operations in a single transaction. @@ -262,13 +334,13 @@ def create_operations(self, transaction_id: str, operations: Optional[List[dict] ---------- transaction_id : str Transaction ID. - operations : Optional[List[dict]] + operations : Optional[List[Dict[str, Any]]] Array of staged operations. Returns ------- - Dict[str, Any] - API response as a dictionary + Transaction + API response as a typed Pydantic model Raises ------ @@ -281,16 +353,21 @@ def create_operations(self, transaction_id: str, operations: Optional[List[dict] if transaction_id is None: raise AppwriteException('Missing required parameter: "transaction_id"') - api_path = api_path.replace('{transactionId}', transaction_id) + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) if operations is not None: - api_params['operations'] = operations + api_params['operations'] = self._normalize_value(operations) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get(self, database_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Transaction) + + + def get( + self, + database_id: str ) -> Database: """ Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. @@ -301,8 +378,8 @@ def get(self, database_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Database + API response as a typed Pydantic model Raises ------ @@ -315,13 +392,20 @@ def get(self, database_id: str) -> Dict[str, Any]: if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update(self, database_id: str, name: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Database) + + + def update( + self, + database_id: str, + name: Optional[str] = None, + enabled: Optional[bool] = None ) -> Database: """ Update a database by its unique ID. @@ -336,8 +420,8 @@ def update(self, database_id: str, name: Optional[str] = None, enabled: Optional Returns ------- - Dict[str, Any] - API response as a dictionary + Database + API response as a typed Pydantic model Raises ------ @@ -350,18 +434,23 @@ def update(self, database_id: str, name: Optional[str] = None, enabled: Optional if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete(self, database_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Database) + + + def delete( + self, + database_id: str ) -> Dict[str, Any]: """ Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. @@ -386,14 +475,22 @@ def delete(self, database_id: str) -> Dict[str, Any]: if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_tables(self, database_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return response + + + def list_tables( + self, + database_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> TableList: """ Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. @@ -410,8 +507,8 @@ def list_tables(self, database_id: str, queries: Optional[List[str]] = None, sea Returns ------- - Dict[str, Any] - API response as a dictionary + TableList + API response as a typed Pydantic model Raises ------ @@ -424,19 +521,31 @@ def list_tables(self, database_id: str, queries: Optional[List[str]] = None, sea if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_table(self, database_id: str, table_id: str, name: str, permissions: Optional[List[str]] = None, row_security: Optional[bool] = None, enabled: Optional[bool] = None, columns: Optional[List[dict]] = None, indexes: Optional[List[dict]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=TableList) + + + def create_table( + self, + database_id: str, + table_id: str, + name: str, + permissions: Optional[List[str]] = None, + row_security: Optional[bool] = None, + enabled: Optional[bool] = None, + columns: Optional[List[Dict[str, Any]]] = None, + indexes: Optional[List[Dict[str, Any]]] = None ) -> Table: """ Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -454,15 +563,15 @@ def create_table(self, database_id: str, table_id: str, name: str, permissions: Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). enabled : Optional[bool] Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. - columns : Optional[List[dict]] + columns : Optional[List[Dict[str, Any]]] Array of column definitions to create. Each column should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - indexes : Optional[List[dict]] + indexes : Optional[List[Dict[str, Any]]] Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). Returns ------- - Dict[str, Any] - API response as a dictionary + Table + API response as a typed Pydantic model Raises ------ @@ -481,25 +590,31 @@ def create_table(self, database_id: str, table_id: str, name: str, permissions: if name is None: raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_params['tableId'] = table_id - api_params['name'] = name - api_params['permissions'] = permissions + api_params['tableId'] = self._normalize_value(table_id) + api_params['name'] = self._normalize_value(name) + api_params['permissions'] = self._normalize_value(permissions) if row_security is not None: - api_params['rowSecurity'] = row_security + api_params['rowSecurity'] = self._normalize_value(row_security) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) if columns is not None: - api_params['columns'] = columns + api_params['columns'] = self._normalize_value(columns) if indexes is not None: - api_params['indexes'] = indexes + api_params['indexes'] = self._normalize_value(indexes) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_table(self, database_id: str, table_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Table) + + + def get_table( + self, + database_id: str, + table_id: str ) -> Table: """ Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. @@ -512,8 +627,8 @@ def get_table(self, database_id: str, table_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Table + API response as a typed Pydantic model Raises ------ @@ -529,14 +644,24 @@ def get_table(self, database_id: str, table_id: str) -> Dict[str, Any]: if table_id is None: raise AppwriteException('Missing required parameter: "table_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_table(self, database_id: str, table_id: str, name: Optional[str] = None, permissions: Optional[List[str]] = None, row_security: Optional[bool] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Table) + + + def update_table( + self, + database_id: str, + table_id: str, + name: Optional[str] = None, + permissions: Optional[List[str]] = None, + row_security: Optional[bool] = None, + enabled: Optional[bool] = None ) -> Table: """ Update a table by its unique ID. @@ -557,8 +682,8 @@ def update_table(self, database_id: str, table_id: str, name: Optional[str] = No Returns ------- - Dict[str, Any] - API response as a dictionary + Table + API response as a typed Pydantic model Raises ------ @@ -574,22 +699,28 @@ def update_table(self, database_id: str, table_id: str, name: Optional[str] = No if table_id is None: raise AppwriteException('Missing required parameter: "table_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) if name is not None: - api_params['name'] = name - api_params['permissions'] = permissions + api_params['name'] = self._normalize_value(name) + api_params['permissions'] = self._normalize_value(permissions) if row_security is not None: - api_params['rowSecurity'] = row_security + api_params['rowSecurity'] = self._normalize_value(row_security) if enabled is not None: - api_params['enabled'] = enabled + api_params['enabled'] = self._normalize_value(enabled) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete_table(self, database_id: str, table_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Table) + + + def delete_table( + self, + database_id: str, + table_id: str ) -> Dict[str, Any]: """ Delete a table by its unique ID. Only users with write permissions have access to delete this resource. @@ -619,15 +750,23 @@ def delete_table(self, database_id: str, table_id: str) -> Dict[str, Any]: if table_id is None: raise AppwriteException('Missing required parameter: "table_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_columns(self, database_id: str, table_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return response + + + def list_columns( + self, + database_id: str, + table_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> ColumnList: """ List columns in the table. @@ -644,8 +783,8 @@ def list_columns(self, database_id: str, table_id: str, queries: Optional[List[s Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnList + API response as a typed Pydantic model Raises ------ @@ -661,18 +800,28 @@ def list_columns(self, database_id: str, table_id: str, queries: Optional[List[s if table_id is None: raise AppwriteException('Missing required parameter: "table_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_boolean_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[bool] = None, array: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnList) + + + def create_boolean_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[bool] = None, + array: Optional[bool] = None ) -> ColumnBoolean: """ Create a boolean column. @@ -694,8 +843,8 @@ def create_boolean_column(self, database_id: str, table_id: str, key: str, requi Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnBoolean + API response as a typed Pydantic model Raises ------ @@ -717,20 +866,30 @@ def create_boolean_column(self, database_id: str, table_id: str, key: str, requi if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_boolean_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[bool], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnBoolean) + + + def update_boolean_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[bool], + new_key: Optional[str] = None ) -> ColumnBoolean: """ Update a boolean column. Changing the `default` value will not update already existing rows. @@ -751,8 +910,8 @@ def update_boolean_column(self, database_id: str, table_id: str, key: str, requi Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnBoolean + API response as a typed Pydantic model Raises ------ @@ -774,19 +933,29 @@ def update_boolean_column(self, database_id: str, table_id: str, key: str, requi if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_datetime_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnBoolean) + + + def create_datetime_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> ColumnDatetime: """ Create a date time column according to the ISO 8601 standard. @@ -807,8 +976,8 @@ def create_datetime_column(self, database_id: str, table_id: str, key: str, requ Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnDatetime + API response as a typed Pydantic model Raises ------ @@ -830,20 +999,30 @@ def create_datetime_column(self, database_id: str, table_id: str, key: str, requ if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_datetime_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnDatetime) + + + def update_datetime_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> ColumnDatetime: """ Update a date time column. Changing the `default` value will not update already existing rows. @@ -864,8 +1043,8 @@ def update_datetime_column(self, database_id: str, table_id: str, key: str, requ Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnDatetime + API response as a typed Pydantic model Raises ------ @@ -887,19 +1066,29 @@ def update_datetime_column(self, database_id: str, table_id: str, key: str, requ if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_email_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnDatetime) + + + def create_email_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> ColumnEmail: """ Create an email column. @@ -921,8 +1110,8 @@ def create_email_column(self, database_id: str, table_id: str, key: str, require Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnEmail + API response as a typed Pydantic model Raises ------ @@ -944,20 +1133,30 @@ def create_email_column(self, database_id: str, table_id: str, key: str, require if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_email_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnEmail) + + + def update_email_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> ColumnEmail: """ Update an email column. Changing the `default` value will not update already existing rows. @@ -979,8 +1178,8 @@ def update_email_column(self, database_id: str, table_id: str, key: str, require Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnEmail + API response as a typed Pydantic model Raises ------ @@ -1002,19 +1201,30 @@ def update_email_column(self, database_id: str, table_id: str, key: str, require if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_enum_column(self, database_id: str, table_id: str, key: str, elements: List[str], required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnEmail) + + + def create_enum_column( + self, + database_id: str, + table_id: str, + key: str, + elements: List[str], + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> ColumnEnum: """ Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. @@ -1037,8 +1247,8 @@ def create_enum_column(self, database_id: str, table_id: str, key: str, elements Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnEnum + API response as a typed Pydantic model Raises ------ @@ -1063,21 +1273,32 @@ def create_enum_column(self, database_id: str, table_id: str, key: str, elements if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['elements'] = elements - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['elements'] = self._normalize_value(elements) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_enum_column(self, database_id: str, table_id: str, key: str, elements: List[str], required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnEnum) + + + def update_enum_column( + self, + database_id: str, + table_id: str, + key: str, + elements: List[str], + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> ColumnEnum: """ Update an enum column. Changing the `default` value will not update already existing rows. @@ -1101,8 +1322,8 @@ def update_enum_column(self, database_id: str, table_id: str, key: str, elements Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnEnum + API response as a typed Pydantic model Raises ------ @@ -1127,20 +1348,32 @@ def update_enum_column(self, database_id: str, table_id: str, key: str, elements if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['elements'] = elements - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['elements'] = self._normalize_value(elements) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_float_column(self, database_id: str, table_id: str, key: str, required: bool, min: Optional[float] = None, max: Optional[float] = None, default: Optional[float] = None, array: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnEnum) + + + def create_float_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + min: Optional[float] = None, + max: Optional[float] = None, + default: Optional[float] = None, + array: Optional[bool] = None ) -> ColumnFloat: """ Create a float column. Optionally, minimum and maximum values can be provided. @@ -1166,8 +1399,8 @@ def create_float_column(self, database_id: str, table_id: str, key: str, require Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnFloat + API response as a typed Pydantic model Raises ------ @@ -1189,22 +1422,34 @@ def create_float_column(self, database_id: str, table_id: str, key: str, require if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['min'] = self._normalize_value(min) + api_params['max'] = self._normalize_value(max) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_float_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[float], min: Optional[float] = None, max: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnFloat) + + + def update_float_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[float], + min: Optional[float] = None, + max: Optional[float] = None, + new_key: Optional[str] = None ) -> ColumnFloat: """ Update a float column. Changing the `default` value will not update already existing rows. @@ -1230,8 +1475,8 @@ def update_float_column(self, database_id: str, table_id: str, key: str, require Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnFloat + API response as a typed Pydantic model Raises ------ @@ -1253,21 +1498,33 @@ def update_float_column(self, database_id: str, table_id: str, key: str, require if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['min'] = self._normalize_value(min) + api_params['max'] = self._normalize_value(max) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_integer_column(self, database_id: str, table_id: str, key: str, required: bool, min: Optional[float] = None, max: Optional[float] = None, default: Optional[float] = None, array: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnFloat) + + + def create_integer_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + min: Optional[float] = None, + max: Optional[float] = None, + default: Optional[float] = None, + array: Optional[bool] = None ) -> ColumnInteger: """ Create an integer column. Optionally, minimum and maximum values can be provided. @@ -1293,8 +1550,8 @@ def create_integer_column(self, database_id: str, table_id: str, key: str, requi Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnInteger + API response as a typed Pydantic model Raises ------ @@ -1316,22 +1573,34 @@ def create_integer_column(self, database_id: str, table_id: str, key: str, requi if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['min'] = self._normalize_value(min) + api_params['max'] = self._normalize_value(max) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_integer_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[float], min: Optional[float] = None, max: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnInteger) + + + def update_integer_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[float], + min: Optional[float] = None, + max: Optional[float] = None, + new_key: Optional[str] = None ) -> ColumnInteger: """ Update an integer column. Changing the `default` value will not update already existing rows. @@ -1357,8 +1626,8 @@ def update_integer_column(self, database_id: str, table_id: str, key: str, requi Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnInteger + API response as a typed Pydantic model Raises ------ @@ -1380,21 +1649,31 @@ def update_integer_column(self, database_id: str, table_id: str, key: str, requi if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['min'] = self._normalize_value(min) + api_params['max'] = self._normalize_value(max) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_ip_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnInteger) + + + def create_ip_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> ColumnIp: """ Create IP address column. @@ -1416,8 +1695,8 @@ def create_ip_column(self, database_id: str, table_id: str, key: str, required: Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnIp + API response as a typed Pydantic model Raises ------ @@ -1439,20 +1718,30 @@ def create_ip_column(self, database_id: str, table_id: str, key: str, required: if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_ip_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnIp) + + + def update_ip_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> ColumnIp: """ Update an ip column. Changing the `default` value will not update already existing rows. @@ -1474,8 +1763,8 @@ def update_ip_column(self, database_id: str, table_id: str, key: str, required: Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnIp + API response as a typed Pydantic model Raises ------ @@ -1497,19 +1786,28 @@ def update_ip_column(self, database_id: str, table_id: str, key: str, required: if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[List[Any]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnIp) + + + def create_line_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None ) -> ColumnLine: """ Create a geometric line column. @@ -1528,8 +1826,8 @@ def create_line_column(self, database_id: str, table_id: str, key: str, required Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnLine + API response as a typed Pydantic model Raises ------ @@ -1551,18 +1849,28 @@ def create_line_column(self, database_id: str, table_id: str, key: str, required if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[List[Any]] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnLine) + + + def update_line_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None, + new_key: Optional[str] = None ) -> ColumnLine: """ Update a line column. Changing the `default` value will not update already existing rows. @@ -1583,8 +1891,8 @@ def update_line_column(self, database_id: str, table_id: str, key: str, required Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnLine + API response as a typed Pydantic model Raises ------ @@ -1606,19 +1914,30 @@ def update_line_column(self, database_id: str, table_id: str, key: str, required if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_longtext_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnLine) + + + def create_longtext_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> ColumnLongtext: """ Create a longtext column. @@ -1642,8 +1961,8 @@ def create_longtext_column(self, database_id: str, table_id: str, key: str, requ Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnLongtext + API response as a typed Pydantic model Raises ------ @@ -1665,22 +1984,32 @@ def create_longtext_column(self, database_id: str, table_id: str, key: str, requ if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_longtext_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnLongtext) + + + def update_longtext_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> ColumnLongtext: """ Update a longtext column. Changing the `default` value will not update already existing rows. @@ -1702,8 +2031,8 @@ def update_longtext_column(self, database_id: str, table_id: str, key: str, requ Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnLongtext + API response as a typed Pydantic model Raises ------ @@ -1725,19 +2054,30 @@ def update_longtext_column(self, database_id: str, table_id: str, key: str, requ if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_mediumtext_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnLongtext) + + + def create_mediumtext_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> ColumnMediumtext: """ Create a mediumtext column. @@ -1761,8 +2101,8 @@ def create_mediumtext_column(self, database_id: str, table_id: str, key: str, re Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnMediumtext + API response as a typed Pydantic model Raises ------ @@ -1784,22 +2124,32 @@ def create_mediumtext_column(self, database_id: str, table_id: str, key: str, re if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_mediumtext_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnMediumtext) + + + def update_mediumtext_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> ColumnMediumtext: """ Update a mediumtext column. Changing the `default` value will not update already existing rows. @@ -1821,8 +2171,8 @@ def update_mediumtext_column(self, database_id: str, table_id: str, key: str, re Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnMediumtext + API response as a typed Pydantic model Raises ------ @@ -1844,19 +2194,28 @@ def update_mediumtext_column(self, database_id: str, table_id: str, key: str, re if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[List[Any]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnMediumtext) + + + def create_point_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None ) -> ColumnPoint: """ Create a geometric point column. @@ -1875,8 +2234,8 @@ def create_point_column(self, database_id: str, table_id: str, key: str, require Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnPoint + API response as a typed Pydantic model Raises ------ @@ -1898,18 +2257,28 @@ def create_point_column(self, database_id: str, table_id: str, key: str, require if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[List[Any]] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnPoint) + + + def update_point_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None, + new_key: Optional[str] = None ) -> ColumnPoint: """ Update a point column. Changing the `default` value will not update already existing rows. @@ -1930,8 +2299,8 @@ def update_point_column(self, database_id: str, table_id: str, key: str, require Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnPoint + API response as a typed Pydantic model Raises ------ @@ -1953,19 +2322,28 @@ def update_point_column(self, database_id: str, table_id: str, key: str, require if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[List[Any]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnPoint) + + + def create_polygon_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None ) -> ColumnPolygon: """ Create a geometric polygon column. @@ -1984,8 +2362,8 @@ def create_polygon_column(self, database_id: str, table_id: str, key: str, requi Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnPolygon + API response as a typed Pydantic model Raises ------ @@ -2007,18 +2385,28 @@ def create_polygon_column(self, database_id: str, table_id: str, key: str, requi if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[List[Any]] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnPolygon) + + + def update_polygon_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[List[Any]] = None, + new_key: Optional[str] = None ) -> ColumnPolygon: """ Update a polygon column. Changing the `default` value will not update already existing rows. @@ -2039,8 +2427,8 @@ def update_polygon_column(self, database_id: str, table_id: str, key: str, requi Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnPolygon + API response as a typed Pydantic model Raises ------ @@ -2062,19 +2450,31 @@ def update_polygon_column(self, database_id: str, table_id: str, key: str, requi if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_relationship_column(self, database_id: str, table_id: str, related_table_id: str, type: RelationshipType, two_way: Optional[bool] = None, key: Optional[str] = None, two_way_key: Optional[str] = None, on_delete: Optional[RelationMutate] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnPolygon) + + + def create_relationship_column( + self, + database_id: str, + table_id: str, + related_table_id: str, + type: RelationshipType, + two_way: Optional[bool] = None, + key: Optional[str] = None, + two_way_key: Optional[str] = None, + on_delete: Optional[RelationMutate] = None ) -> ColumnRelationship: """ Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). @@ -2100,8 +2500,8 @@ def create_relationship_column(self, database_id: str, table_id: str, related_ta Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnRelationship + API response as a typed Pydantic model Raises ------ @@ -2123,24 +2523,36 @@ def create_relationship_column(self, database_id: str, table_id: str, related_ta if type is None: raise AppwriteException('Missing required parameter: "type"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['relatedTableId'] = related_table_id - api_params['type'] = type + api_params['relatedTableId'] = self._normalize_value(related_table_id) + api_params['type'] = self._normalize_value(type) if two_way is not None: - api_params['twoWay'] = two_way - api_params['key'] = key - api_params['twoWayKey'] = two_way_key + api_params['twoWay'] = self._normalize_value(two_way) + api_params['key'] = self._normalize_value(key) + api_params['twoWayKey'] = self._normalize_value(two_way_key) if on_delete is not None: - api_params['onDelete'] = on_delete + api_params['onDelete'] = self._normalize_value(on_delete) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=ColumnRelationship) + + @deprecated("This API has been deprecated since 1.9.0. Please use `tablesDB.create_text_column` instead.") - def create_string_column(self, database_id: str, table_id: str, key: str, size: float, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + def create_string_column( + self, + database_id: str, + table_id: str, + key: str, + size: float, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> ColumnString: """ Create a string column. @@ -2168,8 +2580,8 @@ def create_string_column(self, database_id: str, table_id: str, key: str, size: Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnString + API response as a typed Pydantic model Raises ------ @@ -2194,24 +2606,35 @@ def create_string_column(self, database_id: str, table_id: str, key: str, size: if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['size'] = size - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['size'] = self._normalize_value(size) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) + return self._parse_response(response, model=ColumnString) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_text_column` instead.") - def update_string_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], size: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + def update_string_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str], + size: Optional[float] = None, + new_key: Optional[str] = None ) -> ColumnString: """ Update a string column. Changing the `default` value will not update already existing rows. @@ -2237,8 +2660,8 @@ def update_string_column(self, database_id: str, table_id: str, key: str, requir Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnString + API response as a typed Pydantic model Raises ------ @@ -2260,20 +2683,31 @@ def update_string_column(self, database_id: str, table_id: str, key: str, requir if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['size'] = size - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['size'] = self._normalize_value(size) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_text_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnString) + + + def create_text_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> ColumnText: """ Create a text column. @@ -2297,8 +2731,8 @@ def create_text_column(self, database_id: str, table_id: str, key: str, required Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnText + API response as a typed Pydantic model Raises ------ @@ -2320,22 +2754,32 @@ def create_text_column(self, database_id: str, table_id: str, key: str, required if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_text_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnText) + + + def update_text_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> ColumnText: """ Update a text column. Changing the `default` value will not update already existing rows. @@ -2357,8 +2801,8 @@ def update_text_column(self, database_id: str, table_id: str, key: str, required Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnText + API response as a typed Pydantic model Raises ------ @@ -2380,19 +2824,29 @@ def update_text_column(self, database_id: str, table_id: str, key: str, required if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_url_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnText) + + + def create_url_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None ) -> ColumnUrl: """ Create a URL column. @@ -2414,8 +2868,8 @@ def create_url_column(self, database_id: str, table_id: str, key: str, required: Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnUrl + API response as a typed Pydantic model Raises ------ @@ -2437,20 +2891,30 @@ def create_url_column(self, database_id: str, table_id: str, key: str, required: if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_url_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnUrl) + + + def update_url_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str], + new_key: Optional[str] = None ) -> ColumnUrl: """ Update an url column. Changing the `default` value will not update already existing rows. @@ -2472,8 +2936,8 @@ def update_url_column(self, database_id: str, table_id: str, key: str, required: Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnUrl + API response as a typed Pydantic model Raises ------ @@ -2495,19 +2959,31 @@ def update_url_column(self, database_id: str, table_id: str, key: str, required: if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_varchar_column(self, database_id: str, table_id: str, key: str, size: float, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnUrl) + + + def create_varchar_column( + self, + database_id: str, + table_id: str, + key: str, + size: float, + required: bool, + default: Optional[str] = None, + array: Optional[bool] = None, + encrypt: Optional[bool] = None ) -> ColumnVarchar: """ Create a varchar column. @@ -2533,8 +3009,8 @@ def create_varchar_column(self, database_id: str, table_id: str, key: str, size: Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnVarchar + API response as a typed Pydantic model Raises ------ @@ -2559,23 +3035,34 @@ def create_varchar_column(self, database_id: str, table_id: str, key: str, size: if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['size'] = size - api_params['required'] = required - api_params['default'] = default + api_params['key'] = self._normalize_value(key) + api_params['size'] = self._normalize_value(size) + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) if array is not None: - api_params['array'] = array + api_params['array'] = self._normalize_value(array) if encrypt is not None: - api_params['encrypt'] = encrypt + api_params['encrypt'] = self._normalize_value(encrypt) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_varchar_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], size: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnVarchar) + + + def update_varchar_column( + self, + database_id: str, + table_id: str, + key: str, + required: bool, + default: Optional[str], + size: Optional[float] = None, + new_key: Optional[str] = None ) -> ColumnVarchar: """ Update a varchar column. Changing the `default` value will not update already existing rows. @@ -2599,8 +3086,8 @@ def update_varchar_column(self, database_id: str, table_id: str, key: str, requi Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnVarchar + API response as a typed Pydantic model Raises ------ @@ -2622,20 +3109,27 @@ def update_varchar_column(self, database_id: str, table_id: str, key: str, requi if required is None: raise AppwriteException('Missing required parameter: "required"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['required'] = required - api_params['default'] = default - api_params['size'] = size - api_params['newKey'] = new_key + api_params['required'] = self._normalize_value(required) + api_params['default'] = self._normalize_value(default) + api_params['size'] = self._normalize_value(size) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def get_column(self, database_id: str, table_id: str, key: str) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnVarchar) + + + def get_column( + self, + database_id: str, + table_id: str, + key: str ) -> Union[ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString]: """ Get column by ID. @@ -2650,8 +3144,8 @@ def get_column(self, database_id: str, table_id: str, key: str) -> Dict[str, Any Returns ------- - Dict[str, Any] - API response as a dictionary + Union[ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString] + API response as one of the typed response models Raises ------ @@ -2670,15 +3164,22 @@ def get_column(self, database_id: str, table_id: str, key: str) -> Dict[str, Any if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_column(self, database_id: str, table_id: str, key: str) -> Dict[str, Any]: + return self._parse_response(response, union_models=(ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString, )) + + + def delete_column( + self, + database_id: str, + table_id: str, + key: str ) -> Dict[str, Any]: """ Deletes a column. @@ -2713,16 +3214,25 @@ def delete_column(self, database_id: str, table_id: str, key: str) -> Dict[str, if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def update_relationship_column(self, database_id: str, table_id: str, key: str, on_delete: Optional[RelationMutate] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + return response + + + def update_relationship_column( + self, + database_id: str, + table_id: str, + key: str, + on_delete: Optional[RelationMutate] = None, + new_key: Optional[str] = None ) -> ColumnRelationship: """ Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). @@ -2742,8 +3252,8 @@ def update_relationship_column(self, database_id: str, table_id: str, key: str, Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnRelationship + API response as a typed Pydantic model Raises ------ @@ -2762,18 +3272,26 @@ def update_relationship_column(self, database_id: str, table_id: str, key: str, if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - api_params['onDelete'] = on_delete - api_params['newKey'] = new_key + api_params['onDelete'] = self._normalize_value(on_delete) + api_params['newKey'] = self._normalize_value(new_key) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def list_indexes(self, database_id: str, table_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnRelationship) + + + def list_indexes( + self, + database_id: str, + table_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> ColumnIndexList: """ List indexes on the table. @@ -2790,8 +3308,8 @@ def list_indexes(self, database_id: str, table_id: str, queries: Optional[List[s Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnIndexList + API response as a typed Pydantic model Raises ------ @@ -2807,18 +3325,29 @@ def list_indexes(self, database_id: str, table_id: str, queries: Optional[List[s if table_id is None: raise AppwriteException('Missing required parameter: "table_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_index(self, database_id: str, table_id: str, key: str, type: IndexType, columns: List[str], orders: Optional[List[OrderBy]] = None, lengths: Optional[List[float]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnIndexList) + + + def create_index( + self, + database_id: str, + table_id: str, + key: str, + type: IndexType, + columns: List[str], + orders: Optional[List[OrderBy]] = None, + lengths: Optional[List[float]] = None ) -> ColumnIndex: """ Creates an index on the columns listed. Your index should include all the columns you will query in a single request. Type can be `key`, `fulltext`, or `unique`. @@ -2842,8 +3371,8 @@ def create_index(self, database_id: str, table_id: str, key: str, type: IndexTyp Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnIndex + API response as a typed Pydantic model Raises ------ @@ -2868,22 +3397,29 @@ def create_index(self, database_id: str, table_id: str, key: str, type: IndexTyp if columns is None: raise AppwriteException('Missing required parameter: "columns"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['key'] = key - api_params['type'] = type - api_params['columns'] = columns + api_params['key'] = self._normalize_value(key) + api_params['type'] = self._normalize_value(type) + api_params['columns'] = self._normalize_value(columns) if orders is not None: - api_params['orders'] = orders + api_params['orders'] = self._normalize_value(orders) if lengths is not None: - api_params['lengths'] = lengths + api_params['lengths'] = self._normalize_value(lengths) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_index(self, database_id: str, table_id: str, key: str) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnIndex) + + + def get_index( + self, + database_id: str, + table_id: str, + key: str ) -> ColumnIndex: """ Get index by ID. @@ -2898,8 +3434,8 @@ def get_index(self, database_id: str, table_id: str, key: str) -> Dict[str, Any] Returns ------- - Dict[str, Any] - API response as a dictionary + ColumnIndex + API response as a typed Pydantic model Raises ------ @@ -2918,15 +3454,22 @@ def get_index(self, database_id: str, table_id: str, key: str) -> Dict[str, Any] if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_index(self, database_id: str, table_id: str, key: str) -> Dict[str, Any]: + return self._parse_response(response, model=ColumnIndex) + + + def delete_index( + self, + database_id: str, + table_id: str, + key: str ) -> Dict[str, Any]: """ Delete an index. @@ -2961,16 +3504,26 @@ def delete_index(self, database_id: str, table_id: str, key: str) -> Dict[str, A if key is None: raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{key}', key) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, total: Optional[bool] = None, ttl: Optional[float] = None) -> Dict[str, Any]: + return response + + + def list_rows( + self, + database_id: str, + table_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + total: Optional[bool] = None, + ttl: Optional[float] = None ) -> RowList: """ Get a list of all the user's rows in a given table. You can use the query params to filter your results. @@ -2991,8 +3544,8 @@ def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str] Returns ------- - Dict[str, Any] - API response as a dictionary + RowList + API response as a typed Pydantic model Raises ------ @@ -3008,22 +3561,32 @@ def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str] if table_id is None: raise AppwriteException('Missing required parameter: "table_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if transaction_id is not None: - api_params['transactionId'] = transaction_id + api_params['transactionId'] = self._normalize_value(transaction_id) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) if ttl is not None: - api_params['ttl'] = ttl + api_params['ttl'] = self._normalize_value(ttl) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=RowList) + + + def create_row( + self, + database_id: str, + table_id: str, + row_id: str, + data: Dict[str, Any], + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> Row: """ Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3035,7 +3598,7 @@ def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, p Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. row_id : str Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - data : dict + data : Dict[str, Any] Row data as JSON object. permissions : Optional[List[str]] An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -3044,8 +3607,8 @@ def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, p Returns ------- - Dict[str, Any] - API response as a dictionary + Row + API response as a typed Pydantic model Raises ------ @@ -3067,19 +3630,27 @@ def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, p if data is None: raise AppwriteException('Missing required parameter: "data"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['rowId'] = row_id - api_params['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + api_params['rowId'] = self._normalize_value(row_id) + api_params['data'] = self._normalize_value(data) + api_params['permissions'] = self._normalize_value(permissions) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_rows(self, database_id: str, table_id: str, rows: List[dict], transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Row) + + + def create_rows( + self, + database_id: str, + table_id: str, + rows: List[Dict[str, Any]], + transaction_id: Optional[str] = None ) -> RowList: """ Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3089,15 +3660,15 @@ def create_rows(self, database_id: str, table_id: str, rows: List[dict], transac Database ID. table_id : str Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. - rows : List[dict] + rows : List[Dict[str, Any]] Array of rows data as JSON objects. transaction_id : Optional[str] Transaction ID for staging the operation. Returns ------- - Dict[str, Any] - API response as a dictionary + RowList + API response as a typed Pydantic model Raises ------ @@ -3116,17 +3687,25 @@ def create_rows(self, database_id: str, table_id: str, rows: List[dict], transac if rows is None: raise AppwriteException('Missing required parameter: "rows"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['rows'] = rows - api_params['transactionId'] = transaction_id + api_params['rows'] = self._normalize_value(rows) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def upsert_rows(self, database_id: str, table_id: str, rows: List[dict], transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=RowList) + + + def upsert_rows( + self, + database_id: str, + table_id: str, + rows: List[Dict[str, Any]], + transaction_id: Optional[str] = None ) -> RowList: """ Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3137,15 +3716,15 @@ def upsert_rows(self, database_id: str, table_id: str, rows: List[dict], transac Database ID. table_id : str Table ID. - rows : List[dict] + rows : List[Dict[str, Any]] Array of row data as JSON objects. May contain partial rows. transaction_id : Optional[str] Transaction ID for staging the operation. Returns ------- - Dict[str, Any] - API response as a dictionary + RowList + API response as a typed Pydantic model Raises ------ @@ -3164,17 +3743,26 @@ def upsert_rows(self, database_id: str, table_id: str, rows: List[dict], transac if rows is None: raise AppwriteException('Missing required parameter: "rows"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) - api_params['rows'] = rows - api_params['transactionId'] = transaction_id + api_params['rows'] = self._normalize_value(rows) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def update_rows(self, database_id: str, table_id: str, data: Optional[dict] = None, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=RowList) + + + def update_rows( + self, + database_id: str, + table_id: str, + data: Optional[Dict[str, Any]] = None, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> RowList: """ Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. @@ -3184,7 +3772,7 @@ def update_rows(self, database_id: str, table_id: str, data: Optional[dict] = No Database ID. table_id : str Table ID. - data : Optional[dict] + data : Optional[Dict[str, Any]] Row data as JSON object. Include only column and value pairs to be updated. queries : Optional[List[str]] Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. @@ -3193,8 +3781,8 @@ def update_rows(self, database_id: str, table_id: str, data: Optional[dict] = No Returns ------- - Dict[str, Any] - API response as a dictionary + RowList + API response as a typed Pydantic model Raises ------ @@ -3210,20 +3798,28 @@ def update_rows(self, database_id: str, table_id: str, data: Optional[dict] = No if table_id is None: raise AppwriteException('Missing required parameter: "table_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) if data is not None: - api_params['data'] = data + api_params['data'] = self._normalize_value(data) if queries is not None: - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + api_params['queries'] = self._normalize_value(queries) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_rows(self, database_id: str, table_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=RowList) + + + def delete_rows( + self, + database_id: str, + table_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> RowList: """ Bulk delete rows using queries, if no queries are passed then all rows are deleted. @@ -3240,8 +3836,8 @@ def delete_rows(self, database_id: str, table_id: str, queries: Optional[List[st Returns ------- - Dict[str, Any] - API response as a dictionary + RowList + API response as a typed Pydantic model Raises ------ @@ -3257,18 +3853,27 @@ def delete_rows(self, database_id: str, table_id: str, queries: Optional[List[st if table_id is None: raise AppwriteException('Missing required parameter: "table_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) if queries is not None: - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + api_params['queries'] = self._normalize_value(queries) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def get_row(self, database_id: str, table_id: str, row_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=RowList) + + + def get_row( + self, + database_id: str, + table_id: str, + row_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> Row: """ Get a row by its unique ID. This endpoint response returns a JSON object with the row data. @@ -3287,8 +3892,8 @@ def get_row(self, database_id: str, table_id: str, row_id: str, queries: Optiona Returns ------- - Dict[str, Any] - API response as a dictionary + Row + API response as a typed Pydantic model Raises ------ @@ -3307,19 +3912,29 @@ def get_row(self, database_id: str, table_id: str, row_id: str, queries: Optiona if row_id is None: raise AppwriteException('Missing required parameter: "row_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{rowId}', row_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{rowId}', str(self._normalize_value(row_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if transaction_id is not None: - api_params['transactionId'] = transaction_id + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def upsert_row(self, database_id: str, table_id: str, row_id: str, data: Optional[dict] = None, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Row) + + + def upsert_row( + self, + database_id: str, + table_id: str, + row_id: str, + data: Optional[Dict[str, Any]] = None, + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> Row: """ Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3331,7 +3946,7 @@ def upsert_row(self, database_id: str, table_id: str, row_id: str, data: Optiona Table ID. row_id : str Row ID. - data : Optional[dict] + data : Optional[Dict[str, Any]] Row data as JSON object. Include all required columns of the row to be created or updated. permissions : Optional[List[str]] An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -3340,8 +3955,8 @@ def upsert_row(self, database_id: str, table_id: str, row_id: str, data: Optiona Returns ------- - Dict[str, Any] - API response as a dictionary + Row + API response as a typed Pydantic model Raises ------ @@ -3360,20 +3975,30 @@ def upsert_row(self, database_id: str, table_id: str, row_id: str, data: Optiona if row_id is None: raise AppwriteException('Missing required parameter: "row_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{rowId}', row_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{rowId}', str(self._normalize_value(row_id))) if data is not None: - api_params['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + api_params['data'] = self._normalize_value(data) + api_params['permissions'] = self._normalize_value(permissions) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def update_row(self, database_id: str, table_id: str, row_id: str, data: Optional[dict] = None, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Row) + + + def update_row( + self, + database_id: str, + table_id: str, + row_id: str, + data: Optional[Dict[str, Any]] = None, + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None ) -> Row: """ Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -3385,7 +4010,7 @@ def update_row(self, database_id: str, table_id: str, row_id: str, data: Optiona Table ID. row_id : str Row ID. - data : Optional[dict] + data : Optional[Dict[str, Any]] Row data as JSON object. Include only columns and value pairs to be updated. permissions : Optional[List[str]] An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -3394,8 +4019,8 @@ def update_row(self, database_id: str, table_id: str, row_id: str, data: Optiona Returns ------- - Dict[str, Any] - API response as a dictionary + Row + API response as a typed Pydantic model Raises ------ @@ -3414,20 +4039,28 @@ def update_row(self, database_id: str, table_id: str, row_id: str, data: Optiona if row_id is None: raise AppwriteException('Missing required parameter: "row_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{rowId}', row_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{rowId}', str(self._normalize_value(row_id))) if data is not None: - api_params['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + api_params['data'] = self._normalize_value(data) + api_params['permissions'] = self._normalize_value(permissions) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_row(self, database_id: str, table_id: str, row_id: str, transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Row) + + + def delete_row( + self, + database_id: str, + table_id: str, + row_id: str, + transaction_id: Optional[str] = None ) -> Dict[str, Any]: """ Delete a row by its unique ID. @@ -3464,17 +4097,28 @@ def delete_row(self, database_id: str, table_id: str, row_id: str, transaction_i if row_id is None: raise AppwriteException('Missing required parameter: "row_id"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{rowId}', row_id) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{rowId}', str(self._normalize_value(row_id))) - api_params['transactionId'] = transaction_id + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def decrement_row_column(self, database_id: str, table_id: str, row_id: str, column: str, value: Optional[float] = None, min: Optional[float] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + return response + + + def decrement_row_column( + self, + database_id: str, + table_id: str, + row_id: str, + column: str, + value: Optional[float] = None, + min: Optional[float] = None, + transaction_id: Optional[str] = None ) -> Row: """ Decrement a specific column of a row by a given value. @@ -3497,8 +4141,8 @@ def decrement_row_column(self, database_id: str, table_id: str, row_id: str, col Returns ------- - Dict[str, Any] - API response as a dictionary + Row + API response as a typed Pydantic model Raises ------ @@ -3520,21 +4164,32 @@ def decrement_row_column(self, database_id: str, table_id: str, row_id: str, col if column is None: raise AppwriteException('Missing required parameter: "column"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{rowId}', row_id) - api_path = api_path.replace('{column}', column) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{rowId}', str(self._normalize_value(row_id))) + api_path = api_path.replace('{column}', str(self._normalize_value(column))) if value is not None: - api_params['value'] = value - api_params['min'] = min - api_params['transactionId'] = transaction_id + api_params['value'] = self._normalize_value(value) + api_params['min'] = self._normalize_value(min) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def increment_row_column(self, database_id: str, table_id: str, row_id: str, column: str, value: Optional[float] = None, max: Optional[float] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Row) + + + def increment_row_column( + self, + database_id: str, + table_id: str, + row_id: str, + column: str, + value: Optional[float] = None, + max: Optional[float] = None, + transaction_id: Optional[str] = None ) -> Row: """ Increment a specific column of a row by a given value. @@ -3557,8 +4212,8 @@ def increment_row_column(self, database_id: str, table_id: str, row_id: str, col Returns ------- - Dict[str, Any] - API response as a dictionary + Row + API response as a typed Pydantic model Raises ------ @@ -3580,16 +4235,19 @@ def increment_row_column(self, database_id: str, table_id: str, row_id: str, col if column is None: raise AppwriteException('Missing required parameter: "column"') - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{tableId}', table_id) - api_path = api_path.replace('{rowId}', row_id) - api_path = api_path.replace('{column}', column) + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{tableId}', str(self._normalize_value(table_id))) + api_path = api_path.replace('{rowId}', str(self._normalize_value(row_id))) + api_path = api_path.replace('{column}', str(self._normalize_value(column))) if value is not None: - api_params['value'] = value - api_params['max'] = max - api_params['transactionId'] = transaction_id + api_params['value'] = self._normalize_value(value) + api_params['max'] = self._normalize_value(max) + api_params['transactionId'] = self._normalize_value(transaction_id) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + + return self._parse_response(response, model=Row) + diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 767dab9..0c78681 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -1,14 +1,23 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.team_list import TeamList; +from ..models.team import Team; +from ..models.membership_list import MembershipList; +from ..models.membership import Membership; +from ..models.preferences import Preferences; class Teams(Service): def __init__(self, client) -> None: super(Teams, self).__init__(client) - def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> TeamList: """ Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. @@ -23,8 +32,8 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None Returns ------- - Dict[str, Any] - API response as a dictionary + TeamList + API response as a typed Pydantic model Raises ------ @@ -36,16 +45,23 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create(self, team_id: str, name: str, roles: Optional[List[str]] = None) -> Dict[str, Any]: + return self._parse_response(response, model=TeamList) + + + def create( + self, + team_id: str, + name: str, + roles: Optional[List[str]] = None ) -> Team: """ Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. @@ -60,8 +76,8 @@ def create(self, team_id: str, name: str, roles: Optional[List[str]] = None) -> Returns ------- - Dict[str, Any] - API response as a dictionary + Team + API response as a typed Pydantic model Raises ------ @@ -78,16 +94,21 @@ def create(self, team_id: str, name: str, roles: Optional[List[str]] = None) -> raise AppwriteException('Missing required parameter: "name"') - api_params['teamId'] = team_id - api_params['name'] = name + api_params['teamId'] = self._normalize_value(team_id) + api_params['name'] = self._normalize_value(name) if roles is not None: - api_params['roles'] = roles + api_params['roles'] = self._normalize_value(roles) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get(self, team_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Team) + + + def get( + self, + team_id: str ) -> Team: """ Get a team by its ID. All team members have read access for this resource. @@ -98,8 +119,8 @@ def get(self, team_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Team + API response as a typed Pydantic model Raises ------ @@ -112,13 +133,19 @@ def get(self, team_id: str) -> Dict[str, Any]: if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_name(self, team_id: str, name: str) -> Dict[str, Any]: + return self._parse_response(response, model=Team) + + + def update_name( + self, + team_id: str, + name: str ) -> Team: """ Update the team's name by its unique ID. @@ -131,8 +158,8 @@ def update_name(self, team_id: str, name: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Team + API response as a typed Pydantic model Raises ------ @@ -148,15 +175,20 @@ def update_name(self, team_id: str, name: str) -> Dict[str, Any]: if name is None: raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def delete(self, team_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Team) + + + def delete( + self, + team_id: str ) -> Dict[str, Any]: """ Delete a team using its ID. Only team members with the owner role can delete the team. @@ -181,14 +213,22 @@ def delete(self, team_id: str) -> Dict[str, Any]: if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_memberships(self, team_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return response + + + def list_memberships( + self, + team_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> MembershipList: """ Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. @@ -205,8 +245,8 @@ def list_memberships(self, team_id: str, queries: Optional[List[str]] = None, se Returns ------- - Dict[str, Any] - API response as a dictionary + MembershipList + API response as a typed Pydantic model Raises ------ @@ -219,19 +259,30 @@ def list_memberships(self, team_id: str, queries: Optional[List[str]] = None, se if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_membership(self, team_id: str, roles: List[str], email: Optional[str] = None, user_id: Optional[str] = None, phone: Optional[str] = None, url: Optional[str] = None, name: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=MembershipList) + + + def create_membership( + self, + team_id: str, + roles: List[str], + email: Optional[str] = None, + user_id: Optional[str] = None, + phone: Optional[str] = None, + url: Optional[str] = None, + name: Optional[str] = None ) -> Membership: """ Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. @@ -261,8 +312,8 @@ def create_membership(self, team_id: str, roles: List[str], email: Optional[str] Returns ------- - Dict[str, Any] - API response as a dictionary + Membership + API response as a typed Pydantic model Raises ------ @@ -278,25 +329,31 @@ def create_membership(self, team_id: str, roles: List[str], email: Optional[str] if roles is None: raise AppwriteException('Missing required parameter: "roles"') - api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) if email is not None: - api_params['email'] = email + api_params['email'] = self._normalize_value(email) if user_id is not None: - api_params['userId'] = user_id + api_params['userId'] = self._normalize_value(user_id) if phone is not None: - api_params['phone'] = phone - api_params['roles'] = roles + api_params['phone'] = self._normalize_value(phone) + api_params['roles'] = self._normalize_value(roles) if url is not None: - api_params['url'] = url + api_params['url'] = self._normalize_value(url) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_membership(self, team_id: str, membership_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Membership) + + + def get_membership( + self, + team_id: str, + membership_id: str ) -> Membership: """ Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console. @@ -309,8 +366,8 @@ def get_membership(self, team_id: str, membership_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Membership + API response as a typed Pydantic model Raises ------ @@ -326,14 +383,21 @@ def get_membership(self, team_id: str, membership_id: str) -> Dict[str, Any]: if membership_id is None: raise AppwriteException('Missing required parameter: "membership_id"') - api_path = api_path.replace('{teamId}', team_id) - api_path = api_path.replace('{membershipId}', membership_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) + api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_membership(self, team_id: str, membership_id: str, roles: List[str]) -> Dict[str, Any]: + return self._parse_response(response, model=Membership) + + + def update_membership( + self, + team_id: str, + membership_id: str, + roles: List[str] ) -> Membership: """ Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). @@ -349,8 +413,8 @@ def update_membership(self, team_id: str, membership_id: str, roles: List[str]) Returns ------- - Dict[str, Any] - API response as a dictionary + Membership + API response as a typed Pydantic model Raises ------ @@ -369,16 +433,22 @@ def update_membership(self, team_id: str, membership_id: str, roles: List[str]) if roles is None: raise AppwriteException('Missing required parameter: "roles"') - api_path = api_path.replace('{teamId}', team_id) - api_path = api_path.replace('{membershipId}', membership_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) + api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) - api_params['roles'] = roles + api_params['roles'] = self._normalize_value(roles) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_membership(self, team_id: str, membership_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Membership) + + + def delete_membership( + self, + team_id: str, + membership_id: str ) -> Dict[str, Any]: """ This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted. @@ -408,15 +478,23 @@ def delete_membership(self, team_id: str, membership_id: str) -> Dict[str, Any]: if membership_id is None: raise AppwriteException('Missing required parameter: "membership_id"') - api_path = api_path.replace('{teamId}', team_id) - api_path = api_path.replace('{membershipId}', membership_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) + api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def update_membership_status(self, team_id: str, membership_id: str, user_id: str, secret: str) -> Dict[str, Any]: + return response + + + def update_membership_status( + self, + team_id: str, + membership_id: str, + user_id: str, + secret: str ) -> Membership: """ Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. @@ -436,8 +514,8 @@ def update_membership_status(self, team_id: str, membership_id: str, user_id: st Returns ------- - Dict[str, Any] - API response as a dictionary + Membership + API response as a typed Pydantic model Raises ------ @@ -459,17 +537,22 @@ def update_membership_status(self, team_id: str, membership_id: str, user_id: st if secret is None: raise AppwriteException('Missing required parameter: "secret"') - api_path = api_path.replace('{teamId}', team_id) - api_path = api_path.replace('{membershipId}', membership_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) + api_path = api_path.replace('{membershipId}', str(self._normalize_value(membership_id))) - api_params['userId'] = user_id - api_params['secret'] = secret + api_params['userId'] = self._normalize_value(user_id) + api_params['secret'] = self._normalize_value(secret) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def get_prefs(self, team_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Membership) + + + def get_prefs( + self, + team_id: str ) -> Preferences: """ Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). @@ -480,8 +563,8 @@ def get_prefs(self, team_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Preferences + API response as a typed Pydantic model Raises ------ @@ -494,13 +577,19 @@ def get_prefs(self, team_id: str) -> Dict[str, Any]: if team_id is None: raise AppwriteException('Missing required parameter: "team_id"') - api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_prefs(self, team_id: str, prefs: dict) -> Dict[str, Any]: + return self._parse_response(response, model=Preferences) + + + def update_prefs( + self, + team_id: str, + prefs: Dict[str, Any] ) -> Preferences: """ Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. @@ -508,13 +597,13 @@ def update_prefs(self, team_id: str, prefs: dict) -> Dict[str, Any]: ---------- team_id : str Team ID. - prefs : dict + prefs : Dict[str, Any] Prefs key-value JSON object. Returns ------- - Dict[str, Any] - API response as a dictionary + Preferences + API response as a typed Pydantic model Raises ------ @@ -530,10 +619,13 @@ def update_prefs(self, team_id: str, prefs: dict) -> Dict[str, Any]: if prefs is None: raise AppwriteException('Missing required parameter: "prefs"') - api_path = api_path.replace('{teamId}', team_id) + api_path = api_path.replace('{teamId}', str(self._normalize_value(team_id))) - api_params['prefs'] = prefs + api_params['prefs'] = self._normalize_value(prefs) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) + + return self._parse_response(response, model=Preferences) + diff --git a/appwrite/services/tokens.py b/appwrite/services/tokens.py index a5d9d63..41da60e 100644 --- a/appwrite/services/tokens.py +++ b/appwrite/services/tokens.py @@ -1,14 +1,21 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.resource_token_list import ResourceTokenList; +from ..models.resource_token import ResourceToken; class Tokens(Service): def __init__(self, client) -> None: super(Tokens, self).__init__(client) - def list(self, bucket_id: str, file_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list( + self, + bucket_id: str, + file_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> ResourceTokenList: """ List all the tokens created for a specific file or bucket. You can use the query params to filter your results. @@ -25,8 +32,8 @@ def list(self, bucket_id: str, file_id: str, queries: Optional[List[str]] = None Returns ------- - Dict[str, Any] - API response as a dictionary + ResourceTokenList + API response as a typed Pydantic model Raises ------ @@ -42,18 +49,25 @@ def list(self, bucket_id: str, file_id: str, queries: Optional[List[str]] = None if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - api_path = api_path.replace('{bucketId}', bucket_id) - api_path = api_path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) + api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_file_token(self, bucket_id: str, file_id: str, expire: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ResourceTokenList) + + + def create_file_token( + self, + bucket_id: str, + file_id: str, + expire: Optional[str] = None ) -> ResourceToken: """ Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. @@ -68,8 +82,8 @@ def create_file_token(self, bucket_id: str, file_id: str, expire: Optional[str] Returns ------- - Dict[str, Any] - API response as a dictionary + ResourceToken + API response as a typed Pydantic model Raises ------ @@ -85,16 +99,21 @@ def create_file_token(self, bucket_id: str, file_id: str, expire: Optional[str] if file_id is None: raise AppwriteException('Missing required parameter: "file_id"') - api_path = api_path.replace('{bucketId}', bucket_id) - api_path = api_path.replace('{fileId}', file_id) + api_path = api_path.replace('{bucketId}', str(self._normalize_value(bucket_id))) + api_path = api_path.replace('{fileId}', str(self._normalize_value(file_id))) - api_params['expire'] = expire + api_params['expire'] = self._normalize_value(expire) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get(self, token_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=ResourceToken) + + + def get( + self, + token_id: str ) -> ResourceToken: """ Get a token by its unique ID. @@ -105,8 +124,8 @@ def get(self, token_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + ResourceToken + API response as a typed Pydantic model Raises ------ @@ -119,13 +138,19 @@ def get(self, token_id: str) -> Dict[str, Any]: if token_id is None: raise AppwriteException('Missing required parameter: "token_id"') - api_path = api_path.replace('{tokenId}', token_id) + api_path = api_path.replace('{tokenId}', str(self._normalize_value(token_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update(self, token_id: str, expire: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=ResourceToken) + + + def update( + self, + token_id: str, + expire: Optional[str] = None ) -> ResourceToken: """ Update a token by its unique ID. Use this endpoint to update a token's expiry date. @@ -138,8 +163,8 @@ def update(self, token_id: str, expire: Optional[str] = None) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + ResourceToken + API response as a typed Pydantic model Raises ------ @@ -152,15 +177,20 @@ def update(self, token_id: str, expire: Optional[str] = None) -> Dict[str, Any]: if token_id is None: raise AppwriteException('Missing required parameter: "token_id"') - api_path = api_path.replace('{tokenId}', token_id) + api_path = api_path.replace('{tokenId}', str(self._normalize_value(token_id))) - api_params['expire'] = expire + api_params['expire'] = self._normalize_value(expire) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete(self, token_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=ResourceToken) + + + def delete( + self, + token_id: str ) -> Dict[str, Any]: """ Delete a token by its unique ID. @@ -185,9 +215,12 @@ def delete(self, token_id: str) -> Dict[str, Any]: if token_id is None: raise AppwriteException('Missing required parameter: "token_id"') - api_path = api_path.replace('{tokenId}', token_id) + api_path = api_path.replace('{tokenId}', str(self._normalize_value(token_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) + + return response + diff --git a/appwrite/services/users.py b/appwrite/services/users.py index afaa9aa..981d91a 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -1,17 +1,35 @@ from ..service import Service -from typing import List, Dict, Any, Optional +from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.user_list import UserList; +from ..models.user import User; +from ..models.identity_list import IdentityList; from ..enums.password_hash import PasswordHash; +from ..models.jwt import Jwt; +from ..models.log_list import LogList; +from ..models.membership_list import MembershipList; from ..enums.authenticator_type import AuthenticatorType; +from ..models.mfa_factors import MfaFactors; +from ..models.mfa_recovery_codes import MfaRecoveryCodes; +from ..models.preferences import Preferences; +from ..models.session_list import SessionList; +from ..models.session import Session; +from ..models.target_list import TargetList; from ..enums.messaging_provider_type import MessagingProviderType; +from ..models.target import Target; +from ..models.token import Token; class Users(Service): def __init__(self, client) -> None: super(Users, self).__init__(client) - def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + def list( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> UserList: """ Get a list of all the project's users. You can use the query params to filter your results. @@ -26,8 +44,8 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None Returns ------- - Dict[str, Any] - API response as a dictionary + UserList + API response as a typed Pydantic model Raises ------ @@ -39,16 +57,25 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create(self, user_id: str, email: Optional[str] = None, phone: Optional[str] = None, password: Optional[str] = None, name: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=UserList) + + + def create( + self, + user_id: str, + email: Optional[str] = None, + phone: Optional[str] = None, + password: Optional[str] = None, + name: Optional[str] = None ) -> User: """ Create a new user. @@ -67,8 +94,8 @@ def create(self, user_id: str, email: Optional[str] = None, phone: Optional[str] Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -82,19 +109,27 @@ def create(self, user_id: str, email: Optional[str] = None, phone: Optional[str] raise AppwriteException('Missing required parameter: "user_id"') - api_params['userId'] = user_id - api_params['email'] = email - api_params['phone'] = phone + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) + api_params['phone'] = self._normalize_value(phone) if password is not None: - api_params['password'] = password + api_params['password'] = self._normalize_value(password) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_argon2_user(self, user_id: str, email: str, password: str, name: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def create_argon2_user( + self, + user_id: str, + email: str, + password: str, + name: Optional[str] = None ) -> User: """ Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -111,8 +146,8 @@ def create_argon2_user(self, user_id: str, email: str, password: str, name: Opti Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -132,17 +167,25 @@ def create_argon2_user(self, user_id: str, email: str, password: str, name: Opti raise AppwriteException('Missing required parameter: "password"') - api_params['userId'] = user_id - api_params['email'] = email - api_params['password'] = password + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_bcrypt_user(self, user_id: str, email: str, password: str, name: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def create_bcrypt_user( + self, + user_id: str, + email: str, + password: str, + name: Optional[str] = None ) -> User: """ Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -159,8 +202,8 @@ def create_bcrypt_user(self, user_id: str, email: str, password: str, name: Opti Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -180,17 +223,24 @@ def create_bcrypt_user(self, user_id: str, email: str, password: str, name: Opti raise AppwriteException('Missing required parameter: "password"') - api_params['userId'] = user_id - api_params['email'] = email - api_params['password'] = password + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def list_identities(self, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def list_identities( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> IdentityList: """ Get identities for all users. @@ -205,8 +255,8 @@ def list_identities(self, queries: Optional[List[str]] = None, search: Optional[ Returns ------- - Dict[str, Any] - API response as a dictionary + IdentityList + API response as a typed Pydantic model Raises ------ @@ -218,16 +268,21 @@ def list_identities(self, queries: Optional[List[str]] = None, search: Optional[ api_params = {} if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete_identity(self, identity_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=IdentityList) + + + def delete_identity( + self, + identity_id: str ) -> Dict[str, Any]: """ Delete an identity by its unique ID. @@ -252,14 +307,22 @@ def delete_identity(self, identity_id: str) -> Dict[str, Any]: if identity_id is None: raise AppwriteException('Missing required parameter: "identity_id"') - api_path = api_path.replace('{identityId}', identity_id) + api_path = api_path.replace('{identityId}', str(self._normalize_value(identity_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def create_md5_user(self, user_id: str, email: str, password: str, name: Optional[str] = None) -> Dict[str, Any]: + return response + + + def create_md5_user( + self, + user_id: str, + email: str, + password: str, + name: Optional[str] = None ) -> User: """ Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -276,8 +339,8 @@ def create_md5_user(self, user_id: str, email: str, password: str, name: Optiona Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -297,17 +360,25 @@ def create_md5_user(self, user_id: str, email: str, password: str, name: Optiona raise AppwriteException('Missing required parameter: "password"') - api_params['userId'] = user_id - api_params['email'] = email - api_params['password'] = password + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_ph_pass_user(self, user_id: str, email: str, password: str, name: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def create_ph_pass_user( + self, + user_id: str, + email: str, + password: str, + name: Optional[str] = None ) -> User: """ Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -324,8 +395,8 @@ def create_ph_pass_user(self, user_id: str, email: str, password: str, name: Opt Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -345,17 +416,30 @@ def create_ph_pass_user(self, user_id: str, email: str, password: str, name: Opt raise AppwriteException('Missing required parameter: "password"') - api_params['userId'] = user_id - api_params['email'] = email - api_params['password'] = password + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - 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: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + 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: Optional[str] = None ) -> User: """ Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -382,8 +466,8 @@ def create_scrypt_user(self, user_id: str, email: str, password: str, password_s Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -418,22 +502,33 @@ def create_scrypt_user(self, user_id: str, email: str, password: str, password_s raise AppwriteException('Missing required parameter: "password_length"') - api_params['userId'] = user_id - api_params['email'] = email - api_params['password'] = password - api_params['passwordSalt'] = password_salt - api_params['passwordCpu'] = password_cpu - api_params['passwordMemory'] = password_memory - api_params['passwordParallel'] = password_parallel - api_params['passwordLength'] = password_length + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) + api_params['passwordSalt'] = self._normalize_value(password_salt) + api_params['passwordCpu'] = self._normalize_value(password_cpu) + api_params['passwordMemory'] = self._normalize_value(password_memory) + api_params['passwordParallel'] = self._normalize_value(password_parallel) + api_params['passwordLength'] = self._normalize_value(password_length) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - 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: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + 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: Optional[str] = None ) -> User: """ Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -456,8 +551,8 @@ def create_scrypt_modified_user(self, user_id: str, email: str, password: str, p Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -486,20 +581,29 @@ def create_scrypt_modified_user(self, user_id: str, email: str, password: str, p raise AppwriteException('Missing required parameter: "password_signer_key"') - api_params['userId'] = user_id - api_params['email'] = email - api_params['password'] = password - api_params['passwordSalt'] = password_salt - api_params['passwordSaltSeparator'] = password_salt_separator - api_params['passwordSignerKey'] = password_signer_key + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) + api_params['passwordSalt'] = self._normalize_value(password_salt) + api_params['passwordSaltSeparator'] = self._normalize_value(password_salt_separator) + api_params['passwordSignerKey'] = self._normalize_value(password_signer_key) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_sha_user(self, user_id: str, email: str, password: str, password_version: Optional[PasswordHash] = None, name: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def create_sha_user( + self, + user_id: str, + email: str, + password: str, + password_version: Optional[PasswordHash] = None, + name: Optional[str] = None ) -> User: """ Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -518,8 +622,8 @@ def create_sha_user(self, user_id: str, email: str, password: str, password_vers Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -539,19 +643,24 @@ def create_sha_user(self, user_id: str, email: str, password: str, password_vers raise AppwriteException('Missing required parameter: "password"') - api_params['userId'] = user_id - api_params['email'] = email - api_params['password'] = password + api_params['userId'] = self._normalize_value(user_id) + api_params['email'] = self._normalize_value(email) + api_params['password'] = self._normalize_value(password) if password_version is not None: - api_params['passwordVersion'] = password_version + api_params['passwordVersion'] = self._normalize_value(password_version) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get(self, user_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def get( + self, + user_id: str ) -> User: """ Get a user by its unique ID. @@ -562,8 +671,8 @@ def get(self, user_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -576,13 +685,18 @@ def get(self, user_id: str) -> Dict[str, Any]: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def delete(self, user_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def delete( + self, + user_id: str ) -> Dict[str, Any]: """ Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. @@ -607,14 +721,20 @@ def delete(self, user_id: str) -> Dict[str, Any]: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def update_email(self, user_id: str, email: str) -> Dict[str, Any]: + return response + + + def update_email( + self, + user_id: str, + email: str ) -> User: """ Update the user email by its unique ID. @@ -627,8 +747,8 @@ def update_email(self, user_id: str, email: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -644,15 +764,22 @@ def update_email(self, user_id: str, email: str) -> Dict[str, Any]: if email is None: raise AppwriteException('Missing required parameter: "email"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['email'] = email + api_params['email'] = self._normalize_value(email) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def create_jwt(self, user_id: str, session_id: Optional[str] = None, duration: Optional[float] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def create_jwt( + self, + user_id: str, + session_id: Optional[str] = None, + duration: Optional[float] = None ) -> Jwt: """ Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. @@ -667,8 +794,8 @@ def create_jwt(self, user_id: str, session_id: Optional[str] = None, duration: O Returns ------- - Dict[str, Any] - API response as a dictionary + Jwt + API response as a typed Pydantic model Raises ------ @@ -681,18 +808,24 @@ def create_jwt(self, user_id: str, session_id: Optional[str] = None, duration: O if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) if session_id is not None: - api_params['sessionId'] = session_id + api_params['sessionId'] = self._normalize_value(session_id) if duration is not None: - api_params['duration'] = duration + api_params['duration'] = self._normalize_value(duration) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_labels(self, user_id: str, labels: List[str]) -> Dict[str, Any]: + return self._parse_response(response, model=Jwt) + + + def update_labels( + self, + user_id: str, + labels: List[str] ) -> User: """ Update the user labels by its unique ID. @@ -707,8 +840,8 @@ def update_labels(self, user_id: str, labels: List[str]) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -724,15 +857,22 @@ def update_labels(self, user_id: str, labels: List[str]) -> Dict[str, Any]: if labels is None: raise AppwriteException('Missing required parameter: "labels"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['labels'] = labels + api_params['labels'] = self._normalize_value(labels) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def list_logs(self, user_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def list_logs( + self, + user_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> LogList: """ Get the user activity logs list by its unique ID. @@ -747,8 +887,8 @@ def list_logs(self, user_id: str, queries: Optional[List[str]] = None, total: Op Returns ------- - Dict[str, Any] - API response as a dictionary + LogList + API response as a typed Pydantic model Raises ------ @@ -761,17 +901,25 @@ def list_logs(self, user_id: str, queries: Optional[List[str]] = None, total: Op if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def list_memberships(self, user_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=LogList) + + + def list_memberships( + self, + user_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None ) -> MembershipList: """ Get the user membership list by its unique ID. @@ -788,8 +936,8 @@ def list_memberships(self, user_id: str, queries: Optional[List[str]] = None, se Returns ------- - Dict[str, Any] - API response as a dictionary + MembershipList + API response as a typed Pydantic model Raises ------ @@ -802,19 +950,25 @@ def list_memberships(self, user_id: str, queries: Optional[List[str]] = None, se if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if search is not None: - api_params['search'] = search + api_params['search'] = self._normalize_value(search) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_mfa(self, user_id: str, mfa: bool) -> Dict[str, Any]: + return self._parse_response(response, model=MembershipList) + + + def update_mfa( + self, + user_id: str, + mfa: bool ) -> User: """ Enable or disable MFA on a user account. @@ -827,8 +981,8 @@ def update_mfa(self, user_id: str, mfa: bool) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -844,15 +998,21 @@ def update_mfa(self, user_id: str, mfa: bool) -> Dict[str, Any]: if mfa is None: raise AppwriteException('Missing required parameter: "mfa"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['mfa'] = mfa + api_params['mfa'] = self._normalize_value(mfa) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_mfa_authenticator(self, user_id: str, type: AuthenticatorType) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def delete_mfa_authenticator( + self, + user_id: str, + type: AuthenticatorType ) -> Dict[str, Any]: """ Delete an authenticator app. @@ -882,15 +1042,20 @@ def delete_mfa_authenticator(self, user_id: str, type: AuthenticatorType) -> Dic if type is None: raise AppwriteException('Missing required parameter: "type"') - api_path = api_path.replace('{userId}', user_id) - api_path = api_path.replace('{type}', type) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) + api_path = api_path.replace('{type}', str(self._normalize_value(type))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def list_mfa_factors(self, user_id: str) -> Dict[str, Any]: + return response + + + def list_mfa_factors( + self, + user_id: str ) -> MfaFactors: """ List the factors available on the account to be used as a MFA challange. @@ -901,8 +1066,8 @@ def list_mfa_factors(self, user_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + MfaFactors + API response as a typed Pydantic model Raises ------ @@ -915,13 +1080,18 @@ def list_mfa_factors(self, user_id: str) -> Dict[str, Any]: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def get_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=MfaFactors) + + + def get_mfa_recovery_codes( + self, + user_id: str ) -> MfaRecoveryCodes: """ Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. @@ -932,8 +1102,8 @@ def get_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -946,13 +1116,18 @@ def get_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=MfaRecoveryCodes) + + + def update_mfa_recovery_codes( + self, + user_id: str ) -> MfaRecoveryCodes: """ Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. @@ -963,8 +1138,8 @@ def update_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -977,14 +1152,19 @@ def update_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - return self.client.call('put', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def create_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=MfaRecoveryCodes) + + + def create_mfa_recovery_codes( + self, + user_id: str ) -> MfaRecoveryCodes: """ Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. @@ -995,8 +1175,8 @@ def create_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -1009,14 +1189,20 @@ def create_mfa_recovery_codes(self, user_id: str) -> Dict[str, Any]: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def update_name(self, user_id: str, name: str) -> Dict[str, Any]: + return self._parse_response(response, model=MfaRecoveryCodes) + + + def update_name( + self, + user_id: str, + name: str ) -> User: """ Update the user name by its unique ID. @@ -1029,8 +1215,8 @@ def update_name(self, user_id: str, name: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -1046,15 +1232,21 @@ def update_name(self, user_id: str, name: str) -> Dict[str, Any]: if name is None: raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def update_password(self, user_id: str, password: str) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def update_password( + self, + user_id: str, + password: str ) -> User: """ Update the user password by its unique ID. @@ -1067,8 +1259,8 @@ def update_password(self, user_id: str, password: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -1084,15 +1276,21 @@ def update_password(self, user_id: str, password: str) -> Dict[str, Any]: if password is None: raise AppwriteException('Missing required parameter: "password"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['password'] = password + api_params['password'] = self._normalize_value(password) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def update_phone(self, user_id: str, number: str) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def update_phone( + self, + user_id: str, + number: str ) -> User: """ Update the user phone by its unique ID. @@ -1105,8 +1303,8 @@ def update_phone(self, user_id: str, number: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -1122,15 +1320,20 @@ def update_phone(self, user_id: str, number: str) -> Dict[str, Any]: if number is None: raise AppwriteException('Missing required parameter: "number"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['number'] = number + api_params['number'] = self._normalize_value(number) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def get_prefs(self, user_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def get_prefs( + self, + user_id: str ) -> Preferences: """ Get the user preferences by its unique ID. @@ -1141,8 +1344,8 @@ def get_prefs(self, user_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Preferences + API response as a typed Pydantic model Raises ------ @@ -1155,13 +1358,19 @@ def get_prefs(self, user_id: str) -> Dict[str, Any]: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_prefs(self, user_id: str, prefs: dict) -> Dict[str, Any]: + return self._parse_response(response, model=Preferences) + + + def update_prefs( + self, + user_id: str, + prefs: Dict[str, Any] ) -> Preferences: """ Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. @@ -1169,13 +1378,13 @@ def update_prefs(self, user_id: str, prefs: dict) -> Dict[str, Any]: ---------- user_id : str User ID. - prefs : dict + prefs : Dict[str, Any] Prefs key-value JSON object. Returns ------- - Dict[str, Any] - API response as a dictionary + Preferences + API response as a typed Pydantic model Raises ------ @@ -1191,15 +1400,21 @@ def update_prefs(self, user_id: str, prefs: dict) -> Dict[str, Any]: if prefs is None: raise AppwriteException('Missing required parameter: "prefs"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['prefs'] = prefs + api_params['prefs'] = self._normalize_value(prefs) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def list_sessions(self, user_id: str, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Preferences) + + + def list_sessions( + self, + user_id: str, + total: Optional[bool] = None ) -> SessionList: """ Get the user sessions list by its unique ID. @@ -1212,8 +1427,8 @@ def list_sessions(self, user_id: str, total: Optional[bool] = None) -> Dict[str, Returns ------- - Dict[str, Any] - API response as a dictionary + SessionList + API response as a typed Pydantic model Raises ------ @@ -1226,15 +1441,20 @@ def list_sessions(self, user_id: str, total: Optional[bool] = None) -> Dict[str, if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_session(self, user_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=SessionList) + + + def create_session( + self, + user_id: str ) -> Session: """ Creates a session for a user. Returns an immediately usable session object. @@ -1247,8 +1467,8 @@ def create_session(self, user_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Session + API response as a typed Pydantic model Raises ------ @@ -1261,14 +1481,19 @@ def create_session(self, user_id: str) -> Dict[str, Any]: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def delete_sessions(self, user_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Session) + + + def delete_sessions( + self, + user_id: str ) -> Dict[str, Any]: """ Delete all user's sessions by using the user's unique ID. @@ -1293,14 +1518,20 @@ def delete_sessions(self, user_id: str) -> Dict[str, Any]: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def delete_session(self, user_id: str, session_id: str) -> Dict[str, Any]: + return response + + + def delete_session( + self, + user_id: str, + session_id: str ) -> Dict[str, Any]: """ Delete a user sessions by its unique ID. @@ -1330,15 +1561,21 @@ def delete_session(self, user_id: str, session_id: str) -> Dict[str, Any]: if session_id is None: raise AppwriteException('Missing required parameter: "session_id"') - api_path = api_path.replace('{userId}', user_id) - api_path = api_path.replace('{sessionId}', session_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) + api_path = api_path.replace('{sessionId}', str(self._normalize_value(session_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def update_status(self, user_id: str, status: bool) -> Dict[str, Any]: + return response + + + def update_status( + self, + user_id: str, + status: bool ) -> User: """ Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. @@ -1351,8 +1588,8 @@ def update_status(self, user_id: str, status: bool) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -1368,15 +1605,22 @@ def update_status(self, user_id: str, status: bool) -> Dict[str, Any]: if status is None: raise AppwriteException('Missing required parameter: "status"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['status'] = status + api_params['status'] = self._normalize_value(status) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def list_targets(self, user_id: str, queries: Optional[List[str]] = None, total: Optional[bool] = None) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def list_targets( + self, + user_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> TargetList: """ List the messaging targets that are associated with a user. @@ -1391,8 +1635,8 @@ def list_targets(self, user_id: str, queries: Optional[List[str]] = None, total: Returns ------- - Dict[str, Any] - API response as a dictionary + TargetList + API response as a typed Pydantic model Raises ------ @@ -1405,17 +1649,27 @@ def list_targets(self, user_id: str, queries: Optional[List[str]] = None, total: if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) if queries is not None: - api_params['queries'] = queries + api_params['queries'] = self._normalize_value(queries) if total is not None: - api_params['total'] = total + api_params['total'] = self._normalize_value(total) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def create_target(self, user_id: str, target_id: str, provider_type: MessagingProviderType, identifier: str, provider_id: Optional[str] = None, name: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=TargetList) + + + def create_target( + self, + user_id: str, + target_id: str, + provider_type: MessagingProviderType, + identifier: str, + provider_id: Optional[str] = None, + name: Optional[str] = None ) -> Target: """ Create a messaging target. @@ -1436,8 +1690,8 @@ def create_target(self, user_id: str, target_id: str, provider_type: MessagingPr Returns ------- - Dict[str, Any] - API response as a dictionary + Target + API response as a typed Pydantic model Raises ------ @@ -1459,21 +1713,27 @@ def create_target(self, user_id: str, target_id: str, provider_type: MessagingPr if identifier is None: raise AppwriteException('Missing required parameter: "identifier"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['targetId'] = target_id - api_params['providerType'] = provider_type - api_params['identifier'] = identifier + api_params['targetId'] = self._normalize_value(target_id) + api_params['providerType'] = self._normalize_value(provider_type) + api_params['identifier'] = self._normalize_value(identifier) if provider_id is not None: - api_params['providerId'] = provider_id + api_params['providerId'] = self._normalize_value(provider_id) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def get_target(self, user_id: str, target_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Target) + + + def get_target( + self, + user_id: str, + target_id: str ) -> Target: """ Get a user's push notification target by ID. @@ -1486,8 +1746,8 @@ def get_target(self, user_id: str, target_id: str) -> Dict[str, Any]: Returns ------- - Dict[str, Any] - API response as a dictionary + Target + API response as a typed Pydantic model Raises ------ @@ -1503,14 +1763,23 @@ def get_target(self, user_id: str, target_id: str) -> Dict[str, Any]: if target_id is None: raise AppwriteException('Missing required parameter: "target_id"') - api_path = api_path.replace('{userId}', user_id) - api_path = api_path.replace('{targetId}', target_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) + api_path = api_path.replace('{targetId}', str(self._normalize_value(target_id))) - return self.client.call('get', api_path, { + response = self.client.call('get', api_path, { }, api_params) - def update_target(self, user_id: str, target_id: str, identifier: Optional[str] = None, provider_id: Optional[str] = None, name: Optional[str] = None) -> Dict[str, Any]: + return self._parse_response(response, model=Target) + + + def update_target( + self, + user_id: str, + target_id: str, + identifier: Optional[str] = None, + provider_id: Optional[str] = None, + name: Optional[str] = None ) -> Target: """ Update a messaging target. @@ -1529,8 +1798,8 @@ def update_target(self, user_id: str, target_id: str, identifier: Optional[str] Returns ------- - Dict[str, Any] - API response as a dictionary + Target + API response as a typed Pydantic model Raises ------ @@ -1546,21 +1815,27 @@ def update_target(self, user_id: str, target_id: str, identifier: Optional[str] if target_id is None: raise AppwriteException('Missing required parameter: "target_id"') - api_path = api_path.replace('{userId}', user_id) - api_path = api_path.replace('{targetId}', target_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) + api_path = api_path.replace('{targetId}', str(self._normalize_value(target_id))) if identifier is not None: - api_params['identifier'] = identifier + api_params['identifier'] = self._normalize_value(identifier) if provider_id is not None: - api_params['providerId'] = provider_id + api_params['providerId'] = self._normalize_value(provider_id) if name is not None: - api_params['name'] = name + api_params['name'] = self._normalize_value(name) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_target(self, user_id: str, target_id: str) -> Dict[str, Any]: + return self._parse_response(response, model=Target) + + + def delete_target( + self, + user_id: str, + target_id: str ) -> Dict[str, Any]: """ Delete a messaging target. @@ -1590,15 +1865,22 @@ def delete_target(self, user_id: str, target_id: str) -> Dict[str, Any]: if target_id is None: raise AppwriteException('Missing required parameter: "target_id"') - api_path = api_path.replace('{userId}', user_id) - api_path = api_path.replace('{targetId}', target_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) + api_path = api_path.replace('{targetId}', str(self._normalize_value(target_id))) - return self.client.call('delete', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def create_token(self, user_id: str, length: Optional[float] = None, expire: Optional[float] = None) -> Dict[str, Any]: + return response + + + def create_token( + self, + user_id: str, + length: Optional[float] = None, + expire: Optional[float] = None ) -> Token: """ Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. @@ -1614,8 +1896,8 @@ def create_token(self, user_id: str, length: Optional[float] = None, expire: Opt Returns ------- - Dict[str, Any] - API response as a dictionary + Token + API response as a typed Pydantic model Raises ------ @@ -1628,18 +1910,24 @@ def create_token(self, user_id: str, length: Optional[float] = None, expire: Opt if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) if length is not None: - api_params['length'] = length + api_params['length'] = self._normalize_value(length) if expire is not None: - api_params['expire'] = expire + api_params['expire'] = self._normalize_value(expire) - return self.client.call('post', api_path, { + response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def update_email_verification(self, user_id: str, email_verification: bool) -> Dict[str, Any]: + return self._parse_response(response, model=Token) + + + def update_email_verification( + self, + user_id: str, + email_verification: bool ) -> User: """ Update the user email verification status by its unique ID. @@ -1652,8 +1940,8 @@ def update_email_verification(self, user_id: str, email_verification: bool) -> D Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -1669,15 +1957,21 @@ def update_email_verification(self, user_id: str, email_verification: bool) -> D if email_verification is None: raise AppwriteException('Missing required parameter: "email_verification"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['emailVerification'] = email_verification + api_params['emailVerification'] = self._normalize_value(email_verification) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def update_phone_verification(self, user_id: str, phone_verification: bool) -> Dict[str, Any]: + return self._parse_response(response, model=User) + + + def update_phone_verification( + self, + user_id: str, + phone_verification: bool ) -> User: """ Update the user phone verification status by its unique ID. @@ -1690,8 +1984,8 @@ def update_phone_verification(self, user_id: str, phone_verification: bool) -> D Returns ------- - Dict[str, Any] - API response as a dictionary + User + API response as a typed Pydantic model Raises ------ @@ -1707,10 +2001,13 @@ def update_phone_verification(self, user_id: str, phone_verification: bool) -> D if phone_verification is None: raise AppwriteException('Missing required parameter: "phone_verification"') - api_path = api_path.replace('{userId}', user_id) + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) - api_params['phoneVerification'] = phone_verification + api_params['phoneVerification'] = self._normalize_value(phone_verification) - return self.client.call('patch', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) + + return self._parse_response(response, model=User) + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7e7c7b4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,40 @@ +[build-system] +requires = ["setuptools>=61"] +build-backend = "setuptools.build_meta" + +[project] +name = "appwrite" +version = "15.3.0" +description = "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API" +readme = "README.md" +requires-python = ">=3.9" +license = { text = "BSD-3-Clause" } +authors = [ + { name = "Appwrite Team", email = "team@appwrite.io" } +] +maintainers = [ + { name = "Appwrite Team", email = "team@appwrite.io" } +] +dependencies = [ + "requests", + "pydantic>=2,<3", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Environment :: Web Environment", + "Topic :: Software Development", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] + +[project.urls] +Homepage = "https://appwrite.io/support" +Repository = "https://github.com/appwrite/sdk-for-python" + +[tool.setuptools.packages.find] +include = ["appwrite*"] diff --git a/requirements.txt b/requirements.txt index 2c24336..71762bc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -requests==2.31.0 +requests>=2.31,<3 +pydantic>=2,<3 diff --git a/setup.py b/setup.py index 8446427..ae0fa09 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,9 @@ download_url='https://github.com/appwrite/sdk-for-python/archive/15.3.0.tar.gz', install_requires=[ 'requests', + 'pydantic>=2,<3', ], + python_requires='>=3.9', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -29,9 +31,9 @@ 'Topic :: Software Development', 'License :: OSI Approved :: BSD License', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ], ) From b3f00151e91c548526cdacbeaeec0941bcfe60a5 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 7 Mar 2026 04:03:55 +0000 Subject: [PATCH 2/6] chore: update Python SDK to 16.0.0 --- CHANGELOG.md | 15 +++++++++++---- README.md | 16 +++++++++++++--- appwrite/client.py | 4 ++-- pyproject.toml | 2 +- setup.py | 4 ++-- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb17fd8..11776ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,16 @@ # Change Log -## 15.3.0 - -* Added `ActivityEvent` and `ActivityEventList` models to the public API -* Updated README with `uv add appwrite` example +## 16.0.0 + +* Breaking change: All service methods now return typed Pydantic models instead of `Dict[str, Any]` +* Breaking change: Added `pydantic>=2,<3` as a required dependency +* Breaking change: Minimum Python version raised from 3.5 to 3.9 +* Added `AppwriteModel` base class (Pydantic `BaseModel`) for all response models with `from_dict()` and `to_dict()` helpers +* Added 130+ typed model classes under `appwrite/models/` (e.g., `Database`, `Collection`, `Document`, `User`, `Session`, `File`, `Bucket`, etc.) +* Added `ActivityEvent` and `ActivityEventList` models and `Activities` service +* Added `ValueClassEncoder` support for serializing `AppwriteModel` instances +* Added `pyproject.toml` for modern Python packaging +* Updated README with `uv add appwrite` installation example ## 15.2.0 diff --git a/README.md b/README.md index b221018..ed749b5 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,16 @@ client = Client() ### Make Your First Request Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section. +All service methods return typed Pydantic models, so you can access response fields as attributes: + ```python users = Users(client) -result = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") +user = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") + +print(user.name) # "Walter O'Brien" +print(user.email) # "email@example.com" +print(user.id) # The generated user ID ``` ### Full Example @@ -72,7 +78,10 @@ client = Client() users = Users(client) -result = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") +user = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") + +print(user.name) # Access fields as attributes +print(user.to_dict()) # Convert to dictionary if needed ``` ### Error Handling @@ -81,7 +90,8 @@ The Appwrite Python SDK raises `AppwriteException` object with `message`, `code` ```python users = Users(client) try: - result = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") + user = users.create(ID.unique(), email = "email@example.com", phone = "+123456789", password = "password", name = "Walter O'Brien") + print(user.name) except AppwriteException as e: print(e.message) ``` diff --git a/appwrite/client.py b/appwrite/client.py index 57a7bd0..ce32bff 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -15,11 +15,11 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : f'AppwritePythonSDK/15.3.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/16.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '15.3.0', + 'x-sdk-version': '16.0.0', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/pyproject.toml b/pyproject.toml index 7e7c7b4..032beff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "appwrite" -version = "15.3.0" +version = "16.0.0" description = "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API" readme = "README.md" requires-python = ">=3.9" diff --git a/setup.py b/setup.py index ae0fa09..6c70757 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name = 'appwrite', packages = setuptools.find_packages(), - version = '15.3.0', + version = '16.0.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -18,7 +18,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/15.3.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/16.0.0.tar.gz', install_requires=[ 'requests', 'pydantic>=2,<3', From 97ff4ec1ee2cf7ba7ca3e907e953eb754c701560 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 7 Mar 2026 04:14:31 +0000 Subject: [PATCH 3/6] chore: update Python SDK to 16.0.0 --- CHANGELOG.md | 1 + docs/examples/account/create-anonymous-session.md | 5 ++++- .../account/create-email-password-session.md | 5 ++++- docs/examples/account/create-email-token.md | 5 ++++- docs/examples/account/create-email-verification.md | 5 ++++- docs/examples/account/create-jwt.md | 5 ++++- docs/examples/account/create-magic-url-token.md | 5 ++++- docs/examples/account/create-mfa-authenticator.md | 5 ++++- docs/examples/account/create-mfa-challenge.md | 5 ++++- docs/examples/account/create-mfa-recovery-codes.md | 5 ++++- docs/examples/account/create-o-auth-2-token.md | 2 +- docs/examples/account/create-phone-token.md | 5 ++++- docs/examples/account/create-phone-verification.md | 5 ++++- docs/examples/account/create-recovery.md | 5 ++++- docs/examples/account/create-session.md | 5 ++++- docs/examples/account/create-verification.md | 5 ++++- docs/examples/account/create.md | 5 ++++- docs/examples/account/get-mfa-recovery-codes.md | 5 ++++- docs/examples/account/get-prefs.md | 5 ++++- docs/examples/account/get-session.md | 5 ++++- docs/examples/account/get.md | 5 ++++- docs/examples/account/list-identities.md | 5 ++++- docs/examples/account/list-logs.md | 5 ++++- docs/examples/account/list-mfa-factors.md | 5 ++++- docs/examples/account/list-sessions.md | 5 ++++- docs/examples/account/update-email-verification.md | 5 ++++- docs/examples/account/update-email.md | 5 ++++- docs/examples/account/update-magic-url-session.md | 5 ++++- docs/examples/account/update-mfa-authenticator.md | 5 ++++- docs/examples/account/update-mfa-challenge.md | 5 ++++- docs/examples/account/update-mfa-recovery-codes.md | 5 ++++- docs/examples/account/update-mfa.md | 5 ++++- docs/examples/account/update-name.md | 5 ++++- docs/examples/account/update-password.md | 5 ++++- docs/examples/account/update-phone-session.md | 5 ++++- docs/examples/account/update-phone-verification.md | 5 ++++- docs/examples/account/update-phone.md | 5 ++++- docs/examples/account/update-prefs.md | 5 ++++- docs/examples/account/update-recovery.md | 5 ++++- docs/examples/account/update-session.md | 5 ++++- docs/examples/account/update-status.md | 5 ++++- docs/examples/account/update-verification.md | 5 ++++- docs/examples/activities/get-event.md | 5 ++++- docs/examples/activities/list-events.md | 5 ++++- docs/examples/avatars/get-browser.md | 2 +- docs/examples/avatars/get-credit-card.md | 2 +- docs/examples/avatars/get-favicon.md | 2 +- docs/examples/avatars/get-flag.md | 2 +- docs/examples/avatars/get-image.md | 2 +- docs/examples/avatars/get-initials.md | 2 +- docs/examples/avatars/get-qr.md | 2 +- docs/examples/avatars/get-screenshot.md | 2 +- docs/examples/backups/create-archive.md | 5 ++++- docs/examples/backups/create-policy.md | 5 ++++- docs/examples/backups/create-restoration.md | 5 ++++- docs/examples/backups/get-archive.md | 5 ++++- docs/examples/backups/get-policy.md | 5 ++++- docs/examples/backups/get-restoration.md | 5 ++++- docs/examples/backups/list-archives.md | 5 ++++- docs/examples/backups/list-policies.md | 5 ++++- docs/examples/backups/list-restorations.md | 5 ++++- docs/examples/backups/update-policy.md | 5 ++++- .../examples/databases/create-boolean-attribute.md | 5 ++++- docs/examples/databases/create-collection.md | 5 ++++- .../databases/create-datetime-attribute.md | 5 ++++- docs/examples/databases/create-document.md | 5 ++++- docs/examples/databases/create-documents.md | 5 ++++- docs/examples/databases/create-email-attribute.md | 5 ++++- docs/examples/databases/create-enum-attribute.md | 5 ++++- docs/examples/databases/create-float-attribute.md | 5 ++++- docs/examples/databases/create-index.md | 5 ++++- .../examples/databases/create-integer-attribute.md | 5 ++++- docs/examples/databases/create-ip-attribute.md | 5 ++++- docs/examples/databases/create-line-attribute.md | 5 ++++- .../databases/create-longtext-attribute.md | 5 ++++- .../databases/create-mediumtext-attribute.md | 5 ++++- docs/examples/databases/create-operations.md | 5 ++++- docs/examples/databases/create-point-attribute.md | 5 ++++- .../examples/databases/create-polygon-attribute.md | 5 ++++- .../databases/create-relationship-attribute.md | 5 ++++- docs/examples/databases/create-string-attribute.md | 5 ++++- docs/examples/databases/create-text-attribute.md | 5 ++++- docs/examples/databases/create-transaction.md | 5 ++++- docs/examples/databases/create-url-attribute.md | 5 ++++- .../examples/databases/create-varchar-attribute.md | 5 ++++- docs/examples/databases/create.md | 5 ++++- .../databases/decrement-document-attribute.md | 5 ++++- docs/examples/databases/delete-documents.md | 5 ++++- docs/examples/databases/get-attribute.md | 14 +++++++++++++- docs/examples/databases/get-collection.md | 5 ++++- docs/examples/databases/get-document.md | 5 ++++- docs/examples/databases/get-index.md | 5 ++++- docs/examples/databases/get-transaction.md | 5 ++++- docs/examples/databases/get.md | 5 ++++- .../databases/increment-document-attribute.md | 5 ++++- docs/examples/databases/list-attributes.md | 5 ++++- docs/examples/databases/list-collections.md | 5 ++++- docs/examples/databases/list-documents.md | 5 ++++- docs/examples/databases/list-indexes.md | 5 ++++- docs/examples/databases/list-transactions.md | 5 ++++- docs/examples/databases/list.md | 5 ++++- .../examples/databases/update-boolean-attribute.md | 5 ++++- docs/examples/databases/update-collection.md | 5 ++++- .../databases/update-datetime-attribute.md | 5 ++++- docs/examples/databases/update-document.md | 5 ++++- docs/examples/databases/update-documents.md | 5 ++++- docs/examples/databases/update-email-attribute.md | 5 ++++- docs/examples/databases/update-enum-attribute.md | 5 ++++- docs/examples/databases/update-float-attribute.md | 5 ++++- .../examples/databases/update-integer-attribute.md | 5 ++++- docs/examples/databases/update-ip-attribute.md | 5 ++++- docs/examples/databases/update-line-attribute.md | 5 ++++- .../databases/update-longtext-attribute.md | 5 ++++- .../databases/update-mediumtext-attribute.md | 5 ++++- docs/examples/databases/update-point-attribute.md | 5 ++++- .../examples/databases/update-polygon-attribute.md | 5 ++++- .../databases/update-relationship-attribute.md | 5 ++++- docs/examples/databases/update-string-attribute.md | 5 ++++- docs/examples/databases/update-text-attribute.md | 5 ++++- docs/examples/databases/update-transaction.md | 5 ++++- docs/examples/databases/update-url-attribute.md | 5 ++++- .../examples/databases/update-varchar-attribute.md | 5 ++++- docs/examples/databases/update.md | 5 ++++- docs/examples/databases/upsert-document.md | 5 ++++- docs/examples/databases/upsert-documents.md | 5 ++++- docs/examples/functions/create-deployment.md | 5 ++++- .../functions/create-duplicate-deployment.md | 5 ++++- docs/examples/functions/create-execution.md | 5 ++++- .../functions/create-template-deployment.md | 5 ++++- docs/examples/functions/create-variable.md | 5 ++++- docs/examples/functions/create-vcs-deployment.md | 5 ++++- docs/examples/functions/create.md | 5 ++++- docs/examples/functions/get-deployment-download.md | 2 +- docs/examples/functions/get-deployment.md | 5 ++++- docs/examples/functions/get-execution.md | 5 ++++- docs/examples/functions/get-variable.md | 5 ++++- docs/examples/functions/get.md | 5 ++++- docs/examples/functions/list-deployments.md | 5 ++++- docs/examples/functions/list-executions.md | 5 ++++- docs/examples/functions/list-runtimes.md | 5 ++++- docs/examples/functions/list-specifications.md | 5 ++++- docs/examples/functions/list-variables.md | 5 ++++- docs/examples/functions/list.md | 5 ++++- .../examples/functions/update-deployment-status.md | 5 ++++- .../functions/update-function-deployment.md | 5 ++++- docs/examples/functions/update-variable.md | 5 ++++- docs/examples/functions/update.md | 5 ++++- docs/examples/health/get-antivirus.md | 5 ++++- docs/examples/health/get-cache.md | 5 ++++- docs/examples/health/get-certificate.md | 5 ++++- docs/examples/health/get-console-pausing.md | 5 ++++- docs/examples/health/get-db.md | 5 ++++- docs/examples/health/get-failed-jobs.md | 5 ++++- docs/examples/health/get-pub-sub.md | 5 ++++- docs/examples/health/get-queue-audits.md | 5 ++++- docs/examples/health/get-queue-builds.md | 5 ++++- docs/examples/health/get-queue-certificates.md | 5 ++++- docs/examples/health/get-queue-databases.md | 5 ++++- docs/examples/health/get-queue-deletes.md | 5 ++++- docs/examples/health/get-queue-functions.md | 5 ++++- docs/examples/health/get-queue-logs.md | 5 ++++- docs/examples/health/get-queue-mails.md | 5 ++++- docs/examples/health/get-queue-messaging.md | 5 ++++- docs/examples/health/get-queue-migrations.md | 5 ++++- docs/examples/health/get-queue-stats-resources.md | 5 ++++- docs/examples/health/get-queue-usage.md | 5 ++++- docs/examples/health/get-queue-webhooks.md | 5 ++++- docs/examples/health/get-storage-local.md | 5 ++++- docs/examples/health/get-storage.md | 5 ++++- docs/examples/health/get-time.md | 5 ++++- docs/examples/health/get.md | 5 ++++- docs/examples/locale/get.md | 5 ++++- docs/examples/locale/list-codes.md | 5 ++++- docs/examples/locale/list-continents.md | 5 ++++- docs/examples/locale/list-countries-eu.md | 5 ++++- docs/examples/locale/list-countries-phones.md | 5 ++++- docs/examples/locale/list-countries.md | 5 ++++- docs/examples/locale/list-currencies.md | 5 ++++- docs/examples/locale/list-languages.md | 5 ++++- docs/examples/messaging/create-apns-provider.md | 5 ++++- docs/examples/messaging/create-email.md | 5 ++++- docs/examples/messaging/create-fcm-provider.md | 5 ++++- docs/examples/messaging/create-mailgun-provider.md | 5 ++++- docs/examples/messaging/create-msg-91-provider.md | 5 ++++- docs/examples/messaging/create-push.md | 5 ++++- docs/examples/messaging/create-resend-provider.md | 5 ++++- .../examples/messaging/create-sendgrid-provider.md | 5 ++++- docs/examples/messaging/create-sms.md | 5 ++++- docs/examples/messaging/create-smtp-provider.md | 5 ++++- docs/examples/messaging/create-subscriber.md | 5 ++++- .../examples/messaging/create-telesign-provider.md | 5 ++++- .../messaging/create-textmagic-provider.md | 5 ++++- docs/examples/messaging/create-topic.md | 5 ++++- docs/examples/messaging/create-twilio-provider.md | 5 ++++- docs/examples/messaging/create-vonage-provider.md | 5 ++++- docs/examples/messaging/get-message.md | 5 ++++- docs/examples/messaging/get-provider.md | 5 ++++- docs/examples/messaging/get-subscriber.md | 5 ++++- docs/examples/messaging/get-topic.md | 5 ++++- docs/examples/messaging/list-message-logs.md | 5 ++++- docs/examples/messaging/list-messages.md | 5 ++++- docs/examples/messaging/list-provider-logs.md | 5 ++++- docs/examples/messaging/list-providers.md | 5 ++++- docs/examples/messaging/list-subscriber-logs.md | 5 ++++- docs/examples/messaging/list-subscribers.md | 5 ++++- docs/examples/messaging/list-targets.md | 5 ++++- docs/examples/messaging/list-topic-logs.md | 5 ++++- docs/examples/messaging/list-topics.md | 5 ++++- docs/examples/messaging/update-apns-provider.md | 5 ++++- docs/examples/messaging/update-email.md | 5 ++++- docs/examples/messaging/update-fcm-provider.md | 5 ++++- docs/examples/messaging/update-mailgun-provider.md | 5 ++++- docs/examples/messaging/update-msg-91-provider.md | 5 ++++- docs/examples/messaging/update-push.md | 5 ++++- docs/examples/messaging/update-resend-provider.md | 5 ++++- .../examples/messaging/update-sendgrid-provider.md | 5 ++++- docs/examples/messaging/update-sms.md | 5 ++++- docs/examples/messaging/update-smtp-provider.md | 5 ++++- .../examples/messaging/update-telesign-provider.md | 5 ++++- .../messaging/update-textmagic-provider.md | 5 ++++- docs/examples/messaging/update-topic.md | 5 ++++- docs/examples/messaging/update-twilio-provider.md | 5 ++++- docs/examples/messaging/update-vonage-provider.md | 5 ++++- docs/examples/sites/create-deployment.md | 5 ++++- docs/examples/sites/create-duplicate-deployment.md | 5 ++++- docs/examples/sites/create-template-deployment.md | 5 ++++- docs/examples/sites/create-variable.md | 5 ++++- docs/examples/sites/create-vcs-deployment.md | 5 ++++- docs/examples/sites/create.md | 5 ++++- docs/examples/sites/get-deployment-download.md | 2 +- docs/examples/sites/get-deployment.md | 5 ++++- docs/examples/sites/get-log.md | 5 ++++- docs/examples/sites/get-variable.md | 5 ++++- docs/examples/sites/get.md | 5 ++++- docs/examples/sites/list-deployments.md | 5 ++++- docs/examples/sites/list-frameworks.md | 5 ++++- docs/examples/sites/list-logs.md | 5 ++++- docs/examples/sites/list-specifications.md | 5 ++++- docs/examples/sites/list-variables.md | 5 ++++- docs/examples/sites/list.md | 5 ++++- docs/examples/sites/update-deployment-status.md | 5 ++++- docs/examples/sites/update-site-deployment.md | 5 ++++- docs/examples/sites/update-variable.md | 5 ++++- docs/examples/sites/update.md | 5 ++++- docs/examples/storage/create-bucket.md | 5 ++++- docs/examples/storage/create-file.md | 5 ++++- docs/examples/storage/get-bucket.md | 5 ++++- docs/examples/storage/get-file-download.md | 2 +- docs/examples/storage/get-file-preview.md | 2 +- docs/examples/storage/get-file-view.md | 2 +- docs/examples/storage/get-file.md | 5 ++++- docs/examples/storage/list-buckets.md | 5 ++++- docs/examples/storage/list-files.md | 5 ++++- docs/examples/storage/update-bucket.md | 5 ++++- docs/examples/storage/update-file.md | 5 ++++- docs/examples/tablesdb/create-boolean-column.md | 5 ++++- docs/examples/tablesdb/create-datetime-column.md | 5 ++++- docs/examples/tablesdb/create-email-column.md | 5 ++++- docs/examples/tablesdb/create-enum-column.md | 5 ++++- docs/examples/tablesdb/create-float-column.md | 5 ++++- docs/examples/tablesdb/create-index.md | 5 ++++- docs/examples/tablesdb/create-integer-column.md | 5 ++++- docs/examples/tablesdb/create-ip-column.md | 5 ++++- docs/examples/tablesdb/create-line-column.md | 5 ++++- docs/examples/tablesdb/create-longtext-column.md | 5 ++++- docs/examples/tablesdb/create-mediumtext-column.md | 5 ++++- docs/examples/tablesdb/create-operations.md | 5 ++++- docs/examples/tablesdb/create-point-column.md | 5 ++++- docs/examples/tablesdb/create-polygon-column.md | 5 ++++- .../tablesdb/create-relationship-column.md | 5 ++++- docs/examples/tablesdb/create-row.md | 5 ++++- docs/examples/tablesdb/create-rows.md | 5 ++++- docs/examples/tablesdb/create-string-column.md | 5 ++++- docs/examples/tablesdb/create-table.md | 5 ++++- docs/examples/tablesdb/create-text-column.md | 5 ++++- docs/examples/tablesdb/create-transaction.md | 5 ++++- docs/examples/tablesdb/create-url-column.md | 5 ++++- docs/examples/tablesdb/create-varchar-column.md | 5 ++++- docs/examples/tablesdb/create.md | 5 ++++- docs/examples/tablesdb/decrement-row-column.md | 5 ++++- docs/examples/tablesdb/delete-rows.md | 5 ++++- docs/examples/tablesdb/get-column.md | 14 +++++++++++++- docs/examples/tablesdb/get-index.md | 5 ++++- docs/examples/tablesdb/get-row.md | 5 ++++- docs/examples/tablesdb/get-table.md | 5 ++++- docs/examples/tablesdb/get-transaction.md | 5 ++++- docs/examples/tablesdb/get.md | 5 ++++- docs/examples/tablesdb/increment-row-column.md | 5 ++++- docs/examples/tablesdb/list-columns.md | 5 ++++- docs/examples/tablesdb/list-indexes.md | 5 ++++- docs/examples/tablesdb/list-rows.md | 5 ++++- docs/examples/tablesdb/list-tables.md | 5 ++++- docs/examples/tablesdb/list-transactions.md | 5 ++++- docs/examples/tablesdb/list.md | 5 ++++- docs/examples/tablesdb/update-boolean-column.md | 5 ++++- docs/examples/tablesdb/update-datetime-column.md | 5 ++++- docs/examples/tablesdb/update-email-column.md | 5 ++++- docs/examples/tablesdb/update-enum-column.md | 5 ++++- docs/examples/tablesdb/update-float-column.md | 5 ++++- docs/examples/tablesdb/update-integer-column.md | 5 ++++- docs/examples/tablesdb/update-ip-column.md | 5 ++++- docs/examples/tablesdb/update-line-column.md | 5 ++++- docs/examples/tablesdb/update-longtext-column.md | 5 ++++- docs/examples/tablesdb/update-mediumtext-column.md | 5 ++++- docs/examples/tablesdb/update-point-column.md | 5 ++++- docs/examples/tablesdb/update-polygon-column.md | 5 ++++- .../tablesdb/update-relationship-column.md | 5 ++++- docs/examples/tablesdb/update-row.md | 5 ++++- docs/examples/tablesdb/update-rows.md | 5 ++++- docs/examples/tablesdb/update-string-column.md | 5 ++++- docs/examples/tablesdb/update-table.md | 5 ++++- docs/examples/tablesdb/update-text-column.md | 5 ++++- docs/examples/tablesdb/update-transaction.md | 5 ++++- docs/examples/tablesdb/update-url-column.md | 5 ++++- docs/examples/tablesdb/update-varchar-column.md | 5 ++++- docs/examples/tablesdb/update.md | 5 ++++- docs/examples/tablesdb/upsert-row.md | 5 ++++- docs/examples/tablesdb/upsert-rows.md | 5 ++++- docs/examples/teams/create-membership.md | 5 ++++- docs/examples/teams/create.md | 5 ++++- docs/examples/teams/get-membership.md | 5 ++++- docs/examples/teams/get-prefs.md | 5 ++++- docs/examples/teams/get.md | 5 ++++- docs/examples/teams/list-memberships.md | 5 ++++- docs/examples/teams/list.md | 5 ++++- docs/examples/teams/update-membership-status.md | 5 ++++- docs/examples/teams/update-membership.md | 5 ++++- docs/examples/teams/update-name.md | 5 ++++- docs/examples/teams/update-prefs.md | 5 ++++- docs/examples/tokens/create-file-token.md | 5 ++++- docs/examples/tokens/get.md | 5 ++++- docs/examples/tokens/list.md | 5 ++++- docs/examples/tokens/update.md | 5 ++++- docs/examples/users/create-argon-2-user.md | 5 ++++- docs/examples/users/create-bcrypt-user.md | 5 ++++- docs/examples/users/create-jwt.md | 5 ++++- docs/examples/users/create-md-5-user.md | 5 ++++- docs/examples/users/create-mfa-recovery-codes.md | 5 ++++- docs/examples/users/create-ph-pass-user.md | 5 ++++- docs/examples/users/create-scrypt-modified-user.md | 5 ++++- docs/examples/users/create-scrypt-user.md | 5 ++++- docs/examples/users/create-session.md | 5 ++++- docs/examples/users/create-sha-user.md | 5 ++++- docs/examples/users/create-target.md | 5 ++++- docs/examples/users/create-token.md | 5 ++++- docs/examples/users/create.md | 5 ++++- docs/examples/users/get-mfa-recovery-codes.md | 5 ++++- docs/examples/users/get-prefs.md | 5 ++++- docs/examples/users/get-target.md | 5 ++++- docs/examples/users/get.md | 5 ++++- docs/examples/users/list-identities.md | 5 ++++- docs/examples/users/list-logs.md | 5 ++++- docs/examples/users/list-memberships.md | 5 ++++- docs/examples/users/list-mfa-factors.md | 5 ++++- docs/examples/users/list-sessions.md | 5 ++++- docs/examples/users/list-targets.md | 5 ++++- docs/examples/users/list.md | 5 ++++- docs/examples/users/update-email-verification.md | 5 ++++- docs/examples/users/update-email.md | 5 ++++- docs/examples/users/update-labels.md | 5 ++++- docs/examples/users/update-mfa-recovery-codes.md | 5 ++++- docs/examples/users/update-mfa.md | 5 ++++- docs/examples/users/update-name.md | 5 ++++- docs/examples/users/update-password.md | 5 ++++- docs/examples/users/update-phone-verification.md | 5 ++++- docs/examples/users/update-phone.md | 5 ++++- docs/examples/users/update-prefs.md | 5 ++++- docs/examples/users/update-status.md | 5 ++++- docs/examples/users/update-target.md | 5 ++++- 369 files changed, 1449 insertions(+), 368 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11776ba..bcea0fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * Added `ValueClassEncoder` support for serializing `AppwriteModel` instances * Added `pyproject.toml` for modern Python packaging * Updated README with `uv add appwrite` installation example +* Updated all doc examples to use typed response models (e.g., `result: TemplateFunctionList = functions.list_templates(...)`) ## 15.2.0 diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md index bf0aeab..70a7dd3 100644 --- a/docs/examples/account/create-anonymous-session.md +++ b/docs/examples/account/create-anonymous-session.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Session client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_anonymous_session() +result: Session = account.create_anonymous_session() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index 5849f02..292074d 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Session client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_email_password_session( +result: Session = account.create_email_password_session( email = 'email@example.com', password = 'password' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md index 4c78322..78c5eca 100644 --- a/docs/examples/account/create-email-token.md +++ b/docs/examples/account/create-email-token.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_email_token( +result: Token = account.create_email_token( user_id = '', email = 'email@example.com', phrase = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-email-verification.md b/docs/examples/account/create-email-verification.md index 87b1e5b..d4d8fd8 100644 --- a/docs/examples/account/create-email-verification.md +++ b/docs/examples/account/create-email-verification.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_email_verification( +result: Token = account.create_email_verification( url = 'https://example.com' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index d4c6d35..a28c65f 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Jwt client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_jwt( +result: Jwt = account.create_jwt( duration = 0 # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-magic-url-token.md b/docs/examples/account/create-magic-url-token.md index f3a1670..5ded012 100644 --- a/docs/examples/account/create-magic-url-token.md +++ b/docs/examples/account/create-magic-url-token.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_magic_url_token( +result: Token = account.create_magic_url_token( user_id = '', email = 'email@example.com', url = 'https://example.com', # optional phrase = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index 784d2af..468011b 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import MfaType from appwrite.enums import AuthenticatorType client = Client() @@ -10,7 +11,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_mfa_authenticator( +result: MfaType = account.create_mfa_authenticator( type = AuthenticatorType.TOTP ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index 712b7e2..f31797a 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import MfaChallenge from appwrite.enums import AuthenticationFactor client = Client() @@ -10,7 +11,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_mfa_challenge( +result: MfaChallenge = account.create_mfa_challenge( factor = AuthenticationFactor.EMAIL ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index 2511cfb..b7a2c4d 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import MfaRecoveryCodes client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_mfa_recovery_codes() +result: MfaRecoveryCodes = account.create_mfa_recovery_codes() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 4ffa9ff..87f7de0 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -10,7 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_o_auth2_token( +result: str = account.create_o_auth2_token( provider = OAuthProvider.AMAZON, success = 'https://example.com', # optional failure = 'https://example.com', # optional diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md index c30cbf9..fb09d64 100644 --- a/docs/examples/account/create-phone-token.md +++ b/docs/examples/account/create-phone-token.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_phone_token( +result: Token = account.create_phone_token( user_id = '', phone = '+12065550100' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md index 50db6a9..35d058e 100644 --- a/docs/examples/account/create-phone-verification.md +++ b/docs/examples/account/create-phone-verification.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_phone_verification() +result: Token = account.create_phone_verification() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index ecf596c..ea63672 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_recovery( +result: Token = account.create_recovery( email = 'email@example.com', url = 'https://example.com' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md index 27f0733..b09cf72 100644 --- a/docs/examples/account/create-session.md +++ b/docs/examples/account/create-session.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Session client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_session( +result: Session = account.create_session( user_id = '', secret = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index 3330c23..c44a769 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_verification( +result: Token = account.create_verification( url = 'https://example.com' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index 1781c23..87c8fab 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create( +result: User = account.create( user_id = '', email = 'email@example.com', password = '', name = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index bec99a1..f236eb6 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import MfaRecoveryCodes client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.get_mfa_recovery_codes() +result: MfaRecoveryCodes = account.get_mfa_recovery_codes() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index 35603f2..db58615 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Preferences client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.get_prefs() +result: Preferences = account.get_prefs() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index f978dfc..9a247b2 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Session client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.get_session( +result: Session = account.get_session( session_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index 2ec458f..c06fd6b 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.get() +result: User = account.get() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index 8ba8625..5b8496d 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import IdentityList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.list_identities( +result: IdentityList = account.list_identities( queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 8f40638..3f0a3b5 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import LogList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.list_logs( +result: LogList = account.list_logs( queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index 9558fa1..411a3e9 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import MfaFactors client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.list_mfa_factors() +result: MfaFactors = account.list_mfa_factors() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 8603dc9..d9df7a7 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import SessionList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.list_sessions() +result: SessionList = account.list_sessions() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-email-verification.md b/docs/examples/account/update-email-verification.md index 51f0f48..5415f7d 100644 --- a/docs/examples/account/update-email-verification.md +++ b/docs/examples/account/update-email-verification.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_email_verification( +result: Token = account.update_email_verification( user_id = '', secret = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index 4b9f530..d559e02 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_email( +result: User = account.update_email( email = 'email@example.com', password = 'password' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-magic-url-session.md b/docs/examples/account/update-magic-url-session.md index 777c5d8..754bbcd 100644 --- a/docs/examples/account/update-magic-url-session.md +++ b/docs/examples/account/update-magic-url-session.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Session client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_magic_url_session( +result: Session = account.update_magic_url_session( user_id = '', secret = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index 9fc0f8e..e7040b0 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User from appwrite.enums import AuthenticatorType client = Client() @@ -10,8 +11,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_mfa_authenticator( +result: User = account.update_mfa_authenticator( type = AuthenticatorType.TOTP, otp = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index 2da910b..40d6382 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Session client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_mfa_challenge( +result: Session = account.update_mfa_challenge( challenge_id = '', otp = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index 2b74e1d..38ff568 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import MfaRecoveryCodes client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_mfa_recovery_codes() +result: MfaRecoveryCodes = account.update_mfa_recovery_codes() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-mfa.md b/docs/examples/account/update-mfa.md index 43e4077..607cea7 100644 --- a/docs/examples/account/update-mfa.md +++ b/docs/examples/account/update-mfa.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_mfa( +result: User = account.update_mfa( mfa = False ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index d5b5df3..d16c8dd 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_name( +result: User = account.update_name( name = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index aa09dbe..dc504e2 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_password( +result: User = account.update_password( password = '', old_password = 'password' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md index 7fd599a..300cadd 100644 --- a/docs/examples/account/update-phone-session.md +++ b/docs/examples/account/update-phone-session.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Session client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_phone_session( +result: Session = account.update_phone_session( user_id = '', secret = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index 1fa74a8..9091264 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_phone_verification( +result: Token = account.update_phone_verification( user_id = '', secret = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index 212bb2d..6dcd811 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_phone( +result: User = account.update_phone( phone = '+12065550100', password = 'password' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 0aa3fa9..1c6a0a5 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_prefs( +result: User = account.update_prefs( prefs = { "language": "en", "timezone": "UTC", "darkTheme": True } ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 8c14a3a..90ed309 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_recovery( +result: Token = account.update_recovery( user_id = '', secret = '', password = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index 2b3082d..6232e0b 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Session client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_session( +result: Session = account.update_session( session_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md index baf4961..d480145 100644 --- a/docs/examples/account/update-status.md +++ b/docs/examples/account/update-status.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import User client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_status() +result: User = account.update_status() + +print(result.model_dump()) ``` diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 9e49718..5dffe6a 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.account import Account +from appwrite.models import Token client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.update_verification( +result: Token = account.update_verification( user_id = '', secret = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/activities/get-event.md b/docs/examples/activities/get-event.md index 353d9d5..1281903 100644 --- a/docs/examples/activities/get-event.md +++ b/docs/examples/activities/get-event.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.activities import Activities +from appwrite.models import ActivityEvent client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key activities = Activities(client) -result = activities.get_event( +result: ActivityEvent = activities.get_event( event_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md index 2c7c92d..bbeb644 100644 --- a/docs/examples/activities/list-events.md +++ b/docs/examples/activities/list-events.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.activities import Activities +from appwrite.models import ActivityEventList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key activities = Activities(client) -result = activities.list_events( +result: ActivityEventList = activities.list_events( queries = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 4e5b7a1..3c950db 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -10,7 +10,7 @@ client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_browser( +result: bytes = avatars.get_browser( code = Browser.AVANT_BROWSER, width = 0, # optional height = 0, # optional diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index 5872915..8ef04f6 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -10,7 +10,7 @@ client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_credit_card( +result: bytes = avatars.get_credit_card( code = CreditCard.AMERICAN_EXPRESS, width = 0, # optional height = 0, # optional diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index b201146..dd234ea 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -9,7 +9,7 @@ client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_favicon( +result: bytes = avatars.get_favicon( url = 'https://example.com' ) ``` diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index 2bd0776..f97b20d 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -10,7 +10,7 @@ client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_flag( +result: bytes = avatars.get_flag( code = Flag.AFGHANISTAN, width = 0, # optional height = 0, # optional diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index fa013f1..9beea03 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -9,7 +9,7 @@ client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_image( +result: bytes = avatars.get_image( url = 'https://example.com', width = 0, # optional height = 0 # optional diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 2dff22a..30a39a8 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -9,7 +9,7 @@ client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_initials( +result: bytes = avatars.get_initials( name = '', # optional width = 0, # optional height = 0, # optional diff --git a/docs/examples/avatars/get-qr.md b/docs/examples/avatars/get-qr.md index f3dbede..a7968e7 100644 --- a/docs/examples/avatars/get-qr.md +++ b/docs/examples/avatars/get-qr.md @@ -9,7 +9,7 @@ client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_qr( +result: bytes = avatars.get_qr( text = '', size = 1, # optional margin = 0, # optional diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 31587c3..6080327 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -13,7 +13,7 @@ client.set_session('') # The user session to authenticate with avatars = Avatars(client) -result = avatars.get_screenshot( +result: bytes = avatars.get_screenshot( url = 'https://example.com', headers = { "Authorization": "Bearer token123", diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md index 5393fa3..7726446 100644 --- a/docs/examples/backups/create-archive.md +++ b/docs/examples/backups/create-archive.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupArchive from appwrite.enums import BackupServices client = Client() @@ -10,8 +11,10 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.create_archive( +result: BackupArchive = backups.create_archive( services = [BackupServices.DATABASES], resource_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md index 74458b1..bf24e87 100644 --- a/docs/examples/backups/create-policy.md +++ b/docs/examples/backups/create-policy.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupPolicy from appwrite.enums import BackupServices client = Client() @@ -10,7 +11,7 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.create_policy( +result: BackupPolicy = backups.create_policy( policy_id = '', services = [BackupServices.DATABASES], retention = 1, @@ -19,4 +20,6 @@ result = backups.create_policy( resource_id = '', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md index 31fb49a..e2966ca 100644 --- a/docs/examples/backups/create-restoration.md +++ b/docs/examples/backups/create-restoration.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupRestoration from appwrite.enums import BackupServices client = Client() @@ -10,10 +11,12 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.create_restoration( +result: BackupRestoration = backups.create_restoration( archive_id = '', services = [BackupServices.DATABASES], new_resource_id = '', # optional new_resource_name = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md index 3aa3e4e..60b9c64 100644 --- a/docs/examples/backups/get-archive.md +++ b/docs/examples/backups/get-archive.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupArchive client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.get_archive( +result: BackupArchive = backups.get_archive( archive_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md index 8ebea3a..3fa673a 100644 --- a/docs/examples/backups/get-policy.md +++ b/docs/examples/backups/get-policy.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupPolicy client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.get_policy( +result: BackupPolicy = backups.get_policy( policy_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md index 5e8d004..775f047 100644 --- a/docs/examples/backups/get-restoration.md +++ b/docs/examples/backups/get-restoration.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupRestoration client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.get_restoration( +result: BackupRestoration = backups.get_restoration( restoration_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md index 8ec0409..3d17992 100644 --- a/docs/examples/backups/list-archives.md +++ b/docs/examples/backups/list-archives.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupArchiveList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.list_archives( +result: BackupArchiveList = backups.list_archives( queries = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md index 33bbe8c..bcfb673 100644 --- a/docs/examples/backups/list-policies.md +++ b/docs/examples/backups/list-policies.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupPolicyList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.list_policies( +result: BackupPolicyList = backups.list_policies( queries = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md index f26d828..c353a50 100644 --- a/docs/examples/backups/list-restorations.md +++ b/docs/examples/backups/list-restorations.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupRestorationList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.list_restorations( +result: BackupRestorationList = backups.list_restorations( queries = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md index 99308d4..74fbdeb 100644 --- a/docs/examples/backups/update-policy.md +++ b/docs/examples/backups/update-policy.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.backups import Backups +from appwrite.models import BackupPolicy client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('') # Your secret API key backups = Backups(client) -result = backups.update_policy( +result: BackupPolicy = backups.update_policy( policy_id = '', name = '', # optional retention = 1, # optional schedule = '', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index aff1268..b18196d 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeBoolean client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_boolean_attribute( +result: AttributeBoolean = databases.create_boolean_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.create_boolean_attribute( default = False, # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index f6244a0..7e9afa0 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Collection from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_collection( +result: Collection = databases.create_collection( database_id = '', collection_id = '', name = '', @@ -21,4 +22,6 @@ result = databases.create_collection( attributes = [], # optional indexes = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index d4329bc..c8dc6c2 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeDatetime client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_datetime_attribute( +result: AttributeDatetime = databases.create_datetime_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.create_datetime_attribute( default = '', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index a08f15f..26b0034 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_session('') # The user session to authenticate with databases = Databases(client) -result = databases.create_document( +result: Document = databases.create_document( database_id = '', collection_id = '', document_id = '', @@ -25,4 +26,6 @@ result = databases.create_document( permissions = [Permission.read(Role.any())], # optional transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 5e739d9..a1df96a 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import DocumentList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_documents( +result: DocumentList = databases.create_documents( database_id = '', collection_id = '', documents = [], transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index 07cf8f4..8c37eff 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeEmail client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_email_attribute( +result: AttributeEmail = databases.create_email_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.create_email_attribute( default = 'email@example.com', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index 570e2a1..bc8a4ab 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeEnum client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_enum_attribute( +result: AttributeEnum = databases.create_enum_attribute( database_id = '', collection_id = '', key = '', @@ -18,4 +19,6 @@ result = databases.create_enum_attribute( default = '', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index 0ff954b..204dbfd 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeFloat client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_float_attribute( +result: AttributeFloat = databases.create_float_attribute( database_id = '', collection_id = '', key = '', @@ -19,4 +20,6 @@ result = databases.create_float_attribute( default = None, # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 8f61ede..21cd229 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Index from appwrite.enums import IndexType from appwrite.enums import OrderBy @@ -11,7 +12,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_index( +result: Index = databases.create_index( database_id = '', collection_id = '', key = '', @@ -20,4 +21,6 @@ result = databases.create_index( orders = [OrderBy.ASC], # optional lengths = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index 9760b8c..fe609ba 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeInteger client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_integer_attribute( +result: AttributeInteger = databases.create_integer_attribute( database_id = '', collection_id = '', key = '', @@ -19,4 +20,6 @@ result = databases.create_integer_attribute( default = None, # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index 24acfe0..c684df5 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeIp client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_ip_attribute( +result: AttributeIp = databases.create_ip_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.create_ip_attribute( default = '', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index 84dd47a..5a78276 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeLine client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_line_attribute( +result: AttributeLine = databases.create_line_attribute( database_id = '', collection_id = '', key = '', required = False, default = [[1, 2], [3, 4], [5, 6]] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-longtext-attribute.md b/docs/examples/databases/create-longtext-attribute.md index 64d747d..7659fad 100644 --- a/docs/examples/databases/create-longtext-attribute.md +++ b/docs/examples/databases/create-longtext-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeLongtext client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_longtext_attribute( +result: AttributeLongtext = databases.create_longtext_attribute( database_id = '', collection_id = '', key = '', @@ -18,4 +19,6 @@ result = databases.create_longtext_attribute( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-mediumtext-attribute.md b/docs/examples/databases/create-mediumtext-attribute.md index 84cb1f8..f7381b2 100644 --- a/docs/examples/databases/create-mediumtext-attribute.md +++ b/docs/examples/databases/create-mediumtext-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeMediumtext client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_mediumtext_attribute( +result: AttributeMediumtext = databases.create_mediumtext_attribute( database_id = '', collection_id = '', key = '', @@ -18,4 +19,6 @@ result = databases.create_mediumtext_attribute( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md index 9b3967d..ce412c3 100644 --- a/docs/examples/databases/create-operations.md +++ b/docs/examples/databases/create-operations.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Transaction client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_operations( +result: Transaction = databases.create_operations( transaction_id = '', operations = [ { @@ -23,4 +24,6 @@ result = databases.create_operations( } ] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index c6886a8..8b8c8d1 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributePoint client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_point_attribute( +result: AttributePoint = databases.create_point_attribute( database_id = '', collection_id = '', key = '', required = False, default = [1, 2] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index 79dd0f0..defb0e9 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributePolygon client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_polygon_attribute( +result: AttributePolygon = databases.create_polygon_attribute( database_id = '', collection_id = '', key = '', required = False, default = [[[1, 2], [3, 4], [5, 6], [1, 2]]] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index 298386d..b4300dd 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeRelationship from appwrite.enums import RelationshipType from appwrite.enums import RelationMutate @@ -11,7 +12,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_relationship_attribute( +result: AttributeRelationship = databases.create_relationship_attribute( database_id = '', collection_id = '', related_collection_id = '', @@ -21,4 +22,6 @@ result = databases.create_relationship_attribute( two_way_key = '', # optional on_delete = RelationMutate.CASCADE # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index f23aff8..9d1383d 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeString client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_string_attribute( +result: AttributeString = databases.create_string_attribute( database_id = '', collection_id = '', key = '', @@ -19,4 +20,6 @@ result = databases.create_string_attribute( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-text-attribute.md b/docs/examples/databases/create-text-attribute.md index 7f60cf7..89f29e2 100644 --- a/docs/examples/databases/create-text-attribute.md +++ b/docs/examples/databases/create-text-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeText client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_text_attribute( +result: AttributeText = databases.create_text_attribute( database_id = '', collection_id = '', key = '', @@ -18,4 +19,6 @@ result = databases.create_text_attribute( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-transaction.md b/docs/examples/databases/create-transaction.md index d391e27..733b2cf 100644 --- a/docs/examples/databases/create-transaction.md +++ b/docs/examples/databases/create-transaction.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Transaction client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_transaction( +result: Transaction = databases.create_transaction( ttl = 60 # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index 6d7d985..b6e773a 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeUrl client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_url_attribute( +result: AttributeUrl = databases.create_url_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.create_url_attribute( default = 'https://example.com', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create-varchar-attribute.md b/docs/examples/databases/create-varchar-attribute.md index 224dacd..964e2fc 100644 --- a/docs/examples/databases/create-varchar-attribute.md +++ b/docs/examples/databases/create-varchar-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeVarchar client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create_varchar_attribute( +result: AttributeVarchar = databases.create_varchar_attribute( database_id = '', collection_id = '', key = '', @@ -19,4 +20,6 @@ result = databases.create_varchar_attribute( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index 98bff01..68a5b37 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Database client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.create( +result: Database = databases.create( database_id = '', name = '', enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index df296d0..c7bbfdd 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Document client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_session('') # The user session to authenticate with databases = Databases(client) -result = databases.decrement_document_attribute( +result: Document = databases.decrement_document_attribute( database_id = '', collection_id = '', document_id = '', @@ -18,4 +19,6 @@ result = databases.decrement_document_attribute( min = None, # optional transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index b818585..d410bde 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import DocumentList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.delete_documents( +result: DocumentList = databases.delete_documents( database_id = '', collection_id = '', queries = [], # optional transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index 0eb99c0..1e73fc0 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -1,6 +1,16 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeBoolean +from appwrite.models import AttributeInteger +from appwrite.models import AttributeFloat +from appwrite.models import AttributeEmail +from appwrite.models import AttributeEnum +from appwrite.models import AttributeUrl +from appwrite.models import AttributeIp +from appwrite.models import AttributeDatetime +from appwrite.models import AttributeRelationship +from appwrite.models import AttributeString client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +19,11 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.get_attribute( +result: Union[AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString] = databases.get_attribute( database_id = '', collection_id = '', key = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index f008548..6650f4a 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Collection client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.get_collection( +result: Collection = databases.get_collection( database_id = '', collection_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index fb0ed4a..c6d968a 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Document client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_session('') # The user session to authenticate with databases = Databases(client) -result = databases.get_document( +result: Document = databases.get_document( database_id = '', collection_id = '', document_id = '', queries = [], # optional transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index 7b5f67f..d76008a 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Index client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.get_index( +result: Index = databases.get_index( database_id = '', collection_id = '', key = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/get-transaction.md b/docs/examples/databases/get-transaction.md index 4f9b494..3348baa 100644 --- a/docs/examples/databases/get-transaction.md +++ b/docs/examples/databases/get-transaction.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Transaction client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.get_transaction( +result: Transaction = databases.get_transaction( transaction_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index c928b6b..b2906c5 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Database client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.get( +result: Database = databases.get( database_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 667e927..37fb124 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Document client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_session('') # The user session to authenticate with databases = Databases(client) -result = databases.increment_document_attribute( +result: Document = databases.increment_document_attribute( database_id = '', collection_id = '', document_id = '', @@ -18,4 +19,6 @@ result = databases.increment_document_attribute( max = None, # optional transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index c9cb51b..4fc25f4 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.list_attributes( +result: AttributeList = databases.list_attributes( database_id = '', collection_id = '', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index f14e797..19e7145 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import CollectionList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.list_collections( +result: CollectionList = databases.list_collections( database_id = '', queries = [], # optional search = '', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index ea3fe1a..f085c7d 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import DocumentList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_session('') # The user session to authenticate with databases = Databases(client) -result = databases.list_documents( +result: DocumentList = databases.list_documents( database_id = '', collection_id = '', queries = [], # optional @@ -17,4 +18,6 @@ result = databases.list_documents( total = False, # optional ttl = 0 # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index 95dd617..7129c5a 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import IndexList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.list_indexes( +result: IndexList = databases.list_indexes( database_id = '', collection_id = '', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md index f549f1a..bd09931 100644 --- a/docs/examples/databases/list-transactions.md +++ b/docs/examples/databases/list-transactions.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import TransactionList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.list_transactions( +result: TransactionList = databases.list_transactions( queries = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index b3f4de8..7fb1acd 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import DatabaseList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.list( +result: DatabaseList = databases.list( queries = [], # optional search = '', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index b5ba342..34ae961 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeBoolean client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_boolean_attribute( +result: AttributeBoolean = databases.update_boolean_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_boolean_attribute( default = False, new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 3f9462f..cfb8040 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Collection from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_collection( +result: Collection = databases.update_collection( database_id = '', collection_id = '', name = '', # optional @@ -19,4 +20,6 @@ result = databases.update_collection( document_security = False, # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index da080f2..ca054b4 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeDatetime client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_datetime_attribute( +result: AttributeDatetime = databases.update_datetime_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_datetime_attribute( default = '', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index b10cd5a..667d9b6 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_session('') # The user session to authenticate with databases = Databases(client) -result = databases.update_document( +result: Document = databases.update_document( database_id = '', collection_id = '', document_id = '', @@ -25,4 +26,6 @@ result = databases.update_document( permissions = [Permission.read(Role.any())], # optional transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 6e0cd4f..edae26a 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import DocumentList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_documents( +result: DocumentList = databases.update_documents( database_id = '', collection_id = '', data = { @@ -22,4 +23,6 @@ result = databases.update_documents( queries = [], # optional transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index fbafd98..ac6bb19 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeEmail client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_email_attribute( +result: AttributeEmail = databases.update_email_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_email_attribute( default = 'email@example.com', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index 0b9ab13..d7cf1fe 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeEnum client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_enum_attribute( +result: AttributeEnum = databases.update_enum_attribute( database_id = '', collection_id = '', key = '', @@ -18,4 +19,6 @@ result = databases.update_enum_attribute( default = '', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index 13bc920..c118255 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeFloat client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_float_attribute( +result: AttributeFloat = databases.update_float_attribute( database_id = '', collection_id = '', key = '', @@ -19,4 +20,6 @@ result = databases.update_float_attribute( max = None, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index 92ea392..ddeebf4 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeInteger client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_integer_attribute( +result: AttributeInteger = databases.update_integer_attribute( database_id = '', collection_id = '', key = '', @@ -19,4 +20,6 @@ result = databases.update_integer_attribute( max = None, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index 05e7d5f..11978eb 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeIp client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_ip_attribute( +result: AttributeIp = databases.update_ip_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_ip_attribute( default = '', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index b29b55f..ba82376 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeLine client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_line_attribute( +result: AttributeLine = databases.update_line_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_line_attribute( default = [[1, 2], [3, 4], [5, 6]], # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-longtext-attribute.md b/docs/examples/databases/update-longtext-attribute.md index 71649fe..ec7050e 100644 --- a/docs/examples/databases/update-longtext-attribute.md +++ b/docs/examples/databases/update-longtext-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeLongtext client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_longtext_attribute( +result: AttributeLongtext = databases.update_longtext_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_longtext_attribute( default = '', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-mediumtext-attribute.md b/docs/examples/databases/update-mediumtext-attribute.md index 756c95b..1036a80 100644 --- a/docs/examples/databases/update-mediumtext-attribute.md +++ b/docs/examples/databases/update-mediumtext-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeMediumtext client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_mediumtext_attribute( +result: AttributeMediumtext = databases.update_mediumtext_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_mediumtext_attribute( default = '', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index cd6ee17..9095bdf 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributePoint client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_point_attribute( +result: AttributePoint = databases.update_point_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_point_attribute( default = [1, 2], # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index fa5fc68..dffcaa5 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributePolygon client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_polygon_attribute( +result: AttributePolygon = databases.update_polygon_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_polygon_attribute( default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index 62c8d4a..226e8b0 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeRelationship from appwrite.enums import RelationMutate client = Client() @@ -10,11 +11,13 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_relationship_attribute( +result: AttributeRelationship = databases.update_relationship_attribute( database_id = '', collection_id = '', key = '', on_delete = RelationMutate.CASCADE, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index e97d132..897a313 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeString client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_string_attribute( +result: AttributeString = databases.update_string_attribute( database_id = '', collection_id = '', key = '', @@ -18,4 +19,6 @@ result = databases.update_string_attribute( size = 1, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-text-attribute.md b/docs/examples/databases/update-text-attribute.md index b7c553d..02b5fd3 100644 --- a/docs/examples/databases/update-text-attribute.md +++ b/docs/examples/databases/update-text-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeText client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_text_attribute( +result: AttributeText = databases.update_text_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_text_attribute( default = '', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-transaction.md b/docs/examples/databases/update-transaction.md index 8ccb746..937a227 100644 --- a/docs/examples/databases/update-transaction.md +++ b/docs/examples/databases/update-transaction.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Transaction client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_transaction( +result: Transaction = databases.update_transaction( transaction_id = '', commit = False, # optional rollback = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index 56e2c1c..d574770 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeUrl client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_url_attribute( +result: AttributeUrl = databases.update_url_attribute( database_id = '', collection_id = '', key = '', @@ -17,4 +18,6 @@ result = databases.update_url_attribute( default = 'https://example.com', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update-varchar-attribute.md b/docs/examples/databases/update-varchar-attribute.md index 3504e8d..f3079e1 100644 --- a/docs/examples/databases/update-varchar-attribute.md +++ b/docs/examples/databases/update-varchar-attribute.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import AttributeVarchar client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update_varchar_attribute( +result: AttributeVarchar = databases.update_varchar_attribute( database_id = '', collection_id = '', key = '', @@ -18,4 +19,6 @@ result = databases.update_varchar_attribute( size = 1, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index 864a897..73458d4 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Database client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.update( +result: Database = databases.update( database_id = '', name = '', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index bc097e9..b18eb79 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import Document from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_session('') # The user session to authenticate with databases = Databases(client) -result = databases.upsert_document( +result: Document = databases.upsert_document( database_id = '', collection_id = '', document_id = '', @@ -25,4 +26,6 @@ result = databases.upsert_document( permissions = [Permission.read(Role.any())], # optional transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index ca091c4..5039ccb 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.databases import Databases +from appwrite.models import DocumentList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('') # Your secret API key databases = Databases(client) -result = databases.upsert_documents( +result: DocumentList = databases.upsert_documents( database_id = '', collection_id = '', documents = [], transaction_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index a767648..ed197c3 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -2,6 +2,7 @@ from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.input_file import InputFile +from appwrite.models import Deployment client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -10,11 +11,13 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.create_deployment( +result: Deployment = functions.create_deployment( function_id = '', code = InputFile.from_path('file.png'), activate = False, entrypoint = '', # optional commands = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/create-duplicate-deployment.md b/docs/examples/functions/create-duplicate-deployment.md index 5005b21..68400cb 100644 --- a/docs/examples/functions/create-duplicate-deployment.md +++ b/docs/examples/functions/create-duplicate-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Deployment client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.create_duplicate_deployment( +result: Deployment = functions.create_duplicate_deployment( function_id = '', deployment_id = '', build_id = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index c1b4b91..c88c00e 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Execution from appwrite.enums import ExecutionMethod client = Client() @@ -10,7 +11,7 @@ client.set_session('') # The user session to authenticate with functions = Functions(client) -result = functions.create_execution( +result: Execution = functions.create_execution( function_id = '', body = '', # optional async = False, # optional @@ -19,4 +20,6 @@ result = functions.create_execution( headers = {}, # optional scheduled_at = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md index 6df7dd1..19227be 100644 --- a/docs/examples/functions/create-template-deployment.md +++ b/docs/examples/functions/create-template-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Deployment from appwrite.enums import TemplateReferenceType client = Client() @@ -10,7 +11,7 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.create_template_deployment( +result: Deployment = functions.create_template_deployment( function_id = '', repository = '', owner = '', @@ -19,4 +20,6 @@ result = functions.create_template_deployment( reference = '', activate = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index 046310f..e8f0b90 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Variable client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.create_variable( +result: Variable = functions.create_variable( function_id = '', key = '', value = '', secret = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/create-vcs-deployment.md b/docs/examples/functions/create-vcs-deployment.md index 1ebf526..be644a7 100644 --- a/docs/examples/functions/create-vcs-deployment.md +++ b/docs/examples/functions/create-vcs-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Deployment from appwrite.enums import VCSReferenceType client = Client() @@ -10,10 +11,12 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.create_vcs_deployment( +result: Deployment = functions.create_vcs_deployment( function_id = '', type = VCSReferenceType.BRANCH, reference = '', activate = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 2190692..3ff4e12 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Function from appwrite.enums import Runtime from appwrite.enums import Scopes @@ -11,7 +12,7 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.create( +result: Function = functions.create( function_id = '', name = '', runtime = Runtime.NODE_14_5, @@ -31,4 +32,6 @@ result = functions.create( provider_root_directory = '', # optional specification = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md index b68345a..7f6b2f6 100644 --- a/docs/examples/functions/get-deployment-download.md +++ b/docs/examples/functions/get-deployment-download.md @@ -10,7 +10,7 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.get_deployment_download( +result: bytes = functions.get_deployment_download( function_id = '', deployment_id = '', type = DeploymentDownloadType.SOURCE # optional diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index 03b04f6..d9f8ba2 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Deployment client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.get_deployment( +result: Deployment = functions.get_deployment( function_id = '', deployment_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index a2fe566..47d4ce3 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Execution client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with functions = Functions(client) -result = functions.get_execution( +result: Execution = functions.get_execution( function_id = '', execution_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index 0cc3807..7ba591a 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Variable client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.get_variable( +result: Variable = functions.get_variable( function_id = '', variable_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index 7bf7ff2..a604e4d 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Function client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.get( +result: Function = functions.get( function_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index 45d5412..0971816 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import DeploymentList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.list_deployments( +result: DeploymentList = functions.list_deployments( function_id = '', queries = [], # optional search = '', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index da65054..907ec85 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import ExecutionList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_session('') # The user session to authenticate with functions = Functions(client) -result = functions.list_executions( +result: ExecutionList = functions.list_executions( function_id = '', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index 3e7000a..ee75c80 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import RuntimeList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.list_runtimes() +result: RuntimeList = functions.list_runtimes() + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index f491a12..5b76860 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import SpecificationList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.list_specifications() +result: SpecificationList = functions.list_specifications() + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index 4145503..ac1b960 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import VariableList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.list_variables( +result: VariableList = functions.list_variables( function_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index 3c6adec..6f18769 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import FunctionList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.list( +result: FunctionList = functions.list( queries = [], # optional search = '', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/update-deployment-status.md b/docs/examples/functions/update-deployment-status.md index 15c2e0d..97a5549 100644 --- a/docs/examples/functions/update-deployment-status.md +++ b/docs/examples/functions/update-deployment-status.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Deployment client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.update_deployment_status( +result: Deployment = functions.update_deployment_status( function_id = '', deployment_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/update-function-deployment.md b/docs/examples/functions/update-function-deployment.md index 90eff8b..be39738 100644 --- a/docs/examples/functions/update-function-deployment.md +++ b/docs/examples/functions/update-function-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Function client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.update_function_deployment( +result: Function = functions.update_function_deployment( function_id = '', deployment_id = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index 10176d0..ed20fc5 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Variable client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.update_variable( +result: Variable = functions.update_variable( function_id = '', variable_id = '', key = '', value = '', # optional secret = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index fd99151..a34dfc1 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.functions import Functions +from appwrite.models import Function from appwrite.enums import Runtime from appwrite.enums import Scopes @@ -11,7 +12,7 @@ client.set_key('') # Your secret API key functions = Functions(client) -result = functions.update( +result: Function = functions.update( function_id = '', name = '', runtime = Runtime.NODE_14_5, # optional @@ -31,4 +32,6 @@ result = functions.update( provider_root_directory = '', # optional specification = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md index a3bd10b..1ab5150 100644 --- a/docs/examples/health/get-antivirus.md +++ b/docs/examples/health/get-antivirus.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthAntivirus client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_antivirus() +result: HealthAntivirus = health.get_antivirus() + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md index 3e0bd15..3905087 100644 --- a/docs/examples/health/get-cache.md +++ b/docs/examples/health/get-cache.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthStatusList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_cache() +result: HealthStatusList = health.get_cache() + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md index 6fa8c86..53dde7f 100644 --- a/docs/examples/health/get-certificate.md +++ b/docs/examples/health/get-certificate.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthCertificate client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_certificate( +result: HealthCertificate = health.get_certificate( domain = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-console-pausing.md b/docs/examples/health/get-console-pausing.md index 884a445..633c175 100644 --- a/docs/examples/health/get-console-pausing.md +++ b/docs/examples/health/get-console-pausing.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthStatus client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_console_pausing( +result: HealthStatus = health.get_console_pausing( threshold = None, # optional inactivity_days = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-db.md b/docs/examples/health/get-db.md index 69414aa..47b6dd9 100644 --- a/docs/examples/health/get-db.md +++ b/docs/examples/health/get-db.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthStatusList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_db() +result: HealthStatusList = health.get_db() + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md index 2ade2a7..9815c24 100644 --- a/docs/examples/health/get-failed-jobs.md +++ b/docs/examples/health/get-failed-jobs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue from appwrite.enums import Name client = Client() @@ -10,8 +11,10 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_failed_jobs( +result: HealthQueue = health.get_failed_jobs( name = Name.V1_DATABASE, threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-pub-sub.md b/docs/examples/health/get-pub-sub.md index 8664091..588a2ba 100644 --- a/docs/examples/health/get-pub-sub.md +++ b/docs/examples/health/get-pub-sub.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthStatusList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_pub_sub() +result: HealthStatusList = health.get_pub_sub() + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-audits.md b/docs/examples/health/get-queue-audits.md index 43ad82f..a892ca2 100644 --- a/docs/examples/health/get-queue-audits.md +++ b/docs/examples/health/get-queue-audits.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_audits( +result: HealthQueue = health.get_queue_audits( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/health/get-queue-builds.md index 850a151..0ae87b2 100644 --- a/docs/examples/health/get-queue-builds.md +++ b/docs/examples/health/get-queue-builds.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_builds( +result: HealthQueue = health.get_queue_builds( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md index 4e18f76..6666463 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/health/get-queue-certificates.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_certificates( +result: HealthQueue = health.get_queue_certificates( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-databases.md b/docs/examples/health/get-queue-databases.md index 1df0ca1..44e165e 100644 --- a/docs/examples/health/get-queue-databases.md +++ b/docs/examples/health/get-queue-databases.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_databases( +result: HealthQueue = health.get_queue_databases( name = '', # optional threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-deletes.md b/docs/examples/health/get-queue-deletes.md index 315f7bf..fece630 100644 --- a/docs/examples/health/get-queue-deletes.md +++ b/docs/examples/health/get-queue-deletes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_deletes( +result: HealthQueue = health.get_queue_deletes( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md index 3947d2d..03d9afe 100644 --- a/docs/examples/health/get-queue-functions.md +++ b/docs/examples/health/get-queue-functions.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_functions( +result: HealthQueue = health.get_queue_functions( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md index 59bd7d1..5191fa5 100644 --- a/docs/examples/health/get-queue-logs.md +++ b/docs/examples/health/get-queue-logs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_logs( +result: HealthQueue = health.get_queue_logs( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-mails.md b/docs/examples/health/get-queue-mails.md index 772a44f..aed05e1 100644 --- a/docs/examples/health/get-queue-mails.md +++ b/docs/examples/health/get-queue-mails.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_mails( +result: HealthQueue = health.get_queue_mails( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-messaging.md b/docs/examples/health/get-queue-messaging.md index 4f46712..5da876a 100644 --- a/docs/examples/health/get-queue-messaging.md +++ b/docs/examples/health/get-queue-messaging.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_messaging( +result: HealthQueue = health.get_queue_messaging( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-migrations.md b/docs/examples/health/get-queue-migrations.md index baa7de8..749675d 100644 --- a/docs/examples/health/get-queue-migrations.md +++ b/docs/examples/health/get-queue-migrations.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_migrations( +result: HealthQueue = health.get_queue_migrations( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-stats-resources.md b/docs/examples/health/get-queue-stats-resources.md index 05ea239..60c0dd5 100644 --- a/docs/examples/health/get-queue-stats-resources.md +++ b/docs/examples/health/get-queue-stats-resources.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_stats_resources( +result: HealthQueue = health.get_queue_stats_resources( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md index 9c86453..10fa4a0 100644 --- a/docs/examples/health/get-queue-usage.md +++ b/docs/examples/health/get-queue-usage.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_usage( +result: HealthQueue = health.get_queue_usage( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md index a01d44d..2442376 100644 --- a/docs/examples/health/get-queue-webhooks.md +++ b/docs/examples/health/get-queue-webhooks.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthQueue client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_queue_webhooks( +result: HealthQueue = health.get_queue_webhooks( threshold = None # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md index 9808767..57b8ec4 100644 --- a/docs/examples/health/get-storage-local.md +++ b/docs/examples/health/get-storage-local.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthStatus client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_storage_local() +result: HealthStatus = health.get_storage_local() + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-storage.md b/docs/examples/health/get-storage.md index b6bdca3..a17ee4e 100644 --- a/docs/examples/health/get-storage.md +++ b/docs/examples/health/get-storage.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthStatus client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_storage() +result: HealthStatus = health.get_storage() + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md index 9d0dd57..5ffae25 100644 --- a/docs/examples/health/get-time.md +++ b/docs/examples/health/get-time.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthTime client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get_time() +result: HealthTime = health.get_time() + +print(result.model_dump()) ``` diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md index 40ce32f..5a3b3d0 100644 --- a/docs/examples/health/get.md +++ b/docs/examples/health/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.health import Health +from appwrite.models import HealthStatus client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('') # Your secret API key health = Health(client) -result = health.get() +result: HealthStatus = health.get() + +print(result.model_dump()) ``` diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index 25e16e6..35ecbf8 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.locale import Locale +from appwrite.models import Locale client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with locale = Locale(client) -result = locale.get() +result: Locale = locale.get() + +print(result.model_dump()) ``` diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index 1cc5425..adc2939 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.locale import Locale +from appwrite.models import LocaleCodeList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with locale = Locale(client) -result = locale.list_codes() +result: LocaleCodeList = locale.list_codes() + +print(result.model_dump()) ``` diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index 40d6c6f..fcf05e6 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.locale import Locale +from appwrite.models import ContinentList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with locale = Locale(client) -result = locale.list_continents() +result: ContinentList = locale.list_continents() + +print(result.model_dump()) ``` diff --git a/docs/examples/locale/list-countries-eu.md b/docs/examples/locale/list-countries-eu.md index 2409ae3..374cc9a 100644 --- a/docs/examples/locale/list-countries-eu.md +++ b/docs/examples/locale/list-countries-eu.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.locale import Locale +from appwrite.models import CountryList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with locale = Locale(client) -result = locale.list_countries_eu() +result: CountryList = locale.list_countries_eu() + +print(result.model_dump()) ``` diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 90dc280..8b36a1f 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.locale import Locale +from appwrite.models import PhoneList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with locale = Locale(client) -result = locale.list_countries_phones() +result: PhoneList = locale.list_countries_phones() + +print(result.model_dump()) ``` diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index 1ca58a3..5c45a76 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.locale import Locale +from appwrite.models import CountryList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with locale = Locale(client) -result = locale.list_countries() +result: CountryList = locale.list_countries() + +print(result.model_dump()) ``` diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index 76e0e23..07f061c 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.locale import Locale +from appwrite.models import CurrencyList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with locale = Locale(client) -result = locale.list_currencies() +result: CurrencyList = locale.list_currencies() + +print(result.model_dump()) ``` diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index e9b028e..3fb0c82 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.locale import Locale +from appwrite.models import LanguageList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_session('') # The user session to authenticate with locale = Locale(client) -result = locale.list_languages() +result: LanguageList = locale.list_languages() + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index 84f6b25..52d144d 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key messaging = Messaging(client) -result = messaging.create_apns_provider( +result: Provider = messaging.create_apns_provider( provider_id = '', name = '', auth_key = '', # optional @@ -19,4 +20,6 @@ result = messaging.create_apns_provider( sandbox = False, # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 58dc6cf..c1a8a32 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Message client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key messaging = Messaging(client) -result = messaging.create_email( +result: Message = messaging.create_email( message_id = '', subject = '', content = '', @@ -23,4 +24,6 @@ result = messaging.create_email( html = False, # optional scheduled_at = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index 11e5e63..b4dc9b2 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('') # Your secret API key messaging = Messaging(client) -result = messaging.create_fcm_provider( +result: Provider = messaging.create_fcm_provider( provider_id = '', name = '', service_account_json = {}, # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md index 8bd974b..d16f453 100644 --- a/docs/examples/messaging/create-mailgun-provider.md +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key messaging = Messaging(client) -result = messaging.create_mailgun_provider( +result: Provider = messaging.create_mailgun_provider( provider_id = '', name = '', api_key = '', # optional @@ -21,4 +22,6 @@ result = messaging.create_mailgun_provider( reply_to_email = 'email@example.com', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-msg-91-provider.md b/docs/examples/messaging/create-msg-91-provider.md index 514e344..9bf577d 100644 --- a/docs/examples/messaging/create-msg-91-provider.md +++ b/docs/examples/messaging/create-msg-91-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('') # Your secret API key messaging = Messaging(client) -result = messaging.create_msg91_provider( +result: Provider = messaging.create_msg91_provider( provider_id = '', name = '', template_id = '', # optional @@ -17,4 +18,6 @@ result = messaging.create_msg91_provider( auth_key = '', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 2bc06bd..1a7dcc1 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Message from appwrite.enums import MessagePriority client = Client() @@ -10,7 +11,7 @@ client.set_key('') # Your secret API key messaging = Messaging(client) -result = messaging.create_push( +result: Message = messaging.create_push( message_id = '', title = '', # optional body = '<BODY>', # optional @@ -31,4 +32,6 @@ result = messaging.create_push( critical = False, # optional priority = MessagePriority.NORMAL # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-resend-provider.md b/docs/examples/messaging/create-resend-provider.md index 43c6372..5a1205a 100644 --- a/docs/examples/messaging/create-resend-provider.md +++ b/docs/examples/messaging/create-resend-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.create_resend_provider( +result: Provider = messaging.create_resend_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', api_key = '<API_KEY>', # optional @@ -19,4 +20,6 @@ result = messaging.create_resend_provider( reply_to_email = 'email@example.com', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md index 9a1c8a2..e9abd64 100644 --- a/docs/examples/messaging/create-sendgrid-provider.md +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.create_sendgrid_provider( +result: Provider = messaging.create_sendgrid_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', api_key = '<API_KEY>', # optional @@ -19,4 +20,6 @@ result = messaging.create_sendgrid_provider( reply_to_email = 'email@example.com', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 66a76c2..7eb94e8 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Message client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.create_sms( +result: Message = messaging.create_sms( message_id = '<MESSAGE_ID>', content = '<CONTENT>', topics = [], # optional @@ -18,4 +19,6 @@ result = messaging.create_sms( draft = False, # optional scheduled_at = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index cd3d703..55e5b6e 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider from appwrite.enums import SmtpEncryption client = Client() @@ -10,7 +11,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.create_smtp_provider( +result: Provider = messaging.create_smtp_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', host = '<HOST>', @@ -26,4 +27,6 @@ result = messaging.create_smtp_provider( reply_to_email = 'email@example.com', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md index 402e35f..2c230b1 100644 --- a/docs/examples/messaging/create-subscriber.md +++ b/docs/examples/messaging/create-subscriber.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Subscriber client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_jwt('<YOUR_JWT>') # Your secret JSON Web Token messaging = Messaging(client) -result = messaging.create_subscriber( +result: Subscriber = messaging.create_subscriber( topic_id = '<TOPIC_ID>', subscriber_id = '<SUBSCRIBER_ID>', target_id = '<TARGET_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md index 7a2be40..e4e1058 100644 --- a/docs/examples/messaging/create-telesign-provider.md +++ b/docs/examples/messaging/create-telesign-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.create_telesign_provider( +result: Provider = messaging.create_telesign_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', from = '+12065550100', # optional @@ -17,4 +18,6 @@ result = messaging.create_telesign_provider( api_key = '<API_KEY>', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md index 47ba6f3..3b42e69 100644 --- a/docs/examples/messaging/create-textmagic-provider.md +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.create_textmagic_provider( +result: Provider = messaging.create_textmagic_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', from = '+12065550100', # optional @@ -17,4 +18,6 @@ result = messaging.create_textmagic_provider( api_key = '<API_KEY>', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index cb20965..3a6547e 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Topic client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.create_topic( +result: Topic = messaging.create_topic( topic_id = '<TOPIC_ID>', name = '<NAME>', subscribe = ["any"] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 53f7d37..6a20087 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.create_twilio_provider( +result: Provider = messaging.create_twilio_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', from = '+12065550100', # optional @@ -17,4 +18,6 @@ result = messaging.create_twilio_provider( auth_token = '<AUTH_TOKEN>', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md index 034e539..4afc224 100644 --- a/docs/examples/messaging/create-vonage-provider.md +++ b/docs/examples/messaging/create-vonage-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.create_vonage_provider( +result: Provider = messaging.create_vonage_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', from = '+12065550100', # optional @@ -17,4 +18,6 @@ result = messaging.create_vonage_provider( api_secret = '<API_SECRET>', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md index a1a2ea1..b93df09 100644 --- a/docs/examples/messaging/get-message.md +++ b/docs/examples/messaging/get-message.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Message client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.get_message( +result: Message = messaging.get_message( message_id = '<MESSAGE_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md index 41f2860..77750af 100644 --- a/docs/examples/messaging/get-provider.md +++ b/docs/examples/messaging/get-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.get_provider( +result: Provider = messaging.get_provider( provider_id = '<PROVIDER_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md index 26e76b7..58b6dda 100644 --- a/docs/examples/messaging/get-subscriber.md +++ b/docs/examples/messaging/get-subscriber.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Subscriber client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.get_subscriber( +result: Subscriber = messaging.get_subscriber( topic_id = '<TOPIC_ID>', subscriber_id = '<SUBSCRIBER_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md index 4917f0a..7c38c80 100644 --- a/docs/examples/messaging/get-topic.md +++ b/docs/examples/messaging/get-topic.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Topic client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.get_topic( +result: Topic = messaging.get_topic( topic_id = '<TOPIC_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md index 9ae02f6..27d6b9b 100644 --- a/docs/examples/messaging/list-message-logs.md +++ b/docs/examples/messaging/list-message-logs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import LogList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.list_message_logs( +result: LogList = messaging.list_message_logs( message_id = '<MESSAGE_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md index a8b1254..cb833b2 100644 --- a/docs/examples/messaging/list-messages.md +++ b/docs/examples/messaging/list-messages.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import MessageList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.list_messages( +result: MessageList = messaging.list_messages( queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md index 9bdd1e4..ad27142 100644 --- a/docs/examples/messaging/list-provider-logs.md +++ b/docs/examples/messaging/list-provider-logs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import LogList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.list_provider_logs( +result: LogList = messaging.list_provider_logs( provider_id = '<PROVIDER_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md index cb272aa..eae8eee 100644 --- a/docs/examples/messaging/list-providers.md +++ b/docs/examples/messaging/list-providers.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import ProviderList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.list_providers( +result: ProviderList = messaging.list_providers( queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md index cb5e1a8..b02c2b1 100644 --- a/docs/examples/messaging/list-subscriber-logs.md +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import LogList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.list_subscriber_logs( +result: LogList = messaging.list_subscriber_logs( subscriber_id = '<SUBSCRIBER_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md index 33818ac..7502d00 100644 --- a/docs/examples/messaging/list-subscribers.md +++ b/docs/examples/messaging/list-subscribers.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import SubscriberList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.list_subscribers( +result: SubscriberList = messaging.list_subscribers( topic_id = '<TOPIC_ID>', queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md index 4b5b59c..6c753b2 100644 --- a/docs/examples/messaging/list-targets.md +++ b/docs/examples/messaging/list-targets.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import TargetList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.list_targets( +result: TargetList = messaging.list_targets( message_id = '<MESSAGE_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md index 1e6e15f..3ed2d7e 100644 --- a/docs/examples/messaging/list-topic-logs.md +++ b/docs/examples/messaging/list-topic-logs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import LogList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.list_topic_logs( +result: LogList = messaging.list_topic_logs( topic_id = '<TOPIC_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md index cf50c0f..106deab 100644 --- a/docs/examples/messaging/list-topics.md +++ b/docs/examples/messaging/list-topics.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import TopicList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.list_topics( +result: TopicList = messaging.list_topics( queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index 1108a37..bdbfc06 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_apns_provider( +result: Provider = messaging.update_apns_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional enabled = False, # optional @@ -19,4 +20,6 @@ result = messaging.update_apns_provider( bundle_id = '<BUNDLE_ID>', # optional sandbox = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index e63fd35..9b78e6b 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Message client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_email( +result: Message = messaging.update_email( message_id = '<MESSAGE_ID>', topics = [], # optional users = [], # optional @@ -23,4 +24,6 @@ result = messaging.update_email( scheduled_at = '', # optional attachments = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index 94f7300..6270cb8 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_fcm_provider( +result: Provider = messaging.update_fcm_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional enabled = False, # optional service_account_json = {} # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md index a774d01..5c3285c 100644 --- a/docs/examples/messaging/update-mailgun-provider.md +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_mailgun_provider( +result: Provider = messaging.update_mailgun_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional api_key = '<API_KEY>', # optional @@ -21,4 +22,6 @@ result = messaging.update_mailgun_provider( reply_to_name = '<REPLY_TO_NAME>', # optional reply_to_email = '<REPLY_TO_EMAIL>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-msg-91-provider.md b/docs/examples/messaging/update-msg-91-provider.md index 984e3e4..d608d63 100644 --- a/docs/examples/messaging/update-msg-91-provider.md +++ b/docs/examples/messaging/update-msg-91-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_msg91_provider( +result: Provider = messaging.update_msg91_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional enabled = False, # optional @@ -17,4 +18,6 @@ result = messaging.update_msg91_provider( sender_id = '<SENDER_ID>', # optional auth_key = '<AUTH_KEY>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index de42844..ac86bcb 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Message from appwrite.enums import MessagePriority client = Client() @@ -10,7 +11,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_push( +result: Message = messaging.update_push( message_id = '<MESSAGE_ID>', topics = [], # optional users = [], # optional @@ -31,4 +32,6 @@ result = messaging.update_push( critical = False, # optional priority = MessagePriority.NORMAL # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-resend-provider.md b/docs/examples/messaging/update-resend-provider.md index ecd21ee..1de7e46 100644 --- a/docs/examples/messaging/update-resend-provider.md +++ b/docs/examples/messaging/update-resend-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_resend_provider( +result: Provider = messaging.update_resend_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional enabled = False, # optional @@ -19,4 +20,6 @@ result = messaging.update_resend_provider( reply_to_name = '<REPLY_TO_NAME>', # optional reply_to_email = '<REPLY_TO_EMAIL>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md index e7f9a36..23bf7ba 100644 --- a/docs/examples/messaging/update-sendgrid-provider.md +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_sendgrid_provider( +result: Provider = messaging.update_sendgrid_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional enabled = False, # optional @@ -19,4 +20,6 @@ result = messaging.update_sendgrid_provider( reply_to_name = '<REPLY_TO_NAME>', # optional reply_to_email = '<REPLY_TO_EMAIL>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 0973a10..570c959 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Message client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_sms( +result: Message = messaging.update_sms( message_id = '<MESSAGE_ID>', topics = [], # optional users = [], # optional @@ -18,4 +19,6 @@ result = messaging.update_sms( draft = False, # optional scheduled_at = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index 7824c62..b471250 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider from appwrite.enums import SmtpEncryption client = Client() @@ -10,7 +11,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_smtp_provider( +result: Provider = messaging.update_smtp_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional host = '<HOST>', # optional @@ -26,4 +27,6 @@ result = messaging.update_smtp_provider( reply_to_email = '<REPLY_TO_EMAIL>', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md index dc1d3f1..d59fbaf 100644 --- a/docs/examples/messaging/update-telesign-provider.md +++ b/docs/examples/messaging/update-telesign-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_telesign_provider( +result: Provider = messaging.update_telesign_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional enabled = False, # optional @@ -17,4 +18,6 @@ result = messaging.update_telesign_provider( api_key = '<API_KEY>', # optional from = '<FROM>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md index 0165999..e1f9569 100644 --- a/docs/examples/messaging/update-textmagic-provider.md +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_textmagic_provider( +result: Provider = messaging.update_textmagic_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional enabled = False, # optional @@ -17,4 +18,6 @@ result = messaging.update_textmagic_provider( api_key = '<API_KEY>', # optional from = '<FROM>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 5b20cc6..d7936aa 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Topic client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_topic( +result: Topic = messaging.update_topic( topic_id = '<TOPIC_ID>', name = '<NAME>', # optional subscribe = ["any"] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md index 1db09b2..e4622e2 100644 --- a/docs/examples/messaging/update-twilio-provider.md +++ b/docs/examples/messaging/update-twilio-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_twilio_provider( +result: Provider = messaging.update_twilio_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional enabled = False, # optional @@ -17,4 +18,6 @@ result = messaging.update_twilio_provider( auth_token = '<AUTH_TOKEN>', # optional from = '<FROM>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md index e8a2712..ba37989 100644 --- a/docs/examples/messaging/update-vonage-provider.md +++ b/docs/examples/messaging/update-vonage-provider.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.messaging import Messaging +from appwrite.models import Provider client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key messaging = Messaging(client) -result = messaging.update_vonage_provider( +result: Provider = messaging.update_vonage_provider( provider_id = '<PROVIDER_ID>', name = '<NAME>', # optional enabled = False, # optional @@ -17,4 +18,6 @@ result = messaging.update_vonage_provider( api_secret = '<API_SECRET>', # optional from = '<FROM>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md index 7d7c25b..8abb038 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -2,6 +2,7 @@ from appwrite.client import Client from appwrite.services.sites import Sites from appwrite.input_file import InputFile +from appwrite.models import Deployment client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -10,7 +11,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.create_deployment( +result: Deployment = sites.create_deployment( site_id = '<SITE_ID>', code = InputFile.from_path('file.png'), install_command = '<INSTALL_COMMAND>', # optional @@ -18,4 +19,6 @@ result = sites.create_deployment( output_directory = '<OUTPUT_DIRECTORY>', # optional activate = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/create-duplicate-deployment.md b/docs/examples/sites/create-duplicate-deployment.md index 63cd2b9..35b5256 100644 --- a/docs/examples/sites/create-duplicate-deployment.md +++ b/docs/examples/sites/create-duplicate-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Deployment client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.create_duplicate_deployment( +result: Deployment = sites.create_duplicate_deployment( site_id = '<SITE_ID>', deployment_id = '<DEPLOYMENT_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md index 17aa6a1..f65b153 100644 --- a/docs/examples/sites/create-template-deployment.md +++ b/docs/examples/sites/create-template-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Deployment from appwrite.enums import TemplateReferenceType client = Client() @@ -10,7 +11,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.create_template_deployment( +result: Deployment = sites.create_template_deployment( site_id = '<SITE_ID>', repository = '<REPOSITORY>', owner = '<OWNER>', @@ -19,4 +20,6 @@ result = sites.create_template_deployment( reference = '<REFERENCE>', activate = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md index e8971fd..d9f866b 100644 --- a/docs/examples/sites/create-variable.md +++ b/docs/examples/sites/create-variable.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Variable client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.create_variable( +result: Variable = sites.create_variable( site_id = '<SITE_ID>', key = '<KEY>', value = '<VALUE>', secret = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/create-vcs-deployment.md b/docs/examples/sites/create-vcs-deployment.md index 116f4e9..1846cef 100644 --- a/docs/examples/sites/create-vcs-deployment.md +++ b/docs/examples/sites/create-vcs-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Deployment from appwrite.enums import VCSReferenceType client = Client() @@ -10,10 +11,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.create_vcs_deployment( +result: Deployment = sites.create_vcs_deployment( site_id = '<SITE_ID>', type = VCSReferenceType.BRANCH, reference = '<REFERENCE>', activate = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index 248a234..67eb46c 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Site from appwrite.enums import Framework from appwrite.enums import BuildRuntime from appwrite.enums import Adapter @@ -12,7 +13,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.create( +result: Site = sites.create( site_id = '<SITE_ID>', name = '<NAME>', framework = Framework.ANALOG, @@ -32,4 +33,6 @@ result = sites.create( provider_root_directory = '<PROVIDER_ROOT_DIRECTORY>', # optional specification = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md index fae8371..eae2543 100644 --- a/docs/examples/sites/get-deployment-download.md +++ b/docs/examples/sites/get-deployment-download.md @@ -10,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.get_deployment_download( +result: bytes = sites.get_deployment_download( site_id = '<SITE_ID>', deployment_id = '<DEPLOYMENT_ID>', type = DeploymentDownloadType.SOURCE # optional diff --git a/docs/examples/sites/get-deployment.md b/docs/examples/sites/get-deployment.md index c4ed80c..5291928 100644 --- a/docs/examples/sites/get-deployment.md +++ b/docs/examples/sites/get-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Deployment client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.get_deployment( +result: Deployment = sites.get_deployment( site_id = '<SITE_ID>', deployment_id = '<DEPLOYMENT_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/get-log.md b/docs/examples/sites/get-log.md index 6b70fe2..aa718da 100644 --- a/docs/examples/sites/get-log.md +++ b/docs/examples/sites/get-log.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Execution client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.get_log( +result: Execution = sites.get_log( site_id = '<SITE_ID>', log_id = '<LOG_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/get-variable.md b/docs/examples/sites/get-variable.md index 5251fc4..9eb30dd 100644 --- a/docs/examples/sites/get-variable.md +++ b/docs/examples/sites/get-variable.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Variable client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.get_variable( +result: Variable = sites.get_variable( site_id = '<SITE_ID>', variable_id = '<VARIABLE_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/get.md b/docs/examples/sites/get.md index 129248c..c792987 100644 --- a/docs/examples/sites/get.md +++ b/docs/examples/sites/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Site client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.get( +result: Site = sites.get( site_id = '<SITE_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md index 3e9c738..70b2a0b 100644 --- a/docs/examples/sites/list-deployments.md +++ b/docs/examples/sites/list-deployments.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import DeploymentList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.list_deployments( +result: DeploymentList = sites.list_deployments( site_id = '<SITE_ID>', queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md index 6e2edae..84996b3 100644 --- a/docs/examples/sites/list-frameworks.md +++ b/docs/examples/sites/list-frameworks.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import FrameworkList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.list_frameworks() +result: FrameworkList = sites.list_frameworks() + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md index 35dd7fe..4543f23 100644 --- a/docs/examples/sites/list-logs.md +++ b/docs/examples/sites/list-logs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import ExecutionList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.list_logs( +result: ExecutionList = sites.list_logs( site_id = '<SITE_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index a82616b..c1229a3 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import SpecificationList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,5 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.list_specifications() +result: SpecificationList = sites.list_specifications() + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md index 35b5265..5560279 100644 --- a/docs/examples/sites/list-variables.md +++ b/docs/examples/sites/list-variables.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import VariableList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.list_variables( +result: VariableList = sites.list_variables( site_id = '<SITE_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md index 2d87535..0a56482 100644 --- a/docs/examples/sites/list.md +++ b/docs/examples/sites/list.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import SiteList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.list( +result: SiteList = sites.list( queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/update-deployment-status.md b/docs/examples/sites/update-deployment-status.md index 68f24fa..8ab82d4 100644 --- a/docs/examples/sites/update-deployment-status.md +++ b/docs/examples/sites/update-deployment-status.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Deployment client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.update_deployment_status( +result: Deployment = sites.update_deployment_status( site_id = '<SITE_ID>', deployment_id = '<DEPLOYMENT_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/update-site-deployment.md b/docs/examples/sites/update-site-deployment.md index 53f0b8b..507923e 100644 --- a/docs/examples/sites/update-site-deployment.md +++ b/docs/examples/sites/update-site-deployment.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Site client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.update_site_deployment( +result: Site = sites.update_site_deployment( site_id = '<SITE_ID>', deployment_id = '<DEPLOYMENT_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md index 57ace3e..5e16578 100644 --- a/docs/examples/sites/update-variable.md +++ b/docs/examples/sites/update-variable.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Variable client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.update_variable( +result: Variable = sites.update_variable( site_id = '<SITE_ID>', variable_id = '<VARIABLE_ID>', key = '<KEY>', value = '<VALUE>', # optional secret = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index f4e6a6d..bdfe2b1 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.sites import Sites +from appwrite.models import Site from appwrite.enums import Framework from appwrite.enums import BuildRuntime from appwrite.enums import Adapter @@ -12,7 +13,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key sites = Sites(client) -result = sites.update( +result: Site = sites.update( site_id = '<SITE_ID>', name = '<NAME>', framework = Framework.ANALOG, @@ -32,4 +33,6 @@ result = sites.update( provider_root_directory = '<PROVIDER_ROOT_DIRECTORY>', # optional specification = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index 58caa70..418f8ec 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.storage import Storage +from appwrite.models import Bucket from appwrite.enums import Compression from appwrite.permission import Permission from appwrite.role import Role @@ -12,7 +13,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key storage = Storage(client) -result = storage.create_bucket( +result: Bucket = storage.create_bucket( bucket_id = '<BUCKET_ID>', name = '<NAME>', permissions = [Permission.read(Role.any())], # optional @@ -25,4 +26,6 @@ result = storage.create_bucket( antivirus = False, # optional transformations = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 4e347b2..2103a1d 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -2,6 +2,7 @@ from appwrite.client import Client from appwrite.services.storage import Storage from appwrite.input_file import InputFile +from appwrite.models import File from appwrite.permission import Permission from appwrite.role import Role @@ -12,10 +13,12 @@ client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.create_file( +result: File = storage.create_file( bucket_id = '<BUCKET_ID>', file_id = '<FILE_ID>', file = InputFile.from_path('file.png'), permissions = [Permission.read(Role.any())] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md index a12e720..eaa707c 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.storage import Storage +from appwrite.models import Bucket client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key storage = Storage(client) -result = storage.get_bucket( +result: Bucket = storage.get_bucket( bucket_id = '<BUCKET_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 790bd72..ac6f942 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -9,7 +9,7 @@ client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.get_file_download( +result: bytes = storage.get_file_download( bucket_id = '<BUCKET_ID>', file_id = '<FILE_ID>', token = '<TOKEN>' # optional diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index b14a646..4cbc4a5 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -11,7 +11,7 @@ client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.get_file_preview( +result: bytes = storage.get_file_preview( bucket_id = '<BUCKET_ID>', file_id = '<FILE_ID>', width = 0, # optional diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index f78822d..5cceef6 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -9,7 +9,7 @@ client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.get_file_view( +result: bytes = storage.get_file_view( bucket_id = '<BUCKET_ID>', file_id = '<FILE_ID>', token = '<TOKEN>' # optional diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index 8c79a68..fb14351 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.storage import Storage +from appwrite.models import File client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.get_file( +result: File = storage.get_file( bucket_id = '<BUCKET_ID>', file_id = '<FILE_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index 5c280cd..aebd50b 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.storage import Storage +from appwrite.models import BucketList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key storage = Storage(client) -result = storage.list_buckets( +result: BucketList = storage.list_buckets( queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 5a0e2f2..a676c31 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.storage import Storage +from appwrite.models import FileList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.list_files( +result: FileList = storage.list_files( bucket_id = '<BUCKET_ID>', queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 669d9ab..ecb1ada 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.storage import Storage +from appwrite.models import Bucket from appwrite.enums import Compression from appwrite.permission import Permission from appwrite.role import Role @@ -12,7 +13,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key storage = Storage(client) -result = storage.update_bucket( +result: Bucket = storage.update_bucket( bucket_id = '<BUCKET_ID>', name = '<NAME>', permissions = [Permission.read(Role.any())], # optional @@ -25,4 +26,6 @@ result = storage.update_bucket( antivirus = False, # optional transformations = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index 4e14348..b0fad8d 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.storage import Storage +from appwrite.models import File from appwrite.permission import Permission from appwrite.role import Role @@ -11,10 +12,12 @@ client.set_session('') # The user session to authenticate with storage = Storage(client) -result = storage.update_file( +result: File = storage.update_file( bucket_id = '<BUCKET_ID>', file_id = '<FILE_ID>', name = '<NAME>', # optional permissions = [Permission.read(Role.any())] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md index 29b6e43..a500116 100644 --- a/docs/examples/tablesdb/create-boolean-column.md +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnBoolean client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_boolean_column( +result: ColumnBoolean = tables_db.create_boolean_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.create_boolean_column( default = False, # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md index 3f31d63..1255834 100644 --- a/docs/examples/tablesdb/create-datetime-column.md +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnDatetime client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_datetime_column( +result: ColumnDatetime = tables_db.create_datetime_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.create_datetime_column( default = '', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md index 263af1c..b75bd42 100644 --- a/docs/examples/tablesdb/create-email-column.md +++ b/docs/examples/tablesdb/create-email-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnEmail client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_email_column( +result: ColumnEmail = tables_db.create_email_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.create_email_column( default = 'email@example.com', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md index 6f77c50..a5248b4 100644 --- a/docs/examples/tablesdb/create-enum-column.md +++ b/docs/examples/tablesdb/create-enum-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnEnum client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_enum_column( +result: ColumnEnum = tables_db.create_enum_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -18,4 +19,6 @@ result = tables_db.create_enum_column( default = '<DEFAULT>', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md index 05b1d96..97f414b 100644 --- a/docs/examples/tablesdb/create-float-column.md +++ b/docs/examples/tablesdb/create-float-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnFloat client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_float_column( +result: ColumnFloat = tables_db.create_float_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -19,4 +20,6 @@ result = tables_db.create_float_column( default = None, # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index ddf400d..acf0792 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnIndex from appwrite.enums import IndexType from appwrite.enums import OrderBy @@ -11,7 +12,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_index( +result: ColumnIndex = tables_db.create_index( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -20,4 +21,6 @@ result = tables_db.create_index( orders = [OrderBy.ASC], # optional lengths = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md index 89e0162..35ccf41 100644 --- a/docs/examples/tablesdb/create-integer-column.md +++ b/docs/examples/tablesdb/create-integer-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnInteger client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_integer_column( +result: ColumnInteger = tables_db.create_integer_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -19,4 +20,6 @@ result = tables_db.create_integer_column( default = None, # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md index 0528b57..7121668 100644 --- a/docs/examples/tablesdb/create-ip-column.md +++ b/docs/examples/tablesdb/create-ip-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnIp client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_ip_column( +result: ColumnIp = tables_db.create_ip_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.create_ip_column( default = '', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index 3d99152..0173466 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnLine client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_line_column( +result: ColumnLine = tables_db.create_line_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', required = False, default = [[1, 2], [3, 4], [5, 6]] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-longtext-column.md b/docs/examples/tablesdb/create-longtext-column.md index 65981d6..29f2090 100644 --- a/docs/examples/tablesdb/create-longtext-column.md +++ b/docs/examples/tablesdb/create-longtext-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnLongtext client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_longtext_column( +result: ColumnLongtext = tables_db.create_longtext_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -18,4 +19,6 @@ result = tables_db.create_longtext_column( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-mediumtext-column.md b/docs/examples/tablesdb/create-mediumtext-column.md index c731988..4cdc93b 100644 --- a/docs/examples/tablesdb/create-mediumtext-column.md +++ b/docs/examples/tablesdb/create-mediumtext-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnMediumtext client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_mediumtext_column( +result: ColumnMediumtext = tables_db.create_mediumtext_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -18,4 +19,6 @@ result = tables_db.create_mediumtext_column( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md index 780f088..cb2a8c9 100644 --- a/docs/examples/tablesdb/create-operations.md +++ b/docs/examples/tablesdb/create-operations.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Transaction client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_operations( +result: Transaction = tables_db.create_operations( transaction_id = '<TRANSACTION_ID>', operations = [ { @@ -23,4 +24,6 @@ result = tables_db.create_operations( } ] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index 311bea4..d5dbfce 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnPoint client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_point_column( +result: ColumnPoint = tables_db.create_point_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', required = False, default = [1, 2] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 9e72cdf..a21f00a 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnPolygon client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_polygon_column( +result: ColumnPolygon = tables_db.create_polygon_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', required = False, default = [[[1, 2], [3, 4], [5, 6], [1, 2]]] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md index 3248f0d..0ec16db 100644 --- a/docs/examples/tablesdb/create-relationship-column.md +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnRelationship from appwrite.enums import RelationshipType from appwrite.enums import RelationMutate @@ -11,7 +12,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_relationship_column( +result: ColumnRelationship = tables_db.create_relationship_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', related_table_id = '<RELATED_TABLE_ID>', @@ -21,4 +22,6 @@ result = tables_db.create_relationship_column( two_way_key = '', # optional on_delete = RelationMutate.CASCADE # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index bba8b95..aa8a9fe 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Row from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_session('') # The user session to authenticate with tables_db = TablesDB(client) -result = tables_db.create_row( +result: Row = tables_db.create_row( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', row_id = '<ROW_ID>', @@ -25,4 +26,6 @@ result = tables_db.create_row( permissions = [Permission.read(Role.any())], # optional transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 40276d0..9e741fe 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import RowList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_rows( +result: RowList = tables_db.create_rows( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', rows = [], transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md index 584944d..6dae7f9 100644 --- a/docs/examples/tablesdb/create-string-column.md +++ b/docs/examples/tablesdb/create-string-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnString client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_string_column( +result: ColumnString = tables_db.create_string_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -19,4 +20,6 @@ result = tables_db.create_string_column( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md index d6b9c5f..029fb28 100644 --- a/docs/examples/tablesdb/create-table.md +++ b/docs/examples/tablesdb/create-table.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Table from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_table( +result: Table = tables_db.create_table( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', name = '<NAME>', @@ -21,4 +22,6 @@ result = tables_db.create_table( columns = [], # optional indexes = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-text-column.md b/docs/examples/tablesdb/create-text-column.md index 013c675..5f8a94d 100644 --- a/docs/examples/tablesdb/create-text-column.md +++ b/docs/examples/tablesdb/create-text-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnText client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_text_column( +result: ColumnText = tables_db.create_text_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -18,4 +19,6 @@ result = tables_db.create_text_column( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-transaction.md b/docs/examples/tablesdb/create-transaction.md index 9fb96a0..b48e262 100644 --- a/docs/examples/tablesdb/create-transaction.md +++ b/docs/examples/tablesdb/create-transaction.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Transaction client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_transaction( +result: Transaction = tables_db.create_transaction( ttl = 60 # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md index 7daa52b..b37879a 100644 --- a/docs/examples/tablesdb/create-url-column.md +++ b/docs/examples/tablesdb/create-url-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnUrl client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_url_column( +result: ColumnUrl = tables_db.create_url_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.create_url_column( default = 'https://example.com', # optional array = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create-varchar-column.md b/docs/examples/tablesdb/create-varchar-column.md index 981cf69..02e0410 100644 --- a/docs/examples/tablesdb/create-varchar-column.md +++ b/docs/examples/tablesdb/create-varchar-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnVarchar client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create_varchar_column( +result: ColumnVarchar = tables_db.create_varchar_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -19,4 +20,6 @@ result = tables_db.create_varchar_column( array = False, # optional encrypt = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index 7505f52..fb6bf0f 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Database client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.create( +result: Database = tables_db.create( database_id = '<DATABASE_ID>', name = '<NAME>', enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index 56cbb2d..f447902 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Row client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_session('') # The user session to authenticate with tables_db = TablesDB(client) -result = tables_db.decrement_row_column( +result: Row = tables_db.decrement_row_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', row_id = '<ROW_ID>', @@ -18,4 +19,6 @@ result = tables_db.decrement_row_column( min = None, # optional transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 5164fc1..2a3a89c 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import RowList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.delete_rows( +result: RowList = tables_db.delete_rows( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', queries = [], # optional transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md index 1d52922..1ccced6 100644 --- a/docs/examples/tablesdb/get-column.md +++ b/docs/examples/tablesdb/get-column.md @@ -1,6 +1,16 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnBoolean +from appwrite.models import ColumnInteger +from appwrite.models import ColumnFloat +from appwrite.models import ColumnEmail +from appwrite.models import ColumnEnum +from appwrite.models import ColumnUrl +from appwrite.models import ColumnIp +from appwrite.models import ColumnDatetime +from appwrite.models import ColumnRelationship +from appwrite.models import ColumnString client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +19,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.get_column( +result: Union[ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString] = tables_db.get_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md index 006da01..72c8e46 100644 --- a/docs/examples/tablesdb/get-index.md +++ b/docs/examples/tablesdb/get-index.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnIndex client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.get_index( +result: ColumnIndex = tables_db.get_index( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md index 6b10f3e..55609e2 100644 --- a/docs/examples/tablesdb/get-row.md +++ b/docs/examples/tablesdb/get-row.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Row client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_session('') # The user session to authenticate with tables_db = TablesDB(client) -result = tables_db.get_row( +result: Row = tables_db.get_row( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', row_id = '<ROW_ID>', queries = [], # optional transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md index 6cd8f06..da6a4bc 100644 --- a/docs/examples/tablesdb/get-table.md +++ b/docs/examples/tablesdb/get-table.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Table client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.get_table( +result: Table = tables_db.get_table( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/get-transaction.md b/docs/examples/tablesdb/get-transaction.md index d2f4b7d..b51fcc2 100644 --- a/docs/examples/tablesdb/get-transaction.md +++ b/docs/examples/tablesdb/get-transaction.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Transaction client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.get_transaction( +result: Transaction = tables_db.get_transaction( transaction_id = '<TRANSACTION_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md index a3c0c21..036deee 100644 --- a/docs/examples/tablesdb/get.md +++ b/docs/examples/tablesdb/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Database client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.get( +result: Database = tables_db.get( database_id = '<DATABASE_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index 75a9003..ac844f1 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Row client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_session('') # The user session to authenticate with tables_db = TablesDB(client) -result = tables_db.increment_row_column( +result: Row = tables_db.increment_row_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', row_id = '<ROW_ID>', @@ -18,4 +19,6 @@ result = tables_db.increment_row_column( max = None, # optional transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md index 3643487..3a45048 100644 --- a/docs/examples/tablesdb/list-columns.md +++ b/docs/examples/tablesdb/list-columns.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.list_columns( +result: ColumnList = tables_db.list_columns( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md index 2263fc9..b1ccf1a 100644 --- a/docs/examples/tablesdb/list-indexes.md +++ b/docs/examples/tablesdb/list-indexes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnIndexList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.list_indexes( +result: ColumnIndexList = tables_db.list_indexes( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index b616d1a..0ef9410 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import RowList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_session('') # The user session to authenticate with tables_db = TablesDB(client) -result = tables_db.list_rows( +result: RowList = tables_db.list_rows( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', queries = [], # optional @@ -17,4 +18,6 @@ result = tables_db.list_rows( total = False, # optional ttl = 0 # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md index 48937e8..589aaa9 100644 --- a/docs/examples/tablesdb/list-tables.md +++ b/docs/examples/tablesdb/list-tables.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import TableList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.list_tables( +result: TableList = tables_db.list_tables( database_id = '<DATABASE_ID>', queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md index 6f86199..b4384e6 100644 --- a/docs/examples/tablesdb/list-transactions.md +++ b/docs/examples/tablesdb/list-transactions.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import TransactionList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.list_transactions( +result: TransactionList = tables_db.list_transactions( queries = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md index d687a42..cfc352d 100644 --- a/docs/examples/tablesdb/list.md +++ b/docs/examples/tablesdb/list.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import DatabaseList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.list( +result: DatabaseList = tables_db.list( queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md index d140cc1..ce0a02d 100644 --- a/docs/examples/tablesdb/update-boolean-column.md +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnBoolean client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_boolean_column( +result: ColumnBoolean = tables_db.update_boolean_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_boolean_column( default = False, new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md index 3e0955c..c525ace 100644 --- a/docs/examples/tablesdb/update-datetime-column.md +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnDatetime client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_datetime_column( +result: ColumnDatetime = tables_db.update_datetime_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_datetime_column( default = '', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md index cd5a84b..565b941 100644 --- a/docs/examples/tablesdb/update-email-column.md +++ b/docs/examples/tablesdb/update-email-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnEmail client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_email_column( +result: ColumnEmail = tables_db.update_email_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_email_column( default = 'email@example.com', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md index 612bdc8..4357a93 100644 --- a/docs/examples/tablesdb/update-enum-column.md +++ b/docs/examples/tablesdb/update-enum-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnEnum client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_enum_column( +result: ColumnEnum = tables_db.update_enum_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -18,4 +19,6 @@ result = tables_db.update_enum_column( default = '<DEFAULT>', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md index a622f8b..339e9c8 100644 --- a/docs/examples/tablesdb/update-float-column.md +++ b/docs/examples/tablesdb/update-float-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnFloat client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_float_column( +result: ColumnFloat = tables_db.update_float_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -19,4 +20,6 @@ result = tables_db.update_float_column( max = None, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md index 060d38d..21a2b1c 100644 --- a/docs/examples/tablesdb/update-integer-column.md +++ b/docs/examples/tablesdb/update-integer-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnInteger client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_integer_column( +result: ColumnInteger = tables_db.update_integer_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -19,4 +20,6 @@ result = tables_db.update_integer_column( max = None, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md index 636ec3c..cb7e188 100644 --- a/docs/examples/tablesdb/update-ip-column.md +++ b/docs/examples/tablesdb/update-ip-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnIp client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_ip_column( +result: ColumnIp = tables_db.update_ip_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_ip_column( default = '', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index d7b7739..c5bbb5d 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnLine client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_line_column( +result: ColumnLine = tables_db.update_line_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_line_column( default = [[1, 2], [3, 4], [5, 6]], # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-longtext-column.md b/docs/examples/tablesdb/update-longtext-column.md index 16deaeb..8b31f17 100644 --- a/docs/examples/tablesdb/update-longtext-column.md +++ b/docs/examples/tablesdb/update-longtext-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnLongtext client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_longtext_column( +result: ColumnLongtext = tables_db.update_longtext_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_longtext_column( default = '<DEFAULT>', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-mediumtext-column.md b/docs/examples/tablesdb/update-mediumtext-column.md index 18ac7ce..ad4cdd4 100644 --- a/docs/examples/tablesdb/update-mediumtext-column.md +++ b/docs/examples/tablesdb/update-mediumtext-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnMediumtext client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_mediumtext_column( +result: ColumnMediumtext = tables_db.update_mediumtext_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_mediumtext_column( default = '<DEFAULT>', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index a75546c..5ab5584 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnPoint client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_point_column( +result: ColumnPoint = tables_db.update_point_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_point_column( default = [1, 2], # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index 33d3b2a..692a16c 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnPolygon client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_polygon_column( +result: ColumnPolygon = tables_db.update_polygon_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_polygon_column( default = [[[1, 2], [3, 4], [5, 6], [1, 2]]], # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md index a10395d..20307f6 100644 --- a/docs/examples/tablesdb/update-relationship-column.md +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnRelationship from appwrite.enums import RelationMutate client = Client() @@ -10,11 +11,13 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_relationship_column( +result: ColumnRelationship = tables_db.update_relationship_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', on_delete = RelationMutate.CASCADE, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 1cabdbe..30522e7 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Row from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_session('') # The user session to authenticate with tables_db = TablesDB(client) -result = tables_db.update_row( +result: Row = tables_db.update_row( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', row_id = '<ROW_ID>', @@ -25,4 +26,6 @@ result = tables_db.update_row( permissions = [Permission.read(Role.any())], # optional transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 0a70291..dc3641b 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import RowList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_rows( +result: RowList = tables_db.update_rows( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', data = { @@ -22,4 +23,6 @@ result = tables_db.update_rows( queries = [], # optional transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md index cbc8655..0fdc53c 100644 --- a/docs/examples/tablesdb/update-string-column.md +++ b/docs/examples/tablesdb/update-string-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnString client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_string_column( +result: ColumnString = tables_db.update_string_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -18,4 +19,6 @@ result = tables_db.update_string_column( size = 1, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index d45df51..c810155 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Table from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_table( +result: Table = tables_db.update_table( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', name = '<NAME>', # optional @@ -19,4 +20,6 @@ result = tables_db.update_table( row_security = False, # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-text-column.md b/docs/examples/tablesdb/update-text-column.md index 47cce30..3be554c 100644 --- a/docs/examples/tablesdb/update-text-column.md +++ b/docs/examples/tablesdb/update-text-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnText client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_text_column( +result: ColumnText = tables_db.update_text_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_text_column( default = '<DEFAULT>', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-transaction.md b/docs/examples/tablesdb/update-transaction.md index c55340d..999f53b 100644 --- a/docs/examples/tablesdb/update-transaction.md +++ b/docs/examples/tablesdb/update-transaction.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Transaction client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_transaction( +result: Transaction = tables_db.update_transaction( transaction_id = '<TRANSACTION_ID>', commit = False, # optional rollback = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md index 1af172c..2d8626a 100644 --- a/docs/examples/tablesdb/update-url-column.md +++ b/docs/examples/tablesdb/update-url-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnUrl client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_url_column( +result: ColumnUrl = tables_db.update_url_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -17,4 +18,6 @@ result = tables_db.update_url_column( default = 'https://example.com', new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update-varchar-column.md b/docs/examples/tablesdb/update-varchar-column.md index b1dc732..1a415b8 100644 --- a/docs/examples/tablesdb/update-varchar-column.md +++ b/docs/examples/tablesdb/update-varchar-column.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnVarchar client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update_varchar_column( +result: ColumnVarchar = tables_db.update_varchar_column( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', key = '', @@ -18,4 +19,6 @@ result = tables_db.update_varchar_column( size = 1, # optional new_key = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 85b5c96..aea5485 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Database client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.update( +result: Database = tables_db.update( database_id = '<DATABASE_ID>', name = '<NAME>', # optional enabled = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index f985e84..c511545 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import Row from appwrite.permission import Permission from appwrite.role import Role @@ -11,7 +12,7 @@ client.set_session('') # The user session to authenticate with tables_db = TablesDB(client) -result = tables_db.upsert_row( +result: Row = tables_db.upsert_row( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', row_id = '<ROW_ID>', @@ -25,4 +26,6 @@ result = tables_db.upsert_row( permissions = [Permission.read(Role.any())], # optional transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index d339713..0b6a754 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tables_db import TablesDB +from appwrite.models import RowList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tables_db = TablesDB(client) -result = tables_db.upsert_rows( +result: RowList = tables_db.upsert_rows( database_id = '<DATABASE_ID>', table_id = '<TABLE_ID>', rows = [], transaction_id = '<TRANSACTION_ID>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 71442d4..313bf5f 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import Membership client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.create_membership( +result: Membership = teams.create_membership( team_id = '<TEAM_ID>', roles = [], email = 'email@example.com', # optional @@ -18,4 +19,6 @@ result = teams.create_membership( url = 'https://example.com', # optional name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index d366d05..965d854 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import Team client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.create( +result: Team = teams.create( team_id = '<TEAM_ID>', name = '<NAME>', roles = [] # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index 91c5b2a..54ad0cd 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import Membership client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.get_membership( +result: Membership = teams.get_membership( team_id = '<TEAM_ID>', membership_id = '<MEMBERSHIP_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index 8f41f63..20ae596 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import Preferences client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.get_prefs( +result: Preferences = teams.get_prefs( team_id = '<TEAM_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index 0f6d880..3b5116c 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import Team client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.get( +result: Team = teams.get( team_id = '<TEAM_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 3e105ad..8acc9d1 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import MembershipList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.list_memberships( +result: MembershipList = teams.list_memberships( team_id = '<TEAM_ID>', queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index 9c43f9e..9fcd1dd 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import TeamList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.list( +result: TeamList = teams.list( queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index 2d9d1f3..b836d82 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import Membership client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.update_membership_status( +result: Membership = teams.update_membership_status( team_id = '<TEAM_ID>', membership_id = '<MEMBERSHIP_ID>', user_id = '<USER_ID>', secret = '<SECRET>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index bb10886..4425ae5 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import Membership client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.update_membership( +result: Membership = teams.update_membership( team_id = '<TEAM_ID>', membership_id = '<MEMBERSHIP_ID>', roles = [] ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index 893e3ed..376d6c3 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import Team client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.update_name( +result: Team = teams.update_name( team_id = '<TEAM_ID>', name = '<NAME>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index e4fb822..23f4878 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.models import Preferences client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_session('') # The user session to authenticate with teams = Teams(client) -result = teams.update_prefs( +result: Preferences = teams.update_prefs( team_id = '<TEAM_ID>', prefs = {} ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md index fe05a65..32dce32 100644 --- a/docs/examples/tokens/create-file-token.md +++ b/docs/examples/tokens/create-file-token.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tokens import Tokens +from appwrite.models import ResourceToken client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tokens = Tokens(client) -result = tokens.create_file_token( +result: ResourceToken = tokens.create_file_token( bucket_id = '<BUCKET_ID>', file_id = '<FILE_ID>', expire = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tokens/get.md b/docs/examples/tokens/get.md index aee3a97..83a9649 100644 --- a/docs/examples/tokens/get.md +++ b/docs/examples/tokens/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tokens import Tokens +from appwrite.models import ResourceToken client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tokens = Tokens(client) -result = tokens.get( +result: ResourceToken = tokens.get( token_id = '<TOKEN_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md index 9464504..d570016 100644 --- a/docs/examples/tokens/list.md +++ b/docs/examples/tokens/list.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tokens import Tokens +from appwrite.models import ResourceTokenList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tokens = Tokens(client) -result = tokens.list( +result: ResourceTokenList = tokens.list( bucket_id = '<BUCKET_ID>', file_id = '<FILE_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md index abf544b..4b57a60 100644 --- a/docs/examples/tokens/update.md +++ b/docs/examples/tokens/update.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.tokens import Tokens +from appwrite.models import ResourceToken client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key tokens = Tokens(client) -result = tokens.update( +result: ResourceToken = tokens.update( token_id = '<TOKEN_ID>', expire = '' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-argon-2-user.md b/docs/examples/users/create-argon-2-user.md index a54b2c0..cd3e2bc 100644 --- a/docs/examples/users/create-argon-2-user.md +++ b/docs/examples/users/create-argon-2-user.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_argon2_user( +result: User = users.create_argon2_user( user_id = '<USER_ID>', email = 'email@example.com', password = 'password', name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md index 804181b..d3ab13e 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_bcrypt_user( +result: User = users.create_bcrypt_user( user_id = '<USER_ID>', email = 'email@example.com', password = 'password', name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-jwt.md b/docs/examples/users/create-jwt.md index 1ccf473..bf4df2e 100644 --- a/docs/examples/users/create-jwt.md +++ b/docs/examples/users/create-jwt.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import Jwt client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_jwt( +result: Jwt = users.create_jwt( user_id = '<USER_ID>', session_id = '<SESSION_ID>', # optional duration = 0 # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-md-5-user.md b/docs/examples/users/create-md-5-user.md index f869917..53b45bf 100644 --- a/docs/examples/users/create-md-5-user.md +++ b/docs/examples/users/create-md-5-user.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_md5_user( +result: User = users.create_md5_user( user_id = '<USER_ID>', email = 'email@example.com', password = 'password', name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index d6da65b..0c83df4 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import MfaRecoveryCodes client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_mfa_recovery_codes( +result: MfaRecoveryCodes = users.create_mfa_recovery_codes( user_id = '<USER_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-ph-pass-user.md b/docs/examples/users/create-ph-pass-user.md index c762b98..456a04b 100644 --- a/docs/examples/users/create-ph-pass-user.md +++ b/docs/examples/users/create-ph-pass-user.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_ph_pass_user( +result: User = users.create_ph_pass_user( user_id = '<USER_ID>', email = 'email@example.com', password = 'password', name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index 9a87d14..e802270 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_scrypt_modified_user( +result: User = users.create_scrypt_modified_user( user_id = '<USER_ID>', email = 'email@example.com', password = 'password', @@ -18,4 +19,6 @@ result = users.create_scrypt_modified_user( password_signer_key = '<PASSWORD_SIGNER_KEY>', name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index d83d951..db5618b 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_scrypt_user( +result: User = users.create_scrypt_user( user_id = '<USER_ID>', email = 'email@example.com', password = 'password', @@ -20,4 +21,6 @@ result = users.create_scrypt_user( password_length = None, name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md index 0ab75f0..38a6dbc 100644 --- a/docs/examples/users/create-session.md +++ b/docs/examples/users/create-session.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import Session client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_session( +result: Session = users.create_session( user_id = '<USER_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-sha-user.md b/docs/examples/users/create-sha-user.md index 674a4c2..9d42300 100644 --- a/docs/examples/users/create-sha-user.md +++ b/docs/examples/users/create-sha-user.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User from appwrite.enums import PasswordHash client = Client() @@ -10,11 +11,13 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_sha_user( +result: User = users.create_sha_user( user_id = '<USER_ID>', email = 'email@example.com', password = 'password', password_version = PasswordHash.SHA1, # optional name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md index 0308994..fcfd394 100644 --- a/docs/examples/users/create-target.md +++ b/docs/examples/users/create-target.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import Target from appwrite.enums import MessagingProviderType client = Client() @@ -10,7 +11,7 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_target( +result: Target = users.create_target( user_id = '<USER_ID>', target_id = '<TARGET_ID>', provider_type = MessagingProviderType.EMAIL, @@ -18,4 +19,6 @@ result = users.create_target( provider_id = '<PROVIDER_ID>', # optional name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md index e4ac48a..d7520f5 100644 --- a/docs/examples/users/create-token.md +++ b/docs/examples/users/create-token.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import Token client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create_token( +result: Token = users.create_token( user_id = '<USER_ID>', length = 4, # optional expire = 60 # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 4ce1c21..38361cb 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.create( +result: User = users.create( user_id = '<USER_ID>', email = 'email@example.com', # optional phone = '+12065550100', # optional password = '', # optional name = '<NAME>' # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md index cf0d67c..058aedd 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import MfaRecoveryCodes client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.get_mfa_recovery_codes( +result: MfaRecoveryCodes = users.get_mfa_recovery_codes( user_id = '<USER_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index f95cc59..093b920 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import Preferences client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.get_prefs( +result: Preferences = users.get_prefs( user_id = '<USER_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md index 8fe84df..38a7d63 100644 --- a/docs/examples/users/get-target.md +++ b/docs/examples/users/get-target.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import Target client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.get_target( +result: Target = users.get_target( user_id = '<USER_ID>', target_id = '<TARGET_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index 0cc21b6..941d428 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.get( +result: User = users.get( user_id = '<USER_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index 2b19132..c6e7d8d 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import IdentityList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.list_identities( +result: IdentityList = users.list_identities( queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index 5604d4c..34d41e7 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import LogList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.list_logs( +result: LogList = users.list_logs( user_id = '<USER_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index 7f01abf..c64d7ba 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import MembershipList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,10 +10,12 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.list_memberships( +result: MembershipList = users.list_memberships( user_id = '<USER_ID>', queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index c5d285f..69f5a56 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import MfaFactors client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.list_mfa_factors( +result: MfaFactors = users.list_mfa_factors( user_id = '<USER_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index 2b2970d..e8abced 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import SessionList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.list_sessions( +result: SessionList = users.list_sessions( user_id = '<USER_ID>', total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md index 3942583..e043866 100644 --- a/docs/examples/users/list-targets.md +++ b/docs/examples/users/list-targets.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import TargetList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.list_targets( +result: TargetList = users.list_targets( user_id = '<USER_ID>', queries = [], # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index f16566d..0d623a7 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import UserList client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,9 +10,11 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.list( +result: UserList = users.list( queries = [], # optional search = '<SEARCH>', # optional total = False # optional ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md index e494f64..8fd0513 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_email_verification( +result: User = users.update_email_verification( user_id = '<USER_ID>', email_verification = False ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index 4434b6e..7dcf066 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_email( +result: User = users.update_email( user_id = '<USER_ID>', email = 'email@example.com' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 23d9f6f..bffba0c 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_labels( +result: User = users.update_labels( user_id = '<USER_ID>', labels = [] ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md index 39e8442..c9090ee 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import MfaRecoveryCodes client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,7 +10,9 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_mfa_recovery_codes( +result: MfaRecoveryCodes = users.update_mfa_recovery_codes( user_id = '<USER_ID>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index 0f92c2e..4dda390 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_mfa( +result: User = users.update_mfa( user_id = '<USER_ID>', mfa = False ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 5e9fc00..248411b 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_name( +result: User = users.update_name( user_id = '<USER_ID>', name = '<NAME>' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index 5d6bdc8..2a0c932 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_password( +result: User = users.update_password( user_id = '<USER_ID>', password = '' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md index 4ee7d00..6b31202 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_phone_verification( +result: User = users.update_phone_verification( user_id = '<USER_ID>', phone_verification = False ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md index 1f96389..82f8e15 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_phone( +result: User = users.update_phone( user_id = '<USER_ID>', number = '+12065550100' ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index ec2f0a4..6d1f043 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import Preferences client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_prefs( +result: Preferences = users.update_prefs( user_id = '<USER_ID>', prefs = {} ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index 28918ba..fcf8d0e 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import User client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,8 +10,10 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_status( +result: User = users.update_status( user_id = '<USER_ID>', status = False ) + +print(result.model_dump()) ``` diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md index c1c30ed..1a7c5f1 100644 --- a/docs/examples/users/update-target.md +++ b/docs/examples/users/update-target.md @@ -1,6 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.models import Target client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -9,11 +10,13 @@ client.set_key('<YOUR_API_KEY>') # Your secret API key users = Users(client) -result = users.update_target( +result: Target = users.update_target( user_id = '<USER_ID>', target_id = '<TARGET_ID>', identifier = '<IDENTIFIER>', # optional provider_id = '<PROVIDER_ID>', # optional name = '<NAME>' # optional ) + +print(result.model_dump()) ``` From fa289e06cb241f8dd1c285687caf8dce6792ae9a Mon Sep 17 00:00:00 2001 From: root <chiragaggarwal5k@gmail.com> Date: Sat, 7 Mar 2026 04:29:00 +0000 Subject: [PATCH 4/6] chore: update Python SDK to 16.0.0 --- appwrite/models/base_model.py | 2 +- docs/examples/databases/get-attribute.md | 1 + docs/examples/locale/get.md | 4 ++-- docs/examples/tablesdb/get-column.md | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/appwrite/models/base_model.py b/appwrite/models/base_model.py index d5b8d9b..cb8a10d 100644 --- a/appwrite/models/base_model.py +++ b/appwrite/models/base_model.py @@ -21,7 +21,7 @@ def from_dict(cls: Type[ModelType], data: Optional[Dict[str, Any]]) -> Optional[ return cls.model_validate(data) def to_dict(self) -> Dict[str, Any]: - return self.model_dump(by_alias=True, mode='json') + return self.model_dump(by_alias=True, mode='json', exclude_unset=True) def to_json(self) -> str: return self.model_dump_json(by_alias=True) diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index 1e73fc0..d841226 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -11,6 +11,7 @@ from appwrite.models import AttributeIp from appwrite.models import AttributeDatetime from appwrite.models import AttributeRelationship from appwrite.models import AttributeString +from typing import Union client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index 35ecbf8..bef85fa 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -1,7 +1,7 @@ ```python from appwrite.client import Client from appwrite.services.locale import Locale -from appwrite.models import Locale +from appwrite.models import Locale as LocaleModel client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -10,7 +10,7 @@ client.set_session('') # The user session to authenticate with locale = Locale(client) -result: Locale = locale.get() +result: LocaleModel = locale.get() print(result.model_dump()) ``` diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md index 1ccced6..7749246 100644 --- a/docs/examples/tablesdb/get-column.md +++ b/docs/examples/tablesdb/get-column.md @@ -11,6 +11,7 @@ from appwrite.models import ColumnIp from appwrite.models import ColumnDatetime from appwrite.models import ColumnRelationship from appwrite.models import ColumnString +from typing import Union client = Client() client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint From 3f0b4ce4f36e8fd5477e0450753a8cd003616526 Mon Sep 17 00:00:00 2001 From: root <chiragaggarwal5k@gmail.com> Date: Sat, 7 Mar 2026 08:53:01 +0000 Subject: [PATCH 5/6] chore: update Python SDK to 16.0.0 --- CHANGELOG.md | 5 +- README.md | 50 ++++ appwrite/models/activity_event.py | 5 +- appwrite/models/activity_event_list.py | 5 +- appwrite/models/algo_argon2.py | 5 +- appwrite/models/algo_bcrypt.py | 5 +- appwrite/models/algo_md5.py | 5 +- appwrite/models/algo_phpass.py | 5 +- appwrite/models/algo_scrypt.py | 5 +- appwrite/models/algo_scrypt_modified.py | 5 +- appwrite/models/algo_sha.py | 5 +- appwrite/models/attribute_boolean.py | 5 +- appwrite/models/attribute_datetime.py | 5 +- appwrite/models/attribute_email.py | 5 +- appwrite/models/attribute_enum.py | 5 +- appwrite/models/attribute_float.py | 5 +- appwrite/models/attribute_integer.py | 5 +- appwrite/models/attribute_ip.py | 5 +- appwrite/models/attribute_line.py | 5 +- appwrite/models/attribute_list.py | 5 +- appwrite/models/attribute_longtext.py | 5 +- appwrite/models/attribute_mediumtext.py | 5 +- appwrite/models/attribute_point.py | 5 +- appwrite/models/attribute_polygon.py | 5 +- appwrite/models/attribute_relationship.py | 5 +- appwrite/models/attribute_string.py | 5 +- appwrite/models/attribute_text.py | 5 +- appwrite/models/attribute_url.py | 5 +- appwrite/models/attribute_varchar.py | 5 +- appwrite/models/backup_archive.py | 5 +- appwrite/models/backup_archive_list.py | 5 +- appwrite/models/backup_policy.py | 5 +- appwrite/models/backup_policy_list.py | 5 +- appwrite/models/backup_restoration.py | 5 +- appwrite/models/backup_restoration_list.py | 5 +- appwrite/models/bucket.py | 5 +- appwrite/models/bucket_list.py | 5 +- appwrite/models/collection.py | 5 +- appwrite/models/collection_list.py | 5 +- appwrite/models/column_boolean.py | 5 +- appwrite/models/column_datetime.py | 5 +- appwrite/models/column_email.py | 5 +- appwrite/models/column_enum.py | 5 +- appwrite/models/column_float.py | 5 +- appwrite/models/column_index.py | 5 +- appwrite/models/column_index_list.py | 5 +- appwrite/models/column_integer.py | 5 +- appwrite/models/column_ip.py | 5 +- appwrite/models/column_line.py | 5 +- appwrite/models/column_list.py | 5 +- appwrite/models/column_longtext.py | 5 +- appwrite/models/column_mediumtext.py | 5 +- appwrite/models/column_point.py | 5 +- appwrite/models/column_polygon.py | 5 +- appwrite/models/column_relationship.py | 5 +- appwrite/models/column_string.py | 5 +- appwrite/models/column_text.py | 5 +- appwrite/models/column_url.py | 5 +- appwrite/models/column_varchar.py | 5 +- appwrite/models/continent.py | 5 +- appwrite/models/continent_list.py | 5 +- appwrite/models/country.py | 5 +- appwrite/models/country_list.py | 5 +- appwrite/models/currency.py | 5 +- appwrite/models/currency_list.py | 5 +- appwrite/models/database.py | 5 +- appwrite/models/database_list.py | 5 +- appwrite/models/deployment.py | 5 +- appwrite/models/deployment_list.py | 5 +- appwrite/models/document.py | 39 ++- appwrite/models/document_list.py | 24 +- appwrite/models/execution.py | 5 +- appwrite/models/execution_list.py | 5 +- appwrite/models/file.py | 5 +- appwrite/models/file_list.py | 5 +- appwrite/models/framework.py | 5 +- appwrite/models/framework_adapter.py | 5 +- appwrite/models/framework_list.py | 5 +- appwrite/models/function.py | 5 +- appwrite/models/function_list.py | 5 +- appwrite/models/headers.py | 5 +- appwrite/models/health_antivirus.py | 5 +- appwrite/models/health_certificate.py | 5 +- appwrite/models/health_queue.py | 5 +- appwrite/models/health_status.py | 5 +- appwrite/models/health_status_list.py | 5 +- appwrite/models/health_time.py | 5 +- appwrite/models/identity.py | 5 +- appwrite/models/identity_list.py | 5 +- appwrite/models/index.py | 5 +- appwrite/models/index_list.py | 5 +- appwrite/models/jwt.py | 5 +- appwrite/models/language.py | 5 +- appwrite/models/language_list.py | 5 +- appwrite/models/locale.py | 5 +- appwrite/models/locale_code.py | 5 +- appwrite/models/locale_code_list.py | 5 +- appwrite/models/log.py | 5 +- appwrite/models/log_list.py | 5 +- appwrite/models/membership.py | 5 +- appwrite/models/membership_list.py | 5 +- appwrite/models/message.py | 5 +- appwrite/models/message_list.py | 5 +- appwrite/models/mfa_challenge.py | 5 +- appwrite/models/mfa_factors.py | 5 +- appwrite/models/mfa_recovery_codes.py | 5 +- appwrite/models/mfa_type.py | 5 +- appwrite/models/phone.py | 5 +- appwrite/models/phone_list.py | 5 +- appwrite/models/preferences.py | 39 ++- appwrite/models/provider.py | 5 +- appwrite/models/provider_list.py | 5 +- appwrite/models/resource_token.py | 5 +- appwrite/models/resource_token_list.py | 5 +- appwrite/models/row.py | 39 ++- appwrite/models/row_list.py | 24 +- appwrite/models/runtime.py | 5 +- appwrite/models/runtime_list.py | 5 +- appwrite/models/session.py | 5 +- appwrite/models/session_list.py | 5 +- appwrite/models/site.py | 5 +- appwrite/models/site_list.py | 5 +- appwrite/models/specification.py | 5 +- appwrite/models/specification_list.py | 5 +- appwrite/models/subscriber.py | 5 +- appwrite/models/subscriber_list.py | 5 +- appwrite/models/table.py | 5 +- appwrite/models/table_list.py | 5 +- appwrite/models/target.py | 5 +- appwrite/models/target_list.py | 5 +- appwrite/models/team.py | 23 +- appwrite/models/team_list.py | 24 +- appwrite/models/token.py | 5 +- appwrite/models/topic.py | 5 +- appwrite/models/topic_list.py | 5 +- appwrite/models/transaction.py | 5 +- appwrite/models/transaction_list.py | 5 +- appwrite/models/user.py | 23 +- appwrite/models/user_list.py | 24 +- appwrite/models/variable.py | 5 +- appwrite/models/variable_list.py | 5 +- appwrite/services/account.py | 221 ++++++++-------- appwrite/services/activities.py | 6 +- appwrite/services/backups.py | 30 +-- appwrite/services/databases.py | 278 ++++++++++---------- appwrite/services/functions.py | 63 ++--- appwrite/services/health.py | 87 +++---- appwrite/services/locale.py | 24 +- appwrite/services/messaging.py | 132 ++++------ appwrite/services/sites.py | 60 ++--- appwrite/services/storage.py | 24 +- appwrite/services/tables_db.py | 278 ++++++++++---------- appwrite/services/teams.py | 85 ++++--- appwrite/services/tokens.py | 12 +- appwrite/services/users.py | 280 ++++++++++++--------- 155 files changed, 1264 insertions(+), 1280 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcea0fd..4eab50e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,12 @@ ## 16.0.0 * Breaking change: All service methods now return typed Pydantic models instead of `Dict[str, Any]` +* Breaking change: Models with dynamic fields (e.g., `Row`, `Document`) now store user-defined data in a typed `.data` property instead of direct attribute access * Breaking change: Added `pydantic>=2,<3` as a required dependency * Breaking change: Minimum Python version raised from 3.5 to 3.9 * Added `AppwriteModel` base class (Pydantic `BaseModel`) for all response models with `from_dict()` and `to_dict()` helpers * Added 130+ typed model classes under `appwrite/models/` (e.g., `Database`, `Collection`, `Document`, `User`, `Session`, `File`, `Bucket`, etc.) -* Added `ActivityEvent` and `ActivityEventList` models and `Activities` service -* Added `ValueClassEncoder` support for serializing `AppwriteModel` instances -* Added `pyproject.toml` for modern Python packaging +* Added Generic[T] support for models with dynamic fields (e.g., `Row`, `Document`) - pass `model_type=YourModel` to methods like `get_row()` or `list_rows()` for type-safe access to user-defined data via `result.data.field_name` * Updated README with `uv add appwrite` installation example * Updated all doc examples to use typed response models (e.g., `result: TemplateFunctionList = functions.list_templates(...)`) diff --git a/README.md b/README.md index ed749b5..a1316dc 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,56 @@ print(user.name) # Access fields as attributes print(user.to_dict()) # Convert to dictionary if needed ``` +### Type Safety with Models + +The Appwrite Python SDK provides type safety when working with database rows through generic methods. Methods like `get_row`, `list_rows`, and others accept a `model_type` parameter that allows you to specify your custom Pydantic model for full type safety. + +```python +from pydantic import BaseModel +from datetime import datetime +from typing import Optional +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +# Define your custom model matching your table schema +class Post(BaseModel): + postId: int + authorId: int + title: str + content: str + createdAt: datetime + updatedAt: datetime + isPublished: bool + excerpt: Optional[str] = None + +client = Client() +# ... configure your client ... + +tables_db = TablesDB(client) + +# Fetch a single row with type safety +row = tables_db.get_row( + database_id="your-database-id", + table_id="your-table-id", + row_id="your-row-id", + model_type=Post # Pass your custom model type +) + +print(row.data.title) # Fully typed - IDE autocomplete works +print(row.data.postId) # int type, not Any +print(row.data.createdAt) # datetime type + +# Fetch multiple rows with type safety +result = tables_db.list_rows( + database_id="your-database-id", + table_id="your-table-id", + model_type=Post +) + +for row in result.rows: + print(f"{row.data.title} by {row.data.authorId}") +``` + ### Error Handling The Appwrite Python SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example. diff --git a/appwrite/models/activity_event.py b/appwrite/models/activity_event.py index 030503b..1d4daf6 100644 --- a/appwrite/models/activity_event.py +++ b/appwrite/models/activity_event.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/activity_event_list.py b/appwrite/models/activity_event_list.py index 70ca316..8e5ad68 100644 --- a/appwrite/models/activity_event_list.py +++ b/appwrite/models/activity_event_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .activity_event import ActivityEvent diff --git a/appwrite/models/algo_argon2.py b/appwrite/models/algo_argon2.py index af06717..7a36400 100644 --- a/appwrite/models/algo_argon2.py +++ b/appwrite/models/algo_argon2.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/algo_bcrypt.py b/appwrite/models/algo_bcrypt.py index fcd2b56..da13f69 100644 --- a/appwrite/models/algo_bcrypt.py +++ b/appwrite/models/algo_bcrypt.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/algo_md5.py b/appwrite/models/algo_md5.py index f90a07d..a907b24 100644 --- a/appwrite/models/algo_md5.py +++ b/appwrite/models/algo_md5.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/algo_phpass.py b/appwrite/models/algo_phpass.py index 86a323e..b899255 100644 --- a/appwrite/models/algo_phpass.py +++ b/appwrite/models/algo_phpass.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/algo_scrypt.py b/appwrite/models/algo_scrypt.py index 17285ed..b88ae26 100644 --- a/appwrite/models/algo_scrypt.py +++ b/appwrite/models/algo_scrypt.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/algo_scrypt_modified.py b/appwrite/models/algo_scrypt_modified.py index c2809a2..a6bc6fb 100644 --- a/appwrite/models/algo_scrypt_modified.py +++ b/appwrite/models/algo_scrypt_modified.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/algo_sha.py b/appwrite/models/algo_sha.py index bf8b6ea..c780904 100644 --- a/appwrite/models/algo_sha.py +++ b/appwrite/models/algo_sha.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/attribute_boolean.py b/appwrite/models/attribute_boolean.py index 016b120..af48afe 100644 --- a/appwrite/models/attribute_boolean.py +++ b/appwrite/models/attribute_boolean.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_datetime.py b/appwrite/models/attribute_datetime.py index 4dadf7b..90295f5 100644 --- a/appwrite/models/attribute_datetime.py +++ b/appwrite/models/attribute_datetime.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_email.py b/appwrite/models/attribute_email.py index a7d80e0..498c512 100644 --- a/appwrite/models/attribute_email.py +++ b/appwrite/models/attribute_email.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_enum.py b/appwrite/models/attribute_enum.py index ce088a4..0059a9a 100644 --- a/appwrite/models/attribute_enum.py +++ b/appwrite/models/attribute_enum.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_float.py b/appwrite/models/attribute_float.py index b0bdc39..2de6c42 100644 --- a/appwrite/models/attribute_float.py +++ b/appwrite/models/attribute_float.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_integer.py b/appwrite/models/attribute_integer.py index da51a5d..dcf8a92 100644 --- a/appwrite/models/attribute_integer.py +++ b/appwrite/models/attribute_integer.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_ip.py b/appwrite/models/attribute_ip.py index 6823e8c..ed3bc2e 100644 --- a/appwrite/models/attribute_ip.py +++ b/appwrite/models/attribute_ip.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_line.py b/appwrite/models/attribute_line.py index 67500a2..1313a62 100644 --- a/appwrite/models/attribute_line.py +++ b/appwrite/models/attribute_line.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_list.py b/appwrite/models/attribute_list.py index 38f1005..ae9101c 100644 --- a/appwrite/models/attribute_list.py +++ b/appwrite/models/attribute_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .attribute_boolean import AttributeBoolean diff --git a/appwrite/models/attribute_longtext.py b/appwrite/models/attribute_longtext.py index 41412b8..4806679 100644 --- a/appwrite/models/attribute_longtext.py +++ b/appwrite/models/attribute_longtext.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_mediumtext.py b/appwrite/models/attribute_mediumtext.py index 84dd00a..eb309c7 100644 --- a/appwrite/models/attribute_mediumtext.py +++ b/appwrite/models/attribute_mediumtext.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_point.py b/appwrite/models/attribute_point.py index 8a83bdb..9c89b10 100644 --- a/appwrite/models/attribute_point.py +++ b/appwrite/models/attribute_point.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_polygon.py b/appwrite/models/attribute_polygon.py index 842d181..9a9411e 100644 --- a/appwrite/models/attribute_polygon.py +++ b/appwrite/models/attribute_polygon.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_relationship.py b/appwrite/models/attribute_relationship.py index 17a5119..d242162 100644 --- a/appwrite/models/attribute_relationship.py +++ b/appwrite/models/attribute_relationship.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_string.py b/appwrite/models/attribute_string.py index 8ad77ab..22b3789 100644 --- a/appwrite/models/attribute_string.py +++ b/appwrite/models/attribute_string.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_text.py b/appwrite/models/attribute_text.py index 58a40ef..141f315 100644 --- a/appwrite/models/attribute_text.py +++ b/appwrite/models/attribute_text.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_url.py b/appwrite/models/attribute_url.py index b7f0845..bcc581e 100644 --- a/appwrite/models/attribute_url.py +++ b/appwrite/models/attribute_url.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/attribute_varchar.py b/appwrite/models/attribute_varchar.py index c55edbe..1c47297 100644 --- a/appwrite/models/attribute_varchar.py +++ b/appwrite/models/attribute_varchar.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.attribute_status import AttributeStatus diff --git a/appwrite/models/backup_archive.py b/appwrite/models/backup_archive.py index 71c4164..a3459c0 100644 --- a/appwrite/models/backup_archive.py +++ b/appwrite/models/backup_archive.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/backup_archive_list.py b/appwrite/models/backup_archive_list.py index 7545bf9..d91188b 100644 --- a/appwrite/models/backup_archive_list.py +++ b/appwrite/models/backup_archive_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .backup_archive import BackupArchive diff --git a/appwrite/models/backup_policy.py b/appwrite/models/backup_policy.py index 683df57..8b67ca7 100644 --- a/appwrite/models/backup_policy.py +++ b/appwrite/models/backup_policy.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/backup_policy_list.py b/appwrite/models/backup_policy_list.py index 8836bbc..b3e2f2d 100644 --- a/appwrite/models/backup_policy_list.py +++ b/appwrite/models/backup_policy_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .backup_policy import BackupPolicy diff --git a/appwrite/models/backup_restoration.py b/appwrite/models/backup_restoration.py index 5b91042..4e13b1e 100644 --- a/appwrite/models/backup_restoration.py +++ b/appwrite/models/backup_restoration.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/backup_restoration_list.py b/appwrite/models/backup_restoration_list.py index b0bba25..d272fba 100644 --- a/appwrite/models/backup_restoration_list.py +++ b/appwrite/models/backup_restoration_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .backup_restoration import BackupRestoration diff --git a/appwrite/models/bucket.py b/appwrite/models/bucket.py index ba731c5..141fe2b 100644 --- a/appwrite/models/bucket.py +++ b/appwrite/models/bucket.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/bucket_list.py b/appwrite/models/bucket_list.py index 7f202e3..f1dbbb0 100644 --- a/appwrite/models/bucket_list.py +++ b/appwrite/models/bucket_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .bucket import Bucket diff --git a/appwrite/models/collection.py b/appwrite/models/collection.py index 5b8efa7..db1d054 100644 --- a/appwrite/models/collection.py +++ b/appwrite/models/collection.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .attribute_boolean import AttributeBoolean diff --git a/appwrite/models/collection_list.py b/appwrite/models/collection_list.py index 90f6641..14c896a 100644 --- a/appwrite/models/collection_list.py +++ b/appwrite/models/collection_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .collection import Collection diff --git a/appwrite/models/column_boolean.py b/appwrite/models/column_boolean.py index 7e68a0f..f81e8ec 100644 --- a/appwrite/models/column_boolean.py +++ b/appwrite/models/column_boolean.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_datetime.py b/appwrite/models/column_datetime.py index 1236004..8345d5e 100644 --- a/appwrite/models/column_datetime.py +++ b/appwrite/models/column_datetime.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_email.py b/appwrite/models/column_email.py index b7a4c2d..7e08c1c 100644 --- a/appwrite/models/column_email.py +++ b/appwrite/models/column_email.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_enum.py b/appwrite/models/column_enum.py index a780076..8930aa9 100644 --- a/appwrite/models/column_enum.py +++ b/appwrite/models/column_enum.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_float.py b/appwrite/models/column_float.py index 577ade5..46c77bc 100644 --- a/appwrite/models/column_float.py +++ b/appwrite/models/column_float.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_index.py b/appwrite/models/column_index.py index 9eacbdb..eaa4b8d 100644 --- a/appwrite/models/column_index.py +++ b/appwrite/models/column_index.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/column_index_list.py b/appwrite/models/column_index_list.py index 05fbd8f..fcb3645 100644 --- a/appwrite/models/column_index_list.py +++ b/appwrite/models/column_index_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .column_index import ColumnIndex diff --git a/appwrite/models/column_integer.py b/appwrite/models/column_integer.py index 0dffb8d..340dd21 100644 --- a/appwrite/models/column_integer.py +++ b/appwrite/models/column_integer.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_ip.py b/appwrite/models/column_ip.py index 3dd44d3..3240a6f 100644 --- a/appwrite/models/column_ip.py +++ b/appwrite/models/column_ip.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_line.py b/appwrite/models/column_line.py index d0861c9..280b987 100644 --- a/appwrite/models/column_line.py +++ b/appwrite/models/column_line.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_list.py b/appwrite/models/column_list.py index 2a6092f..d6f05bd 100644 --- a/appwrite/models/column_list.py +++ b/appwrite/models/column_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .column_boolean import ColumnBoolean diff --git a/appwrite/models/column_longtext.py b/appwrite/models/column_longtext.py index b66f75a..8feaa26 100644 --- a/appwrite/models/column_longtext.py +++ b/appwrite/models/column_longtext.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_mediumtext.py b/appwrite/models/column_mediumtext.py index 8be1678..817063e 100644 --- a/appwrite/models/column_mediumtext.py +++ b/appwrite/models/column_mediumtext.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_point.py b/appwrite/models/column_point.py index 78be38b..63802f5 100644 --- a/appwrite/models/column_point.py +++ b/appwrite/models/column_point.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_polygon.py b/appwrite/models/column_polygon.py index 5361347..0cdb990 100644 --- a/appwrite/models/column_polygon.py +++ b/appwrite/models/column_polygon.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_relationship.py b/appwrite/models/column_relationship.py index fc088e0..acc95a1 100644 --- a/appwrite/models/column_relationship.py +++ b/appwrite/models/column_relationship.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_string.py b/appwrite/models/column_string.py index e58b2a6..28f5d64 100644 --- a/appwrite/models/column_string.py +++ b/appwrite/models/column_string.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_text.py b/appwrite/models/column_text.py index 692d0b4..b0622d3 100644 --- a/appwrite/models/column_text.py +++ b/appwrite/models/column_text.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_url.py b/appwrite/models/column_url.py index 76f70de..fe13692 100644 --- a/appwrite/models/column_url.py +++ b/appwrite/models/column_url.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/column_varchar.py b/appwrite/models/column_varchar.py index 65dade5..1c7a688 100644 --- a/appwrite/models/column_varchar.py +++ b/appwrite/models/column_varchar.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.column_status import ColumnStatus diff --git a/appwrite/models/continent.py b/appwrite/models/continent.py index 2f56544..18f68d7 100644 --- a/appwrite/models/continent.py +++ b/appwrite/models/continent.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/continent_list.py b/appwrite/models/continent_list.py index 0cdf932..35d970d 100644 --- a/appwrite/models/continent_list.py +++ b/appwrite/models/continent_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .continent import Continent diff --git a/appwrite/models/country.py b/appwrite/models/country.py index c064450..46223ea 100644 --- a/appwrite/models/country.py +++ b/appwrite/models/country.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/country_list.py b/appwrite/models/country_list.py index df8d054..b666a97 100644 --- a/appwrite/models/country_list.py +++ b/appwrite/models/country_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .country import Country diff --git a/appwrite/models/currency.py b/appwrite/models/currency.py index c6f9329..4a46b04 100644 --- a/appwrite/models/currency.py +++ b/appwrite/models/currency.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/currency_list.py b/appwrite/models/currency_list.py index 18a104e..c92a05d 100644 --- a/appwrite/models/currency_list.py +++ b/appwrite/models/currency_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .currency import Currency diff --git a/appwrite/models/database.py b/appwrite/models/database.py index 22f5f7e..6ae78b5 100644 --- a/appwrite/models/database.py +++ b/appwrite/models/database.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.database_type import DatabaseType diff --git a/appwrite/models/database_list.py b/appwrite/models/database_list.py index f55e3e7..aaa1030 100644 --- a/appwrite/models/database_list.py +++ b/appwrite/models/database_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .database import Database diff --git a/appwrite/models/deployment.py b/appwrite/models/deployment.py index b36bbae..13c3f73 100644 --- a/appwrite/models/deployment.py +++ b/appwrite/models/deployment.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.deployment_status import DeploymentStatus diff --git a/appwrite/models/deployment_list.py b/appwrite/models/deployment_list.py index f84950f..6ed143c 100644 --- a/appwrite/models/deployment_list.py +++ b/appwrite/models/deployment_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .deployment import Deployment diff --git a/appwrite/models/document.py b/appwrite/models/document.py index 31e2b32..8b3913b 100644 --- a/appwrite/models/document.py +++ b/appwrite/models/document.py @@ -1,10 +1,11 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel -class Document(AppwriteModel): +T = TypeVar('T') + +class Document(AppwriteModel, Generic[T]): """ Document @@ -32,3 +33,33 @@ class Document(AppwriteModel): createdat: str = Field(..., alias='$createdAt') updatedat: str = Field(..., alias='$updatedAt') permissions: List[Any] = Field(..., alias='$permissions') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'Document[T]': + """Create Document instance with typed data.""" + internal_fields = {k: v for k, v in data.items() if k.startswith('$')} + user_data = {k: v for k, v in data.items() if not k.startswith('$')} + instance = cls.model_validate(internal_fields) + instance._data = model_type(**user_data) if model_type is not dict else user_data + return instance + + _data: Any = PrivateAttr(default_factory=dict) + + @property + def data(self) -> T: + return cast(T, self._data) + + @data.setter + def data(self, value: T) -> None: + object.__setattr__(self, '_data', value) + + def to_dict(self) -> Dict[str, Any]: + result = super().to_dict() + if hasattr(self, '_data'): + if isinstance(self._data, dict): + result['data'] = self._data + elif hasattr(self._data, 'model_dump'): + result['data'] = self._data.model_dump(mode='json') + else: + result['data'] = self._data + return result diff --git a/appwrite/models/document_list.py b/appwrite/models/document_list.py index 6c6a0cf..a73bb75 100644 --- a/appwrite/models/document_list.py +++ b/appwrite/models/document_list.py @@ -1,11 +1,12 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .document import Document -class DocumentList(AppwriteModel): +T = TypeVar('T') + +class DocumentList(AppwriteModel, Generic[T]): """ Documents List @@ -13,8 +14,19 @@ class DocumentList(AppwriteModel): ---------- total : float Total number of documents that matched your query. - documents : List[Document] + documents : List[Document[T]] List of documents. """ total: float = Field(..., alias='total') - documents: List[Document] = Field(..., alias='documents') + documents: List[Document[T]] = Field(..., alias='documents') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'DocumentList[T]': + """Create DocumentList instance with typed data.""" + instance = cls.model_validate(data) + if 'documents' in data and data['documents'] is not None: + instance.documents = [ + Document.with_data(row, model_type) + for row in data['documents'] + ] + return instance diff --git a/appwrite/models/execution.py b/appwrite/models/execution.py index 48c5122..eaf9a80 100644 --- a/appwrite/models/execution.py +++ b/appwrite/models/execution.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.execution_trigger import ExecutionTrigger diff --git a/appwrite/models/execution_list.py b/appwrite/models/execution_list.py index d5d83ef..3d336d2 100644 --- a/appwrite/models/execution_list.py +++ b/appwrite/models/execution_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .execution import Execution diff --git a/appwrite/models/file.py b/appwrite/models/file.py index 4567b97..8eb4590 100644 --- a/appwrite/models/file.py +++ b/appwrite/models/file.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/file_list.py b/appwrite/models/file_list.py index f05a9a9..4ab21cd 100644 --- a/appwrite/models/file_list.py +++ b/appwrite/models/file_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .file import File diff --git a/appwrite/models/framework.py b/appwrite/models/framework.py index 6f88c67..6bfe759 100644 --- a/appwrite/models/framework.py +++ b/appwrite/models/framework.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .framework_adapter import FrameworkAdapter diff --git a/appwrite/models/framework_adapter.py b/appwrite/models/framework_adapter.py index a4c8aaf..e7c567f 100644 --- a/appwrite/models/framework_adapter.py +++ b/appwrite/models/framework_adapter.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/framework_list.py b/appwrite/models/framework_list.py index d6266bf..60ec6b4 100644 --- a/appwrite/models/framework_list.py +++ b/appwrite/models/framework_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .framework import Framework diff --git a/appwrite/models/function.py b/appwrite/models/function.py index 6f0b24d..1f6c1d6 100644 --- a/appwrite/models/function.py +++ b/appwrite/models/function.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .variable import Variable diff --git a/appwrite/models/function_list.py b/appwrite/models/function_list.py index 153f4fa..2beb1e8 100644 --- a/appwrite/models/function_list.py +++ b/appwrite/models/function_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .function import Function diff --git a/appwrite/models/headers.py b/appwrite/models/headers.py index 837cf1b..6775537 100644 --- a/appwrite/models/headers.py +++ b/appwrite/models/headers.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/health_antivirus.py b/appwrite/models/health_antivirus.py index a70fb0b..4e15043 100644 --- a/appwrite/models/health_antivirus.py +++ b/appwrite/models/health_antivirus.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.health_antivirus_status import HealthAntivirusStatus diff --git a/appwrite/models/health_certificate.py b/appwrite/models/health_certificate.py index 4ab76d1..58999e7 100644 --- a/appwrite/models/health_certificate.py +++ b/appwrite/models/health_certificate.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/health_queue.py b/appwrite/models/health_queue.py index 7969b05..f9dcf66 100644 --- a/appwrite/models/health_queue.py +++ b/appwrite/models/health_queue.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/health_status.py b/appwrite/models/health_status.py index ca46b68..0ae1146 100644 --- a/appwrite/models/health_status.py +++ b/appwrite/models/health_status.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.health_check_status import HealthCheckStatus diff --git a/appwrite/models/health_status_list.py b/appwrite/models/health_status_list.py index c645e04..2690437 100644 --- a/appwrite/models/health_status_list.py +++ b/appwrite/models/health_status_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .health_status import HealthStatus diff --git a/appwrite/models/health_time.py b/appwrite/models/health_time.py index b564cbf..240694d 100644 --- a/appwrite/models/health_time.py +++ b/appwrite/models/health_time.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/identity.py b/appwrite/models/identity.py index 54acec9..4f5ab56 100644 --- a/appwrite/models/identity.py +++ b/appwrite/models/identity.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/identity_list.py b/appwrite/models/identity_list.py index 9a64574..02abfdf 100644 --- a/appwrite/models/identity_list.py +++ b/appwrite/models/identity_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .identity import Identity diff --git a/appwrite/models/index.py b/appwrite/models/index.py index 0c2b960..9fc6d03 100644 --- a/appwrite/models/index.py +++ b/appwrite/models/index.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.index_status import IndexStatus diff --git a/appwrite/models/index_list.py b/appwrite/models/index_list.py index 2357189..a0984a7 100644 --- a/appwrite/models/index_list.py +++ b/appwrite/models/index_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .index import Index diff --git a/appwrite/models/jwt.py b/appwrite/models/jwt.py index 6931b33..b68dd3d 100644 --- a/appwrite/models/jwt.py +++ b/appwrite/models/jwt.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/language.py b/appwrite/models/language.py index d501a1b..7738126 100644 --- a/appwrite/models/language.py +++ b/appwrite/models/language.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/language_list.py b/appwrite/models/language_list.py index 87608df..815ef98 100644 --- a/appwrite/models/language_list.py +++ b/appwrite/models/language_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .language import Language diff --git a/appwrite/models/locale.py b/appwrite/models/locale.py index bc64d2a..95952e1 100644 --- a/appwrite/models/locale.py +++ b/appwrite/models/locale.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/locale_code.py b/appwrite/models/locale_code.py index 051aae4..5e845f4 100644 --- a/appwrite/models/locale_code.py +++ b/appwrite/models/locale_code.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/locale_code_list.py b/appwrite/models/locale_code_list.py index a1aeedc..c4118a3 100644 --- a/appwrite/models/locale_code_list.py +++ b/appwrite/models/locale_code_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .locale_code import LocaleCode diff --git a/appwrite/models/log.py b/appwrite/models/log.py index fbb8bff..c2ccd08 100644 --- a/appwrite/models/log.py +++ b/appwrite/models/log.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/log_list.py b/appwrite/models/log_list.py index f0f826f..5eb0940 100644 --- a/appwrite/models/log_list.py +++ b/appwrite/models/log_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .log import Log diff --git a/appwrite/models/membership.py b/appwrite/models/membership.py index 66600d9..b309efd 100644 --- a/appwrite/models/membership.py +++ b/appwrite/models/membership.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/membership_list.py b/appwrite/models/membership_list.py index 2ea17b4..4ac7aa3 100644 --- a/appwrite/models/membership_list.py +++ b/appwrite/models/membership_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .membership import Membership diff --git a/appwrite/models/message.py b/appwrite/models/message.py index 818ebba..e1189c4 100644 --- a/appwrite/models/message.py +++ b/appwrite/models/message.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from ..enums.message_status import MessageStatus diff --git a/appwrite/models/message_list.py b/appwrite/models/message_list.py index 8520366..87513c8 100644 --- a/appwrite/models/message_list.py +++ b/appwrite/models/message_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .message import Message diff --git a/appwrite/models/mfa_challenge.py b/appwrite/models/mfa_challenge.py index 4458c5a..c05ec3d 100644 --- a/appwrite/models/mfa_challenge.py +++ b/appwrite/models/mfa_challenge.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/mfa_factors.py b/appwrite/models/mfa_factors.py index 1fc312d..1392c1d 100644 --- a/appwrite/models/mfa_factors.py +++ b/appwrite/models/mfa_factors.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/mfa_recovery_codes.py b/appwrite/models/mfa_recovery_codes.py index 1038950..a9f6491 100644 --- a/appwrite/models/mfa_recovery_codes.py +++ b/appwrite/models/mfa_recovery_codes.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/mfa_type.py b/appwrite/models/mfa_type.py index 47f62aa..a24ea21 100644 --- a/appwrite/models/mfa_type.py +++ b/appwrite/models/mfa_type.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/phone.py b/appwrite/models/phone.py index 6e6e3ef..8242ee1 100644 --- a/appwrite/models/phone.py +++ b/appwrite/models/phone.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/phone_list.py b/appwrite/models/phone_list.py index 89c0499..b84cde1 100644 --- a/appwrite/models/phone_list.py +++ b/appwrite/models/phone_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .phone import Phone diff --git a/appwrite/models/preferences.py b/appwrite/models/preferences.py index 082bb4d..01f36c3 100644 --- a/appwrite/models/preferences.py +++ b/appwrite/models/preferences.py @@ -1,11 +1,42 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel -class Preferences(AppwriteModel): +T = TypeVar('T') + +class Preferences(AppwriteModel, Generic[T]): """ Preferences """ pass + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'Preferences[T]': + """Create Preferences instance with typed data.""" + internal_fields = {k: v for k, v in data.items() if k.startswith('$')} + user_data = {k: v for k, v in data.items() if not k.startswith('$')} + instance = cls.model_validate(internal_fields) + instance._data = model_type(**user_data) if model_type is not dict else user_data + return instance + + _data: Any = PrivateAttr(default_factory=dict) + + @property + def data(self) -> T: + return cast(T, self._data) + + @data.setter + def data(self, value: T) -> None: + object.__setattr__(self, '_data', value) + + def to_dict(self) -> Dict[str, Any]: + result = super().to_dict() + if hasattr(self, '_data'): + if isinstance(self._data, dict): + result['data'] = self._data + elif hasattr(self._data, 'model_dump'): + result['data'] = self._data.model_dump(mode='json') + else: + result['data'] = self._data + return result diff --git a/appwrite/models/provider.py b/appwrite/models/provider.py index fbfe1f5..88a28b8 100644 --- a/appwrite/models/provider.py +++ b/appwrite/models/provider.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/provider_list.py b/appwrite/models/provider_list.py index 5db7086..9f476dc 100644 --- a/appwrite/models/provider_list.py +++ b/appwrite/models/provider_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .provider import Provider diff --git a/appwrite/models/resource_token.py b/appwrite/models/resource_token.py index 52e96eb..35eff96 100644 --- a/appwrite/models/resource_token.py +++ b/appwrite/models/resource_token.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/resource_token_list.py b/appwrite/models/resource_token_list.py index e5e181e..422ebc4 100644 --- a/appwrite/models/resource_token_list.py +++ b/appwrite/models/resource_token_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .resource_token import ResourceToken diff --git a/appwrite/models/row.py b/appwrite/models/row.py index 4ec3131..9508143 100644 --- a/appwrite/models/row.py +++ b/appwrite/models/row.py @@ -1,10 +1,11 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel -class Row(AppwriteModel): +T = TypeVar('T') + +class Row(AppwriteModel, Generic[T]): """ Row @@ -32,3 +33,33 @@ class Row(AppwriteModel): createdat: str = Field(..., alias='$createdAt') updatedat: str = Field(..., alias='$updatedAt') permissions: List[Any] = Field(..., alias='$permissions') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'Row[T]': + """Create Row instance with typed data.""" + internal_fields = {k: v for k, v in data.items() if k.startswith('$')} + user_data = {k: v for k, v in data.items() if not k.startswith('$')} + instance = cls.model_validate(internal_fields) + instance._data = model_type(**user_data) if model_type is not dict else user_data + return instance + + _data: Any = PrivateAttr(default_factory=dict) + + @property + def data(self) -> T: + return cast(T, self._data) + + @data.setter + def data(self, value: T) -> None: + object.__setattr__(self, '_data', value) + + def to_dict(self) -> Dict[str, Any]: + result = super().to_dict() + if hasattr(self, '_data'): + if isinstance(self._data, dict): + result['data'] = self._data + elif hasattr(self._data, 'model_dump'): + result['data'] = self._data.model_dump(mode='json') + else: + result['data'] = self._data + return result diff --git a/appwrite/models/row_list.py b/appwrite/models/row_list.py index fa60620..86ca37a 100644 --- a/appwrite/models/row_list.py +++ b/appwrite/models/row_list.py @@ -1,11 +1,12 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .row import Row -class RowList(AppwriteModel): +T = TypeVar('T') + +class RowList(AppwriteModel, Generic[T]): """ Rows List @@ -13,8 +14,19 @@ class RowList(AppwriteModel): ---------- total : float Total number of rows that matched your query. - rows : List[Row] + rows : List[Row[T]] List of rows. """ total: float = Field(..., alias='total') - rows: List[Row] = Field(..., alias='rows') + rows: List[Row[T]] = Field(..., alias='rows') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'RowList[T]': + """Create RowList instance with typed data.""" + instance = cls.model_validate(data) + if 'rows' in data and data['rows'] is not None: + instance.rows = [ + Row.with_data(row, model_type) + for row in data['rows'] + ] + return instance diff --git a/appwrite/models/runtime.py b/appwrite/models/runtime.py index 5ae4ed6..f42ea12 100644 --- a/appwrite/models/runtime.py +++ b/appwrite/models/runtime.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/runtime_list.py b/appwrite/models/runtime_list.py index 87015ec..34d0334 100644 --- a/appwrite/models/runtime_list.py +++ b/appwrite/models/runtime_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .runtime import Runtime diff --git a/appwrite/models/session.py b/appwrite/models/session.py index fba571c..8487c1c 100644 --- a/appwrite/models/session.py +++ b/appwrite/models/session.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/session_list.py b/appwrite/models/session_list.py index dcec9cc..6b37cb5 100644 --- a/appwrite/models/session_list.py +++ b/appwrite/models/session_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .session import Session diff --git a/appwrite/models/site.py b/appwrite/models/site.py index d838ad3..718f282 100644 --- a/appwrite/models/site.py +++ b/appwrite/models/site.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .variable import Variable diff --git a/appwrite/models/site_list.py b/appwrite/models/site_list.py index c8376d7..87eb672 100644 --- a/appwrite/models/site_list.py +++ b/appwrite/models/site_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .site import Site diff --git a/appwrite/models/specification.py b/appwrite/models/specification.py index c3d2751..832cfb8 100644 --- a/appwrite/models/specification.py +++ b/appwrite/models/specification.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/specification_list.py b/appwrite/models/specification_list.py index d75f51a..d302f94 100644 --- a/appwrite/models/specification_list.py +++ b/appwrite/models/specification_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .specification import Specification diff --git a/appwrite/models/subscriber.py b/appwrite/models/subscriber.py index 2569c1b..a0a6c1d 100644 --- a/appwrite/models/subscriber.py +++ b/appwrite/models/subscriber.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .target import Target diff --git a/appwrite/models/subscriber_list.py b/appwrite/models/subscriber_list.py index 446769c..35bf843 100644 --- a/appwrite/models/subscriber_list.py +++ b/appwrite/models/subscriber_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .subscriber import Subscriber diff --git a/appwrite/models/table.py b/appwrite/models/table.py index dfb05f7..50759f9 100644 --- a/appwrite/models/table.py +++ b/appwrite/models/table.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .column_boolean import ColumnBoolean diff --git a/appwrite/models/table_list.py b/appwrite/models/table_list.py index f086e39..f617c91 100644 --- a/appwrite/models/table_list.py +++ b/appwrite/models/table_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .table import Table diff --git a/appwrite/models/target.py b/appwrite/models/target.py index 6cae848..d68a52d 100644 --- a/appwrite/models/target.py +++ b/appwrite/models/target.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/target_list.py b/appwrite/models/target_list.py index 7398cf2..dd99f7a 100644 --- a/appwrite/models/target_list.py +++ b/appwrite/models/target_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .target import Target diff --git a/appwrite/models/team.py b/appwrite/models/team.py index 26e1086..9298951 100644 --- a/appwrite/models/team.py +++ b/appwrite/models/team.py @@ -1,11 +1,12 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .preferences import Preferences -class Team(AppwriteModel): +T = TypeVar('T') + +class Team(AppwriteModel, Generic[T]): """ Team @@ -21,7 +22,7 @@ class Team(AppwriteModel): Team name. total : float Total number of team members. - prefs : Preferences + prefs : Preferences[T] Team preferences as a key-value object """ id: str = Field(..., alias='$id') @@ -29,4 +30,14 @@ class Team(AppwriteModel): updatedat: str = Field(..., alias='$updatedAt') name: str = Field(..., alias='name') total: float = Field(..., alias='total') - prefs: Preferences = Field(..., alias='prefs') + prefs: Preferences[T] = Field(..., alias='prefs') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'Team[T]': + """Create Team instance with typed data.""" + instance = cls.model_validate(data) + if 'prefs' in data and data['prefs'] is not None: + instance.prefs = Preferences.with_data( + data['prefs'], model_type + ) + return instance diff --git a/appwrite/models/team_list.py b/appwrite/models/team_list.py index f587966..81602c9 100644 --- a/appwrite/models/team_list.py +++ b/appwrite/models/team_list.py @@ -1,11 +1,12 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .team import Team -class TeamList(AppwriteModel): +T = TypeVar('T') + +class TeamList(AppwriteModel, Generic[T]): """ Teams List @@ -13,8 +14,19 @@ class TeamList(AppwriteModel): ---------- total : float Total number of teams that matched your query. - teams : List[Team] + teams : List[Team[T]] List of teams. """ total: float = Field(..., alias='total') - teams: List[Team] = Field(..., alias='teams') + teams: List[Team[T]] = Field(..., alias='teams') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'TeamList[T]': + """Create TeamList instance with typed data.""" + instance = cls.model_validate(data) + if 'teams' in data and data['teams'] is not None: + instance.teams = [ + Team.with_data(row, model_type) + for row in data['teams'] + ] + return instance diff --git a/appwrite/models/token.py b/appwrite/models/token.py index e59e023..5bc7588 100644 --- a/appwrite/models/token.py +++ b/appwrite/models/token.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/topic.py b/appwrite/models/topic.py index fd9370f..04dad6c 100644 --- a/appwrite/models/topic.py +++ b/appwrite/models/topic.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/topic_list.py b/appwrite/models/topic_list.py index 88e654e..a217a8c 100644 --- a/appwrite/models/topic_list.py +++ b/appwrite/models/topic_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .topic import Topic diff --git a/appwrite/models/transaction.py b/appwrite/models/transaction.py index 762c3f9..e1dd7af 100644 --- a/appwrite/models/transaction.py +++ b/appwrite/models/transaction.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/transaction_list.py b/appwrite/models/transaction_list.py index b571f2c..b85aaec 100644 --- a/appwrite/models/transaction_list.py +++ b/appwrite/models/transaction_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .transaction import Transaction diff --git a/appwrite/models/user.py b/appwrite/models/user.py index 9a110c8..51a1223 100644 --- a/appwrite/models/user.py +++ b/appwrite/models/user.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .algo_argon2 import AlgoArgon2 @@ -13,7 +12,9 @@ from .preferences import Preferences from .target import Target -class User(AppwriteModel): +T = TypeVar('T') + +class User(AppwriteModel, Generic[T]): """ User @@ -51,7 +52,7 @@ class User(AppwriteModel): Phone verification status. mfa : bool Multi factor authentication status. - prefs : Preferences + prefs : Preferences[T] User preferences as a key-value object targets : List[Target] A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. @@ -74,6 +75,16 @@ class User(AppwriteModel): emailverification: bool = Field(..., alias='emailVerification') phoneverification: bool = Field(..., alias='phoneVerification') mfa: bool = Field(..., alias='mfa') - prefs: Preferences = Field(..., alias='prefs') + prefs: Preferences[T] = Field(..., alias='prefs') targets: List[Target] = Field(..., alias='targets') accessedat: str = Field(..., alias='accessedAt') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'User[T]': + """Create User instance with typed data.""" + instance = cls.model_validate(data) + if 'prefs' in data and data['prefs'] is not None: + instance.prefs = Preferences.with_data( + data['prefs'], model_type + ) + return instance diff --git a/appwrite/models/user_list.py b/appwrite/models/user_list.py index 632c812..c6c2e62 100644 --- a/appwrite/models/user_list.py +++ b/appwrite/models/user_list.py @@ -1,11 +1,12 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .user import User -class UserList(AppwriteModel): +T = TypeVar('T') + +class UserList(AppwriteModel, Generic[T]): """ Users List @@ -13,8 +14,19 @@ class UserList(AppwriteModel): ---------- total : float Total number of users that matched your query. - users : List[User] + users : List[User[T]] List of users. """ total: float = Field(..., alias='total') - users: List[User] = Field(..., alias='users') + users: List[User[T]] = Field(..., alias='users') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'UserList[T]': + """Create UserList instance with typed data.""" + instance = cls.model_validate(data) + if 'users' in data and data['users'] is not None: + instance.users = [ + User.with_data(row, model_type) + for row in data['users'] + ] + return instance diff --git a/appwrite/models/variable.py b/appwrite/models/variable.py index fee92ba..2988077 100644 --- a/appwrite/models/variable.py +++ b/appwrite/models/variable.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel diff --git a/appwrite/models/variable_list.py b/appwrite/models/variable_list.py index 7b973c9..bb140a2 100644 --- a/appwrite/models/variable_list.py +++ b/appwrite/models/variable_list.py @@ -1,6 +1,5 @@ -from typing import Any, Dict, List, Optional, Union - -from pydantic import Field +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr from .base_model import AppwriteModel from .variable import Variable diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 6580bb8..b6ab073 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -1,5 +1,5 @@ from ..service import Service -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union, Type, TypeVar from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated from ..models.user import User; @@ -18,20 +18,28 @@ from ..models.session_list import SessionList; from ..enums.o_auth_provider import OAuthProvider; +T = TypeVar('T') + class Account(Service): def __init__(self, client) -> None: super(Account, self).__init__(client) def get( - self ) -> User: + self, + model_type: Type[T] = dict ) -> User[T]: """ Get the currently logged in user. + Parameters + ---------- + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -45,7 +53,7 @@ def get( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create( @@ -53,7 +61,8 @@ def create( user_id: str, email: str, password: str, - name: Optional[str] = None ) -> User: + name: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). @@ -68,10 +77,12 @@ def create( name : Optional[str] User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -101,13 +112,14 @@ def create( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def update_email( self, email: str, - password: str ) -> User: + password: str, + model_type: Type[T] = dict ) -> User[T]: """ Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. @@ -120,10 +132,12 @@ def update_email( password : str User password. Must be at least 8 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -147,7 +161,7 @@ def update_email( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def list_identities( @@ -166,8 +180,7 @@ def list_identities( Returns ------- - IdentityList - API response as a typed Pydantic model + IdentityList API response as a typed Pydantic model Raises ------ @@ -239,8 +252,7 @@ def create_jwt( Returns ------- - Jwt - API response as a typed Pydantic model + Jwt API response as a typed Pydantic model Raises ------ @@ -277,8 +289,7 @@ def list_logs( Returns ------- - LogList - API response as a typed Pydantic model + LogList API response as a typed Pydantic model Raises ------ @@ -302,7 +313,8 @@ def list_logs( def update_mfa( self, - mfa: bool ) -> User: + mfa: bool, + model_type: Type[T] = dict ) -> User[T]: """ Enable or disable MFA on an account. @@ -311,10 +323,12 @@ def update_mfa( mfa : bool Enable or disable MFA. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -334,7 +348,7 @@ def update_mfa( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_mfa_authenticator( @@ -350,8 +364,7 @@ def create_mfa_authenticator( Returns ------- - MfaType - API response as a typed Pydantic model + MfaType API response as a typed Pydantic model Raises ------ @@ -377,7 +390,8 @@ def create_mfa_authenticator( def update_mfa_authenticator( self, type: AuthenticatorType, - otp: str ) -> User: + otp: str, + model_type: Type[T] = dict ) -> User[T]: """ Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. @@ -388,10 +402,12 @@ def update_mfa_authenticator( otp : str Valid verification token. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -415,7 +431,7 @@ def update_mfa_authenticator( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def delete_mfa_authenticator( @@ -468,8 +484,7 @@ def create_mfa_challenge( Returns ------- - MfaChallenge - API response as a typed Pydantic model + MfaChallenge API response as a typed Pydantic model Raises ------ @@ -508,8 +523,7 @@ def update_mfa_challenge( Returns ------- - Session - API response as a typed Pydantic model + Session API response as a typed Pydantic model Raises ------ @@ -543,8 +557,7 @@ def list_mfa_factors( Returns ------- - MfaFactors - API response as a typed Pydantic model + MfaFactors API response as a typed Pydantic model Raises ------ @@ -568,8 +581,7 @@ def get_mfa_recovery_codes( Returns ------- - MfaRecoveryCodes - API response as a typed Pydantic model + MfaRecoveryCodes API response as a typed Pydantic model Raises ------ @@ -593,8 +605,7 @@ def create_mfa_recovery_codes( Returns ------- - MfaRecoveryCodes - API response as a typed Pydantic model + MfaRecoveryCodes API response as a typed Pydantic model Raises ------ @@ -619,8 +630,7 @@ def update_mfa_recovery_codes( Returns ------- - MfaRecoveryCodes - API response as a typed Pydantic model + MfaRecoveryCodes API response as a typed Pydantic model Raises ------ @@ -640,7 +650,8 @@ def update_mfa_recovery_codes( def update_name( self, - name: str ) -> User: + name: str, + model_type: Type[T] = dict ) -> User[T]: """ Update currently logged in user account name. @@ -649,10 +660,12 @@ def update_name( name : str User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -672,13 +685,14 @@ def update_name( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def update_password( self, password: str, - old_password: Optional[str] = None ) -> User: + old_password: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. @@ -689,10 +703,12 @@ def update_password( old_password : Optional[str] Current user password. Must be at least 8 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -714,13 +730,14 @@ def update_password( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def update_phone( self, phone: str, - password: str ) -> User: + password: str, + model_type: Type[T] = dict ) -> User[T]: """ Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. @@ -731,10 +748,12 @@ def update_phone( password : str User password. Must be at least 8 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -758,18 +777,24 @@ def update_phone( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def get_prefs( - self ) -> Preferences: + self, + model_type: Type[T] = dict ) -> Preferences[T]: """ Get the preferences as a key-value object for the currently logged in user. + Parameters + ---------- + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Preferences - API response as a typed Pydantic model + Preferences[T] API response as a typed Pydantic model Raises ------ @@ -783,12 +808,13 @@ def get_prefs( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=Preferences) + return Preferences.with_data(response, model_type) def update_prefs( self, - prefs: Dict[str, Any] ) -> User: + prefs: Dict[str, Any], + model_type: Type[T] = dict ) -> User[T]: """ Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. @@ -797,10 +823,12 @@ def update_prefs( prefs : Dict[str, Any] Prefs key-value JSON object. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -820,7 +848,7 @@ def update_prefs( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_recovery( @@ -839,8 +867,7 @@ def create_recovery( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -888,8 +915,7 @@ def update_recovery( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -927,8 +953,7 @@ def list_sessions( Returns ------- - SessionList - API response as a typed Pydantic model + SessionList API response as a typed Pydantic model Raises ------ @@ -978,8 +1003,7 @@ def create_anonymous_session( Returns ------- - Session - API response as a typed Pydantic model + Session API response as a typed Pydantic model Raises ------ @@ -1015,8 +1039,7 @@ def create_email_password_session( Returns ------- - Session - API response as a typed Pydantic model + Session API response as a typed Pydantic model Raises ------ @@ -1062,8 +1085,7 @@ def update_magic_url_session( Returns ------- - Session - API response as a typed Pydantic model + Session API response as a typed Pydantic model Raises ------ @@ -1109,8 +1131,7 @@ def update_phone_session( Returns ------- - Session - API response as a typed Pydantic model + Session API response as a typed Pydantic model Raises ------ @@ -1153,8 +1174,7 @@ def create_session( Returns ------- - Session - API response as a typed Pydantic model + Session API response as a typed Pydantic model Raises ------ @@ -1194,8 +1214,7 @@ def get_session( Returns ------- - Session - API response as a typed Pydantic model + Session API response as a typed Pydantic model Raises ------ @@ -1230,8 +1249,7 @@ def update_session( Returns ------- - Session - API response as a typed Pydantic model + Session API response as a typed Pydantic model Raises ------ @@ -1292,14 +1310,20 @@ def delete_session( def update_status( - self ) -> User: + self, + model_type: Type[T] = dict ) -> User[T]: """ Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. + Parameters + ---------- + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -1314,7 +1338,7 @@ def update_status( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_email_token( @@ -1339,8 +1363,7 @@ def create_email_token( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -1394,8 +1417,7 @@ def create_magic_url_token( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -1499,8 +1521,7 @@ def create_phone_token( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -1543,8 +1564,7 @@ def create_email_verification( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -1586,8 +1606,7 @@ def create_verification( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -1626,8 +1645,7 @@ def update_email_verification( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -1673,8 +1691,7 @@ def update_verification( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -1708,8 +1725,7 @@ def create_phone_verification( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -1743,8 +1759,7 @@ def update_phone_verification( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/activities.py b/appwrite/services/activities.py index cc91583..7e65465 100644 --- a/appwrite/services/activities.py +++ b/appwrite/services/activities.py @@ -23,8 +23,7 @@ def list_events( Returns ------- - ActivityEventList - API response as a typed Pydantic model + ActivityEventList API response as a typed Pydantic model Raises ------ @@ -58,8 +57,7 @@ def get_event( Returns ------- - ActivityEvent - API response as a typed Pydantic model + ActivityEvent API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/backups.py b/appwrite/services/backups.py index 154c66f..755fadb 100644 --- a/appwrite/services/backups.py +++ b/appwrite/services/backups.py @@ -28,8 +28,7 @@ def list_archives( Returns ------- - BackupArchiveList - API response as a typed Pydantic model + BackupArchiveList API response as a typed Pydantic model Raises ------ @@ -65,8 +64,7 @@ def create_archive( Returns ------- - BackupArchive - API response as a typed Pydantic model + BackupArchive API response as a typed Pydantic model Raises ------ @@ -103,8 +101,7 @@ def get_archive( Returns ------- - BackupArchive - API response as a typed Pydantic model + BackupArchive API response as a typed Pydantic model Raises ------ @@ -176,8 +173,7 @@ def list_policies( Returns ------- - BackupPolicyList - API response as a typed Pydantic model + BackupPolicyList API response as a typed Pydantic model Raises ------ @@ -228,8 +224,7 @@ def create_policy( Returns ------- - BackupPolicy - API response as a typed Pydantic model + BackupPolicy API response as a typed Pydantic model Raises ------ @@ -282,8 +277,7 @@ def get_policy( Returns ------- - BackupPolicy - API response as a typed Pydantic model + BackupPolicy API response as a typed Pydantic model Raises ------ @@ -330,8 +324,7 @@ def update_policy( Returns ------- - BackupPolicy - API response as a typed Pydantic model + BackupPolicy API response as a typed Pydantic model Raises ------ @@ -418,8 +411,7 @@ def create_restoration( Returns ------- - BackupRestoration - API response as a typed Pydantic model + BackupRestoration API response as a typed Pydantic model Raises ------ @@ -463,8 +455,7 @@ def list_restorations( Returns ------- - BackupRestorationList - API response as a typed Pydantic model + BackupRestorationList API response as a typed Pydantic model Raises ------ @@ -497,8 +488,7 @@ def get_restoration( Returns ------- - BackupRestoration - API response as a typed Pydantic model + BackupRestoration API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index b2c65bd..2595561 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -1,5 +1,5 @@ from ..service import Service -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union, Type, TypeVar from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated from ..models.database_list import DatabaseList; @@ -35,6 +35,8 @@ from ..enums.order_by import OrderBy; from ..models.index import Index; +T = TypeVar('T') + class Databases(Service): def __init__(self, client) -> None: @@ -62,8 +64,7 @@ def list( Returns ------- - DatabaseList - API response as a typed Pydantic model + DatabaseList API response as a typed Pydantic model Raises ------ @@ -110,8 +111,7 @@ def create( Returns ------- - Database - API response as a typed Pydantic model + Database API response as a typed Pydantic model Raises ------ @@ -153,8 +153,7 @@ def list_transactions( Returns ------- - TransactionList - API response as a typed Pydantic model + TransactionList API response as a typed Pydantic model Raises ------ @@ -187,8 +186,7 @@ def create_transaction( Returns ------- - Transaction - API response as a typed Pydantic model + Transaction API response as a typed Pydantic model Raises ------ @@ -222,8 +220,7 @@ def get_transaction( Returns ------- - Transaction - API response as a typed Pydantic model + Transaction API response as a typed Pydantic model Raises ------ @@ -264,8 +261,7 @@ def update_transaction( Returns ------- - Transaction - API response as a typed Pydantic model + Transaction API response as a typed Pydantic model Raises ------ @@ -345,8 +341,7 @@ def create_operations( Returns ------- - Transaction - API response as a typed Pydantic model + Transaction API response as a typed Pydantic model Raises ------ @@ -387,8 +382,7 @@ def get( Returns ------- - Database - API response as a typed Pydantic model + Database API response as a typed Pydantic model Raises ------ @@ -432,8 +426,7 @@ def update( Returns ------- - Database - API response as a typed Pydantic model + Database API response as a typed Pydantic model Raises ------ @@ -525,8 +518,7 @@ def list_collections( Returns ------- - CollectionList - API response as a typed Pydantic model + CollectionList API response as a typed Pydantic model Raises ------ @@ -591,8 +583,7 @@ def create_collection( Returns ------- - Collection - API response as a typed Pydantic model + Collection API response as a typed Pydantic model Raises ------ @@ -651,8 +642,7 @@ def get_collection( Returns ------- - Collection - API response as a typed Pydantic model + Collection API response as a typed Pydantic model Raises ------ @@ -709,8 +699,7 @@ def update_collection( Returns ------- - Collection - API response as a typed Pydantic model + Collection API response as a typed Pydantic model Raises ------ @@ -816,8 +805,7 @@ def list_attributes( Returns ------- - AttributeList - API response as a typed Pydantic model + AttributeList API response as a typed Pydantic model Raises ------ @@ -879,8 +867,7 @@ def create_boolean_attribute( Returns ------- - AttributeBoolean - API response as a typed Pydantic model + AttributeBoolean API response as a typed Pydantic model Raises ------ @@ -949,8 +936,7 @@ def update_boolean_attribute( Returns ------- - AttributeBoolean - API response as a typed Pydantic model + AttributeBoolean API response as a typed Pydantic model Raises ------ @@ -1018,8 +1004,7 @@ def create_datetime_attribute( Returns ------- - AttributeDatetime - API response as a typed Pydantic model + AttributeDatetime API response as a typed Pydantic model Raises ------ @@ -1088,8 +1073,7 @@ def update_datetime_attribute( Returns ------- - AttributeDatetime - API response as a typed Pydantic model + AttributeDatetime API response as a typed Pydantic model Raises ------ @@ -1158,8 +1142,7 @@ def create_email_attribute( Returns ------- - AttributeEmail - API response as a typed Pydantic model + AttributeEmail API response as a typed Pydantic model Raises ------ @@ -1229,8 +1212,7 @@ def update_email_attribute( Returns ------- - AttributeEmail - API response as a typed Pydantic model + AttributeEmail API response as a typed Pydantic model Raises ------ @@ -1302,8 +1284,7 @@ def create_enum_attribute( Returns ------- - AttributeEnum - API response as a typed Pydantic model + AttributeEnum API response as a typed Pydantic model Raises ------ @@ -1380,8 +1361,7 @@ def update_enum_attribute( Returns ------- - AttributeEnum - API response as a typed Pydantic model + AttributeEnum API response as a typed Pydantic model Raises ------ @@ -1460,8 +1440,7 @@ def create_float_attribute( Returns ------- - AttributeFloat - API response as a typed Pydantic model + AttributeFloat API response as a typed Pydantic model Raises ------ @@ -1539,8 +1518,7 @@ def update_float_attribute( Returns ------- - AttributeFloat - API response as a typed Pydantic model + AttributeFloat API response as a typed Pydantic model Raises ------ @@ -1617,8 +1595,7 @@ def create_integer_attribute( Returns ------- - AttributeInteger - API response as a typed Pydantic model + AttributeInteger API response as a typed Pydantic model Raises ------ @@ -1696,8 +1673,7 @@ def update_integer_attribute( Returns ------- - AttributeInteger - API response as a typed Pydantic model + AttributeInteger API response as a typed Pydantic model Raises ------ @@ -1768,8 +1744,7 @@ def create_ip_attribute( Returns ------- - AttributeIp - API response as a typed Pydantic model + AttributeIp API response as a typed Pydantic model Raises ------ @@ -1839,8 +1814,7 @@ def update_ip_attribute( Returns ------- - AttributeIp - API response as a typed Pydantic model + AttributeIp API response as a typed Pydantic model Raises ------ @@ -1905,8 +1879,7 @@ def create_line_attribute( Returns ------- - AttributeLine - API response as a typed Pydantic model + AttributeLine API response as a typed Pydantic model Raises ------ @@ -1973,8 +1946,7 @@ def update_line_attribute( Returns ------- - AttributeLine - API response as a typed Pydantic model + AttributeLine API response as a typed Pydantic model Raises ------ @@ -2043,8 +2015,7 @@ def create_longtext_attribute( Returns ------- - AttributeLongtext - API response as a typed Pydantic model + AttributeLongtext API response as a typed Pydantic model Raises ------ @@ -2113,8 +2084,7 @@ def update_longtext_attribute( Returns ------- - AttributeLongtext - API response as a typed Pydantic model + AttributeLongtext API response as a typed Pydantic model Raises ------ @@ -2183,8 +2153,7 @@ def create_mediumtext_attribute( Returns ------- - AttributeMediumtext - API response as a typed Pydantic model + AttributeMediumtext API response as a typed Pydantic model Raises ------ @@ -2253,8 +2222,7 @@ def update_mediumtext_attribute( Returns ------- - AttributeMediumtext - API response as a typed Pydantic model + AttributeMediumtext API response as a typed Pydantic model Raises ------ @@ -2319,8 +2287,7 @@ def create_point_attribute( Returns ------- - AttributePoint - API response as a typed Pydantic model + AttributePoint API response as a typed Pydantic model Raises ------ @@ -2387,8 +2354,7 @@ def update_point_attribute( Returns ------- - AttributePoint - API response as a typed Pydantic model + AttributePoint API response as a typed Pydantic model Raises ------ @@ -2453,8 +2419,7 @@ def create_polygon_attribute( Returns ------- - AttributePolygon - API response as a typed Pydantic model + AttributePolygon API response as a typed Pydantic model Raises ------ @@ -2521,8 +2486,7 @@ def update_polygon_attribute( Returns ------- - AttributePolygon - API response as a typed Pydantic model + AttributePolygon API response as a typed Pydantic model Raises ------ @@ -2597,8 +2561,7 @@ def create_relationship_attribute( Returns ------- - AttributeRelationship - API response as a typed Pydantic model + AttributeRelationship API response as a typed Pydantic model Raises ------ @@ -2668,8 +2631,7 @@ def update_relationship_attribute( Returns ------- - AttributeRelationship - API response as a typed Pydantic model + AttributeRelationship API response as a typed Pydantic model Raises ------ @@ -2741,8 +2703,7 @@ def create_string_attribute( Returns ------- - AttributeString - API response as a typed Pydantic model + AttributeString API response as a typed Pydantic model Raises ------ @@ -2821,8 +2782,7 @@ def update_string_attribute( Returns ------- - AttributeString - API response as a typed Pydantic model + AttributeString API response as a typed Pydantic model Raises ------ @@ -2892,8 +2852,7 @@ def create_text_attribute( Returns ------- - AttributeText - API response as a typed Pydantic model + AttributeText API response as a typed Pydantic model Raises ------ @@ -2962,8 +2921,7 @@ def update_text_attribute( Returns ------- - AttributeText - API response as a typed Pydantic model + AttributeText API response as a typed Pydantic model Raises ------ @@ -3032,8 +2990,7 @@ def create_url_attribute( Returns ------- - AttributeUrl - API response as a typed Pydantic model + AttributeUrl API response as a typed Pydantic model Raises ------ @@ -3103,8 +3060,7 @@ def update_url_attribute( Returns ------- - AttributeUrl - API response as a typed Pydantic model + AttributeUrl API response as a typed Pydantic model Raises ------ @@ -3176,8 +3132,7 @@ def create_varchar_attribute( Returns ------- - AttributeVarchar - API response as a typed Pydantic model + AttributeVarchar API response as a typed Pydantic model Raises ------ @@ -3253,8 +3208,7 @@ def update_varchar_attribute( Returns ------- - AttributeVarchar - API response as a typed Pydantic model + AttributeVarchar API response as a typed Pydantic model Raises ------ @@ -3407,7 +3361,8 @@ def list_documents( queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, total: Optional[bool] = None, - ttl: Optional[float] = None ) -> DocumentList: + ttl: Optional[float] = None, + model_type: Type[T] = dict ) -> DocumentList[T]: """ Get a list of all the user's documents in a given collection. You can use the query params to filter your results. @@ -3428,10 +3383,12 @@ def list_documents( ttl : Optional[float] TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - DocumentList - API response as a typed Pydantic model + DocumentList[T] API response as a typed Pydantic model Raises ------ @@ -3462,7 +3419,7 @@ def list_documents( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=DocumentList) + return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_row` instead.") @@ -3473,7 +3430,8 @@ def create_document( document_id: str, data: Dict[str, Any], permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> Document: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Document[T]: """ Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3494,10 +3452,12 @@ def create_document( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Document - API response as a typed Pydantic model + Document[T] API response as a typed Pydantic model Raises ------ @@ -3531,7 +3491,7 @@ def create_document( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Document) + return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_rows` instead.") @@ -3540,7 +3500,8 @@ def create_documents( database_id: str, collection_id: str, documents: List[Dict[str, Any]], - transaction_id: Optional[str] = None ) -> DocumentList: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> DocumentList[T]: """ Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3557,10 +3518,12 @@ def create_documents( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - DocumentList - API response as a typed Pydantic model + DocumentList[T] API response as a typed Pydantic model Raises ------ @@ -3589,7 +3552,7 @@ def create_documents( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=DocumentList) + return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.upsert_rows` instead.") @@ -3598,7 +3561,8 @@ def upsert_documents( database_id: str, collection_id: str, documents: List[Dict[str, Any]], - transaction_id: Optional[str] = None ) -> DocumentList: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> DocumentList[T]: """ Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3616,10 +3580,12 @@ def upsert_documents( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - DocumentList - API response as a typed Pydantic model + DocumentList[T] API response as a typed Pydantic model Raises ------ @@ -3648,7 +3614,7 @@ def upsert_documents( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=DocumentList) + return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_rows` instead.") @@ -3658,7 +3624,8 @@ def update_documents( collection_id: str, data: Optional[Dict[str, Any]] = None, queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> DocumentList: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> DocumentList[T]: """ Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. @@ -3677,10 +3644,12 @@ def update_documents( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - DocumentList - API response as a typed Pydantic model + DocumentList[T] API response as a typed Pydantic model Raises ------ @@ -3709,7 +3678,7 @@ def update_documents( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=DocumentList) + return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_rows` instead.") @@ -3718,7 +3687,8 @@ def delete_documents( database_id: str, collection_id: str, queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> DocumentList: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> DocumentList[T]: """ Bulk delete documents using queries, if no queries are passed then all documents are deleted. @@ -3735,10 +3705,12 @@ def delete_documents( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - DocumentList - API response as a typed Pydantic model + DocumentList[T] API response as a typed Pydantic model Raises ------ @@ -3765,7 +3737,7 @@ def delete_documents( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=DocumentList) + return DocumentList.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_row` instead.") @@ -3775,7 +3747,8 @@ def get_document( collection_id: str, document_id: str, queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> Document: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Document[T]: """ Get a document by its unique ID. This endpoint response returns a JSON object with the document data. @@ -3794,10 +3767,12 @@ def get_document( transaction_id : Optional[str] Transaction ID to read uncommitted changes within the transaction. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Document - API response as a typed Pydantic model + Document[T] API response as a typed Pydantic model Raises ------ @@ -3828,7 +3803,7 @@ def get_document( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=Document) + return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.upsert_row` instead.") @@ -3839,7 +3814,8 @@ def upsert_document( document_id: str, data: Optional[Dict[str, Any]] = None, permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> Document: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Document[T]: """ Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3860,10 +3836,12 @@ def upsert_document( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Document - API response as a typed Pydantic model + Document[T] API response as a typed Pydantic model Raises ------ @@ -3895,7 +3873,7 @@ def upsert_document( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Document) + return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_row` instead.") @@ -3906,7 +3884,8 @@ def update_document( document_id: str, data: Optional[Dict[str, Any]] = None, permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> Document: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Document[T]: """ Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -3927,10 +3906,12 @@ def update_document( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Document - API response as a typed Pydantic model + Document[T] API response as a typed Pydantic model Raises ------ @@ -3962,7 +3943,7 @@ def update_document( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Document) + return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_row` instead.") @@ -4032,7 +4013,8 @@ def decrement_document_attribute( attribute: str, value: Optional[float] = None, min: Optional[float] = None, - transaction_id: Optional[str] = None ) -> Document: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Document[T]: """ Decrement a specific attribute of a document by a given value. @@ -4055,10 +4037,12 @@ def decrement_document_attribute( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Document - API response as a typed Pydantic model + Document[T] API response as a typed Pydantic model Raises ------ @@ -4094,7 +4078,7 @@ def decrement_document_attribute( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Document) + return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.increment_row_column` instead.") @@ -4106,7 +4090,8 @@ def increment_document_attribute( attribute: str, value: Optional[float] = None, max: Optional[float] = None, - transaction_id: Optional[str] = None ) -> Document: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Document[T]: """ Increment a specific attribute of a document by a given value. @@ -4129,10 +4114,12 @@ def increment_document_attribute( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Document - API response as a typed Pydantic model + Document[T] API response as a typed Pydantic model Raises ------ @@ -4168,7 +4155,7 @@ def increment_document_attribute( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Document) + return Document.with_data(response, model_type) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_indexes` instead.") @@ -4196,8 +4183,7 @@ def list_indexes( Returns ------- - IndexList - API response as a typed Pydantic model + IndexList API response as a typed Pydantic model Raises ------ @@ -4262,8 +4248,7 @@ def create_index( Returns ------- - Index - API response as a typed Pydantic model + Index API response as a typed Pydantic model Raises ------ @@ -4328,8 +4313,7 @@ def get_index( Returns ------- - Index - API response as a typed Pydantic model + Index API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index fabadba..0fdddff 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -44,8 +44,7 @@ def list( Returns ------- - FunctionList - API response as a typed Pydantic model + FunctionList API response as a typed Pydantic model Raises ------ @@ -133,8 +132,7 @@ def create( Returns ------- - Function - API response as a typed Pydantic model + Function API response as a typed Pydantic model Raises ------ @@ -202,8 +200,7 @@ def list_runtimes( Returns ------- - RuntimeList - API response as a typed Pydantic model + RuntimeList API response as a typed Pydantic model Raises ------ @@ -227,8 +224,7 @@ def list_specifications( Returns ------- - SpecificationList - API response as a typed Pydantic model + SpecificationList API response as a typed Pydantic model Raises ------ @@ -258,8 +254,7 @@ def get( Returns ------- - Function - API response as a typed Pydantic model + Function API response as a typed Pydantic model Raises ------ @@ -345,8 +340,7 @@ def update( Returns ------- - Function - API response as a typed Pydantic model + Function API response as a typed Pydantic model Raises ------ @@ -457,8 +451,7 @@ def update_function_deployment( Returns ------- - Function - API response as a typed Pydantic model + Function API response as a typed Pydantic model Raises ------ @@ -507,8 +500,7 @@ def list_deployments( Returns ------- - DeploymentList - API response as a typed Pydantic model + DeploymentList API response as a typed Pydantic model Raises ------ @@ -568,8 +560,7 @@ def create_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -628,8 +619,7 @@ def create_duplicate_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -691,8 +681,7 @@ def create_template_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -761,8 +750,7 @@ def create_vcs_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -811,8 +799,7 @@ def get_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -946,8 +933,7 @@ def update_deployment_status( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -993,8 +979,7 @@ def list_executions( Returns ------- - ExecutionList - API response as a typed Pydantic model + ExecutionList API response as a typed Pydantic model Raises ------ @@ -1051,8 +1036,7 @@ def create_execution( Returns ------- - Execution - API response as a typed Pydantic model + Execution API response as a typed Pydantic model Raises ------ @@ -1102,8 +1086,7 @@ def get_execution( Returns ------- - Execution - API response as a typed Pydantic model + Execution API response as a typed Pydantic model Raises ------ @@ -1186,8 +1169,7 @@ def list_variables( Returns ------- - VariableList - API response as a typed Pydantic model + VariableList API response as a typed Pydantic model Raises ------ @@ -1231,8 +1213,7 @@ def create_variable( Returns ------- - Variable - API response as a typed Pydantic model + Variable API response as a typed Pydantic model Raises ------ @@ -1281,8 +1262,7 @@ def get_variable( Returns ------- - Variable - API response as a typed Pydantic model + Variable API response as a typed Pydantic model Raises ------ @@ -1333,8 +1313,7 @@ def update_variable( Returns ------- - Variable - API response as a typed Pydantic model + Variable API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/health.py b/appwrite/services/health.py index 7249b67..0fc4a98 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -22,8 +22,7 @@ def get( Returns ------- - HealthStatus - API response as a typed Pydantic model + HealthStatus API response as a typed Pydantic model Raises ------ @@ -47,8 +46,7 @@ def get_antivirus( Returns ------- - HealthAntivirus - API response as a typed Pydantic model + HealthAntivirus API response as a typed Pydantic model Raises ------ @@ -72,8 +70,7 @@ def get_cache( Returns ------- - HealthStatusList - API response as a typed Pydantic model + HealthStatusList API response as a typed Pydantic model Raises ------ @@ -103,8 +100,7 @@ def get_certificate( Returns ------- - HealthCertificate - API response as a typed Pydantic model + HealthCertificate API response as a typed Pydantic model Raises ------ @@ -141,8 +137,7 @@ def get_console_pausing( Returns ------- - HealthStatus - API response as a typed Pydantic model + HealthStatus API response as a typed Pydantic model Raises ------ @@ -171,8 +166,7 @@ def get_db( Returns ------- - HealthStatusList - API response as a typed Pydantic model + HealthStatusList API response as a typed Pydantic model Raises ------ @@ -196,8 +190,7 @@ def get_pub_sub( Returns ------- - HealthStatusList - API response as a typed Pydantic model + HealthStatusList API response as a typed Pydantic model Raises ------ @@ -227,8 +220,7 @@ def get_queue_audits( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -261,8 +253,7 @@ def get_queue_billing_project_aggregation( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -295,8 +286,7 @@ def get_queue_billing_team_aggregation( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -329,8 +319,7 @@ def get_queue_builds( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -363,8 +352,7 @@ def get_queue_priority_builds( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -397,8 +385,7 @@ def get_queue_certificates( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -434,8 +421,7 @@ def get_queue_databases( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -470,8 +456,7 @@ def get_queue_deletes( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -508,8 +493,7 @@ def get_failed_jobs( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -546,8 +530,7 @@ def get_queue_functions( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -580,8 +563,7 @@ def get_queue_logs( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -614,8 +596,7 @@ def get_queue_mails( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -648,8 +629,7 @@ def get_queue_messaging( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -682,8 +662,7 @@ def get_queue_migrations( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -716,8 +695,7 @@ def get_queue_region_manager( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -750,8 +728,7 @@ def get_queue_stats_resources( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -784,8 +761,7 @@ def get_queue_usage( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -818,8 +794,7 @@ def get_queue_threats( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -852,8 +827,7 @@ def get_queue_webhooks( Returns ------- - HealthQueue - API response as a typed Pydantic model + HealthQueue API response as a typed Pydantic model Raises ------ @@ -880,8 +854,7 @@ def get_storage( Returns ------- - HealthStatus - API response as a typed Pydantic model + HealthStatus API response as a typed Pydantic model Raises ------ @@ -905,8 +878,7 @@ def get_storage_local( Returns ------- - HealthStatus - API response as a typed Pydantic model + HealthStatus API response as a typed Pydantic model Raises ------ @@ -930,8 +902,7 @@ def get_time( Returns ------- - HealthTime - API response as a typed Pydantic model + HealthTime API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/locale.py b/appwrite/services/locale.py index 4f835c9..0969153 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -24,8 +24,7 @@ def get( Returns ------- - Locale - API response as a typed Pydantic model + LocaleModel API response as a typed Pydantic model Raises ------ @@ -49,8 +48,7 @@ def list_codes( Returns ------- - LocaleCodeList - API response as a typed Pydantic model + LocaleCodeList API response as a typed Pydantic model Raises ------ @@ -74,8 +72,7 @@ def list_continents( Returns ------- - ContinentList - API response as a typed Pydantic model + ContinentList API response as a typed Pydantic model Raises ------ @@ -99,8 +96,7 @@ def list_countries( Returns ------- - CountryList - API response as a typed Pydantic model + CountryList API response as a typed Pydantic model Raises ------ @@ -124,8 +120,7 @@ def list_countries_eu( Returns ------- - CountryList - API response as a typed Pydantic model + CountryList API response as a typed Pydantic model Raises ------ @@ -149,8 +144,7 @@ def list_countries_phones( Returns ------- - PhoneList - API response as a typed Pydantic model + PhoneList API response as a typed Pydantic model Raises ------ @@ -174,8 +168,7 @@ def list_currencies( Returns ------- - CurrencyList - API response as a typed Pydantic model + CurrencyList API response as a typed Pydantic model Raises ------ @@ -199,8 +192,7 @@ def list_languages( Returns ------- - LanguageList - API response as a typed Pydantic model + LanguageList API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/messaging.py b/appwrite/services/messaging.py index 7c66f5f..e7b2e87 100644 --- a/appwrite/services/messaging.py +++ b/appwrite/services/messaging.py @@ -39,8 +39,7 @@ def list_messages( Returns ------- - MessageList - API response as a typed Pydantic model + MessageList API response as a typed Pydantic model Raises ------ @@ -110,8 +109,7 @@ def create_email( Returns ------- - Message - API response as a typed Pydantic model + Message API response as a typed Pydantic model Raises ------ @@ -206,8 +204,7 @@ def update_email( Returns ------- - Message - API response as a typed Pydantic model + Message API response as a typed Pydantic model Raises ------ @@ -308,8 +305,7 @@ def create_push( Returns ------- - Message - API response as a typed Pydantic model + Message API response as a typed Pydantic model Raises ------ @@ -434,8 +430,7 @@ def update_push( Returns ------- - Message - API response as a typed Pydantic model + Message API response as a typed Pydantic model Raises ------ @@ -507,8 +502,7 @@ def create_sms( Returns ------- - Message - API response as a typed Pydantic model + Message API response as a typed Pydantic model Raises ------ @@ -576,8 +570,7 @@ def update_sms( Returns ------- - Message - API response as a typed Pydantic model + Message API response as a typed Pydantic model Raises ------ @@ -620,8 +613,7 @@ def get_message( Returns ------- - Message - API response as a typed Pydantic model + Message API response as a typed Pydantic model Raises ------ @@ -699,8 +691,7 @@ def list_message_logs( Returns ------- - LogList - API response as a typed Pydantic model + LogList API response as a typed Pydantic model Raises ------ @@ -745,8 +736,7 @@ def list_targets( Returns ------- - TargetList - API response as a typed Pydantic model + TargetList API response as a typed Pydantic model Raises ------ @@ -791,8 +781,7 @@ def list_providers( Returns ------- - ProviderList - API response as a typed Pydantic model + ProviderList API response as a typed Pydantic model Raises ------ @@ -850,8 +839,7 @@ def create_apns_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -923,8 +911,7 @@ def update_apns_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -981,8 +968,7 @@ def create_fcm_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1033,8 +1019,7 @@ def update_fcm_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1101,8 +1086,7 @@ def create_mailgun_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1183,8 +1167,7 @@ def update_mailgun_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1251,8 +1234,7 @@ def create_msg91_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1314,8 +1296,7 @@ def update_msg91_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1381,8 +1362,7 @@ def create_resend_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1454,8 +1434,7 @@ def update_resend_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1525,8 +1504,7 @@ def create_sendgrid_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1598,8 +1576,7 @@ def update_sendgrid_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1687,8 +1664,7 @@ def create_smtp_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1792,8 +1768,7 @@ def update_smtp_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1867,8 +1842,7 @@ def create_telesign_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1930,8 +1904,7 @@ def update_telesign_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -1991,8 +1964,7 @@ def create_textmagic_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -2054,8 +2026,7 @@ def update_textmagic_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -2115,8 +2086,7 @@ def create_twilio_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -2178,8 +2148,7 @@ def update_twilio_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -2239,8 +2208,7 @@ def create_vonage_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -2302,8 +2270,7 @@ def update_vonage_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -2349,8 +2316,7 @@ def get_provider( Returns ------- - Provider - API response as a typed Pydantic model + Provider API response as a typed Pydantic model Raises ------ @@ -2428,8 +2394,7 @@ def list_provider_logs( Returns ------- - LogList - API response as a typed Pydantic model + LogList API response as a typed Pydantic model Raises ------ @@ -2474,8 +2439,7 @@ def list_subscriber_logs( Returns ------- - LogList - API response as a typed Pydantic model + LogList API response as a typed Pydantic model Raises ------ @@ -2520,8 +2484,7 @@ def list_topics( Returns ------- - TopicList - API response as a typed Pydantic model + TopicList API response as a typed Pydantic model Raises ------ @@ -2564,8 +2527,7 @@ def create_topic( Returns ------- - Topic - API response as a typed Pydantic model + Topic API response as a typed Pydantic model Raises ------ @@ -2608,8 +2570,7 @@ def get_topic( Returns ------- - Topic - API response as a typed Pydantic model + Topic API response as a typed Pydantic model Raises ------ @@ -2651,8 +2612,7 @@ def update_topic( Returns ------- - Topic - API response as a typed Pydantic model + Topic API response as a typed Pydantic model Raises ------ @@ -2733,8 +2693,7 @@ def list_topic_logs( Returns ------- - LogList - API response as a typed Pydantic model + LogList API response as a typed Pydantic model Raises ------ @@ -2782,8 +2741,7 @@ def list_subscribers( Returns ------- - SubscriberList - API response as a typed Pydantic model + SubscriberList API response as a typed Pydantic model Raises ------ @@ -2830,8 +2788,7 @@ def create_subscriber( Returns ------- - Subscriber - API response as a typed Pydantic model + Subscriber API response as a typed Pydantic model Raises ------ @@ -2879,8 +2836,7 @@ def get_subscriber( Returns ------- - Subscriber - API response as a typed Pydantic model + Subscriber API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index efe4503..0dc2019 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -44,8 +44,7 @@ def list( Returns ------- - SiteList - API response as a typed Pydantic model + SiteList API response as a typed Pydantic model Raises ------ @@ -133,8 +132,7 @@ def create( Returns ------- - Site - API response as a typed Pydantic model + Site API response as a typed Pydantic model Raises ------ @@ -204,8 +202,7 @@ def list_frameworks( Returns ------- - FrameworkList - API response as a typed Pydantic model + FrameworkList API response as a typed Pydantic model Raises ------ @@ -229,8 +226,7 @@ def list_specifications( Returns ------- - SpecificationList - API response as a typed Pydantic model + SpecificationList API response as a typed Pydantic model Raises ------ @@ -260,8 +256,7 @@ def get( Returns ------- - Site - API response as a typed Pydantic model + Site API response as a typed Pydantic model Raises ------ @@ -347,8 +342,7 @@ def update( Returns ------- - Site - API response as a typed Pydantic model + Site API response as a typed Pydantic model Raises ------ @@ -462,8 +456,7 @@ def update_site_deployment( Returns ------- - Site - API response as a typed Pydantic model + Site API response as a typed Pydantic model Raises ------ @@ -512,8 +505,7 @@ def list_deployments( Returns ------- - DeploymentList - API response as a typed Pydantic model + DeploymentList API response as a typed Pydantic model Raises ------ @@ -572,8 +564,7 @@ def create_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -629,8 +620,7 @@ def create_duplicate_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -690,8 +680,7 @@ def create_template_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -760,8 +749,7 @@ def create_vcs_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -810,8 +798,7 @@ def get_deployment( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -945,8 +932,7 @@ def update_deployment_status( Returns ------- - Deployment - API response as a typed Pydantic model + Deployment API response as a typed Pydantic model Raises ------ @@ -992,8 +978,7 @@ def list_logs( Returns ------- - ExecutionList - API response as a typed Pydantic model + ExecutionList API response as a typed Pydantic model Raises ------ @@ -1035,8 +1020,7 @@ def get_log( Returns ------- - Execution - API response as a typed Pydantic model + Execution API response as a typed Pydantic model Raises ------ @@ -1119,8 +1103,7 @@ def list_variables( Returns ------- - VariableList - API response as a typed Pydantic model + VariableList API response as a typed Pydantic model Raises ------ @@ -1164,8 +1147,7 @@ def create_variable( Returns ------- - Variable - API response as a typed Pydantic model + Variable API response as a typed Pydantic model Raises ------ @@ -1214,8 +1196,7 @@ def get_variable( Returns ------- - Variable - API response as a typed Pydantic model + Variable API response as a typed Pydantic model Raises ------ @@ -1266,8 +1247,7 @@ def update_variable( Returns ------- - Variable - API response as a typed Pydantic model + Variable API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index 9569288..72bc61b 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -35,8 +35,7 @@ def list_buckets( Returns ------- - BucketList - API response as a typed Pydantic model + BucketList API response as a typed Pydantic model Raises ------ @@ -103,8 +102,7 @@ def create_bucket( Returns ------- - Bucket - API response as a typed Pydantic model + Bucket API response as a typed Pydantic model Raises ------ @@ -161,8 +159,7 @@ def get_bucket( Returns ------- - Bucket - API response as a typed Pydantic model + Bucket API response as a typed Pydantic model Raises ------ @@ -227,8 +224,7 @@ def update_bucket( Returns ------- - Bucket - API response as a typed Pydantic model + Bucket API response as a typed Pydantic model Raises ------ @@ -331,8 +327,7 @@ def list_files( Returns ------- - FileList - API response as a typed Pydantic model + FileList API response as a typed Pydantic model Raises ------ @@ -392,8 +387,7 @@ def create_file( Returns ------- - File - API response as a typed Pydantic model + File API response as a typed Pydantic model Raises ------ @@ -448,8 +442,7 @@ def get_file( Returns ------- - File - API response as a typed Pydantic model + File API response as a typed Pydantic model Raises ------ @@ -497,8 +490,7 @@ def update_file( Returns ------- - File - API response as a typed Pydantic model + File API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index 8eb7149..e5f2a0f 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -1,5 +1,5 @@ from ..service import Service -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union, Type, TypeVar from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated from ..models.database_list import DatabaseList; @@ -35,6 +35,8 @@ from ..models.row_list import RowList; from ..models.row import Row; +T = TypeVar('T') + class TablesDB(Service): def __init__(self, client) -> None: @@ -59,8 +61,7 @@ def list( Returns ------- - DatabaseList - API response as a typed Pydantic model + DatabaseList API response as a typed Pydantic model Raises ------ @@ -104,8 +105,7 @@ def create( Returns ------- - Database - API response as a typed Pydantic model + Database API response as a typed Pydantic model Raises ------ @@ -147,8 +147,7 @@ def list_transactions( Returns ------- - TransactionList - API response as a typed Pydantic model + TransactionList API response as a typed Pydantic model Raises ------ @@ -181,8 +180,7 @@ def create_transaction( Returns ------- - Transaction - API response as a typed Pydantic model + Transaction API response as a typed Pydantic model Raises ------ @@ -216,8 +214,7 @@ def get_transaction( Returns ------- - Transaction - API response as a typed Pydantic model + Transaction API response as a typed Pydantic model Raises ------ @@ -258,8 +255,7 @@ def update_transaction( Returns ------- - Transaction - API response as a typed Pydantic model + Transaction API response as a typed Pydantic model Raises ------ @@ -339,8 +335,7 @@ def create_operations( Returns ------- - Transaction - API response as a typed Pydantic model + Transaction API response as a typed Pydantic model Raises ------ @@ -378,8 +373,7 @@ def get( Returns ------- - Database - API response as a typed Pydantic model + Database API response as a typed Pydantic model Raises ------ @@ -420,8 +414,7 @@ def update( Returns ------- - Database - API response as a typed Pydantic model + Database API response as a typed Pydantic model Raises ------ @@ -507,8 +500,7 @@ def list_tables( Returns ------- - TableList - API response as a typed Pydantic model + TableList API response as a typed Pydantic model Raises ------ @@ -570,8 +562,7 @@ def create_table( Returns ------- - Table - API response as a typed Pydantic model + Table API response as a typed Pydantic model Raises ------ @@ -627,8 +618,7 @@ def get_table( Returns ------- - Table - API response as a typed Pydantic model + Table API response as a typed Pydantic model Raises ------ @@ -682,8 +672,7 @@ def update_table( Returns ------- - Table - API response as a typed Pydantic model + Table API response as a typed Pydantic model Raises ------ @@ -783,8 +772,7 @@ def list_columns( Returns ------- - ColumnList - API response as a typed Pydantic model + ColumnList API response as a typed Pydantic model Raises ------ @@ -843,8 +831,7 @@ def create_boolean_column( Returns ------- - ColumnBoolean - API response as a typed Pydantic model + ColumnBoolean API response as a typed Pydantic model Raises ------ @@ -910,8 +897,7 @@ def update_boolean_column( Returns ------- - ColumnBoolean - API response as a typed Pydantic model + ColumnBoolean API response as a typed Pydantic model Raises ------ @@ -976,8 +962,7 @@ def create_datetime_column( Returns ------- - ColumnDatetime - API response as a typed Pydantic model + ColumnDatetime API response as a typed Pydantic model Raises ------ @@ -1043,8 +1028,7 @@ def update_datetime_column( Returns ------- - ColumnDatetime - API response as a typed Pydantic model + ColumnDatetime API response as a typed Pydantic model Raises ------ @@ -1110,8 +1094,7 @@ def create_email_column( Returns ------- - ColumnEmail - API response as a typed Pydantic model + ColumnEmail API response as a typed Pydantic model Raises ------ @@ -1178,8 +1161,7 @@ def update_email_column( Returns ------- - ColumnEmail - API response as a typed Pydantic model + ColumnEmail API response as a typed Pydantic model Raises ------ @@ -1247,8 +1229,7 @@ def create_enum_column( Returns ------- - ColumnEnum - API response as a typed Pydantic model + ColumnEnum API response as a typed Pydantic model Raises ------ @@ -1322,8 +1303,7 @@ def update_enum_column( Returns ------- - ColumnEnum - API response as a typed Pydantic model + ColumnEnum API response as a typed Pydantic model Raises ------ @@ -1399,8 +1379,7 @@ def create_float_column( Returns ------- - ColumnFloat - API response as a typed Pydantic model + ColumnFloat API response as a typed Pydantic model Raises ------ @@ -1475,8 +1454,7 @@ def update_float_column( Returns ------- - ColumnFloat - API response as a typed Pydantic model + ColumnFloat API response as a typed Pydantic model Raises ------ @@ -1550,8 +1528,7 @@ def create_integer_column( Returns ------- - ColumnInteger - API response as a typed Pydantic model + ColumnInteger API response as a typed Pydantic model Raises ------ @@ -1626,8 +1603,7 @@ def update_integer_column( Returns ------- - ColumnInteger - API response as a typed Pydantic model + ColumnInteger API response as a typed Pydantic model Raises ------ @@ -1695,8 +1671,7 @@ def create_ip_column( Returns ------- - ColumnIp - API response as a typed Pydantic model + ColumnIp API response as a typed Pydantic model Raises ------ @@ -1763,8 +1738,7 @@ def update_ip_column( Returns ------- - ColumnIp - API response as a typed Pydantic model + ColumnIp API response as a typed Pydantic model Raises ------ @@ -1826,8 +1800,7 @@ def create_line_column( Returns ------- - ColumnLine - API response as a typed Pydantic model + ColumnLine API response as a typed Pydantic model Raises ------ @@ -1891,8 +1864,7 @@ def update_line_column( Returns ------- - ColumnLine - API response as a typed Pydantic model + ColumnLine API response as a typed Pydantic model Raises ------ @@ -1961,8 +1933,7 @@ def create_longtext_column( Returns ------- - ColumnLongtext - API response as a typed Pydantic model + ColumnLongtext API response as a typed Pydantic model Raises ------ @@ -2031,8 +2002,7 @@ def update_longtext_column( Returns ------- - ColumnLongtext - API response as a typed Pydantic model + ColumnLongtext API response as a typed Pydantic model Raises ------ @@ -2101,8 +2071,7 @@ def create_mediumtext_column( Returns ------- - ColumnMediumtext - API response as a typed Pydantic model + ColumnMediumtext API response as a typed Pydantic model Raises ------ @@ -2171,8 +2140,7 @@ def update_mediumtext_column( Returns ------- - ColumnMediumtext - API response as a typed Pydantic model + ColumnMediumtext API response as a typed Pydantic model Raises ------ @@ -2234,8 +2202,7 @@ def create_point_column( Returns ------- - ColumnPoint - API response as a typed Pydantic model + ColumnPoint API response as a typed Pydantic model Raises ------ @@ -2299,8 +2266,7 @@ def update_point_column( Returns ------- - ColumnPoint - API response as a typed Pydantic model + ColumnPoint API response as a typed Pydantic model Raises ------ @@ -2362,8 +2328,7 @@ def create_polygon_column( Returns ------- - ColumnPolygon - API response as a typed Pydantic model + ColumnPolygon API response as a typed Pydantic model Raises ------ @@ -2427,8 +2392,7 @@ def update_polygon_column( Returns ------- - ColumnPolygon - API response as a typed Pydantic model + ColumnPolygon API response as a typed Pydantic model Raises ------ @@ -2500,8 +2464,7 @@ def create_relationship_column( Returns ------- - ColumnRelationship - API response as a typed Pydantic model + ColumnRelationship API response as a typed Pydantic model Raises ------ @@ -2580,8 +2543,7 @@ def create_string_column( Returns ------- - ColumnString - API response as a typed Pydantic model + ColumnString API response as a typed Pydantic model Raises ------ @@ -2660,8 +2622,7 @@ def update_string_column( Returns ------- - ColumnString - API response as a typed Pydantic model + ColumnString API response as a typed Pydantic model Raises ------ @@ -2731,8 +2692,7 @@ def create_text_column( Returns ------- - ColumnText - API response as a typed Pydantic model + ColumnText API response as a typed Pydantic model Raises ------ @@ -2801,8 +2761,7 @@ def update_text_column( Returns ------- - ColumnText - API response as a typed Pydantic model + ColumnText API response as a typed Pydantic model Raises ------ @@ -2868,8 +2827,7 @@ def create_url_column( Returns ------- - ColumnUrl - API response as a typed Pydantic model + ColumnUrl API response as a typed Pydantic model Raises ------ @@ -2936,8 +2894,7 @@ def update_url_column( Returns ------- - ColumnUrl - API response as a typed Pydantic model + ColumnUrl API response as a typed Pydantic model Raises ------ @@ -3009,8 +2966,7 @@ def create_varchar_column( Returns ------- - ColumnVarchar - API response as a typed Pydantic model + ColumnVarchar API response as a typed Pydantic model Raises ------ @@ -3086,8 +3042,7 @@ def update_varchar_column( Returns ------- - ColumnVarchar - API response as a typed Pydantic model + ColumnVarchar API response as a typed Pydantic model Raises ------ @@ -3252,8 +3207,7 @@ def update_relationship_column( Returns ------- - ColumnRelationship - API response as a typed Pydantic model + ColumnRelationship API response as a typed Pydantic model Raises ------ @@ -3308,8 +3262,7 @@ def list_indexes( Returns ------- - ColumnIndexList - API response as a typed Pydantic model + ColumnIndexList API response as a typed Pydantic model Raises ------ @@ -3371,8 +3324,7 @@ def create_index( Returns ------- - ColumnIndex - API response as a typed Pydantic model + ColumnIndex API response as a typed Pydantic model Raises ------ @@ -3434,8 +3386,7 @@ def get_index( Returns ------- - ColumnIndex - API response as a typed Pydantic model + ColumnIndex API response as a typed Pydantic model Raises ------ @@ -3523,7 +3474,8 @@ def list_rows( queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, total: Optional[bool] = None, - ttl: Optional[float] = None ) -> RowList: + ttl: Optional[float] = None, + model_type: Type[T] = dict ) -> RowList[T]: """ Get a list of all the user's rows in a given table. You can use the query params to filter your results. @@ -3542,10 +3494,12 @@ def list_rows( ttl : Optional[float] TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - RowList - API response as a typed Pydantic model + RowList[T] API response as a typed Pydantic model Raises ------ @@ -3576,7 +3530,7 @@ def list_rows( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=RowList) + return RowList.with_data(response, model_type) def create_row( @@ -3586,7 +3540,8 @@ def create_row( row_id: str, data: Dict[str, Any], permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> Row: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Row[T]: """ Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3605,10 +3560,12 @@ def create_row( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Row - API response as a typed Pydantic model + Row[T] API response as a typed Pydantic model Raises ------ @@ -3642,7 +3599,7 @@ def create_row( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Row) + return Row.with_data(response, model_type) def create_rows( @@ -3650,7 +3607,8 @@ def create_rows( database_id: str, table_id: str, rows: List[Dict[str, Any]], - transaction_id: Optional[str] = None ) -> RowList: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> RowList[T]: """ Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3665,10 +3623,12 @@ def create_rows( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - RowList - API response as a typed Pydantic model + RowList[T] API response as a typed Pydantic model Raises ------ @@ -3697,7 +3657,7 @@ def create_rows( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=RowList) + return RowList.with_data(response, model_type) def upsert_rows( @@ -3705,7 +3665,8 @@ def upsert_rows( database_id: str, table_id: str, rows: List[Dict[str, Any]], - transaction_id: Optional[str] = None ) -> RowList: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> RowList[T]: """ Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3721,10 +3682,12 @@ def upsert_rows( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - RowList - API response as a typed Pydantic model + RowList[T] API response as a typed Pydantic model Raises ------ @@ -3753,7 +3716,7 @@ def upsert_rows( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=RowList) + return RowList.with_data(response, model_type) def update_rows( @@ -3762,7 +3725,8 @@ def update_rows( table_id: str, data: Optional[Dict[str, Any]] = None, queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> RowList: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> RowList[T]: """ Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. @@ -3779,10 +3743,12 @@ def update_rows( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - RowList - API response as a typed Pydantic model + RowList[T] API response as a typed Pydantic model Raises ------ @@ -3811,7 +3777,7 @@ def update_rows( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=RowList) + return RowList.with_data(response, model_type) def delete_rows( @@ -3819,7 +3785,8 @@ def delete_rows( database_id: str, table_id: str, queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> RowList: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> RowList[T]: """ Bulk delete rows using queries, if no queries are passed then all rows are deleted. @@ -3834,10 +3801,12 @@ def delete_rows( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - RowList - API response as a typed Pydantic model + RowList[T] API response as a typed Pydantic model Raises ------ @@ -3864,7 +3833,7 @@ def delete_rows( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=RowList) + return RowList.with_data(response, model_type) def get_row( @@ -3873,7 +3842,8 @@ def get_row( table_id: str, row_id: str, queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> Row: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Row[T]: """ Get a row by its unique ID. This endpoint response returns a JSON object with the row data. @@ -3890,10 +3860,12 @@ def get_row( transaction_id : Optional[str] Transaction ID to read uncommitted changes within the transaction. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Row - API response as a typed Pydantic model + Row[T] API response as a typed Pydantic model Raises ------ @@ -3924,7 +3896,7 @@ def get_row( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=Row) + return Row.with_data(response, model_type) def upsert_row( @@ -3934,7 +3906,8 @@ def upsert_row( row_id: str, data: Optional[Dict[str, Any]] = None, permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> Row: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Row[T]: """ Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3953,10 +3926,12 @@ def upsert_row( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Row - API response as a typed Pydantic model + Row[T] API response as a typed Pydantic model Raises ------ @@ -3988,7 +3963,7 @@ def upsert_row( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Row) + return Row.with_data(response, model_type) def update_row( @@ -3998,7 +3973,8 @@ def update_row( row_id: str, data: Optional[Dict[str, Any]] = None, permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None ) -> Row: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Row[T]: """ Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -4017,10 +3993,12 @@ def update_row( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Row - API response as a typed Pydantic model + Row[T] API response as a typed Pydantic model Raises ------ @@ -4052,7 +4030,7 @@ def update_row( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Row) + return Row.with_data(response, model_type) def delete_row( @@ -4118,7 +4096,8 @@ def decrement_row_column( column: str, value: Optional[float] = None, min: Optional[float] = None, - transaction_id: Optional[str] = None ) -> Row: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Row[T]: """ Decrement a specific column of a row by a given value. @@ -4139,10 +4118,12 @@ def decrement_row_column( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Row - API response as a typed Pydantic model + Row[T] API response as a typed Pydantic model Raises ------ @@ -4178,7 +4159,7 @@ def decrement_row_column( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Row) + return Row.with_data(response, model_type) def increment_row_column( @@ -4189,7 +4170,8 @@ def increment_row_column( column: str, value: Optional[float] = None, max: Optional[float] = None, - transaction_id: Optional[str] = None ) -> Row: + transaction_id: Optional[str] = None, + model_type: Type[T] = dict ) -> Row[T]: """ Increment a specific column of a row by a given value. @@ -4210,10 +4192,12 @@ def increment_row_column( transaction_id : Optional[str] Transaction ID for staging the operation. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Row - API response as a typed Pydantic model + Row[T] API response as a typed Pydantic model Raises ------ @@ -4249,5 +4233,5 @@ def increment_row_column( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Row) + return Row.with_data(response, model_type) diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 0c78681..3353e8a 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -1,5 +1,5 @@ from ..service import Service -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union, Type, TypeVar from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated from ..models.team_list import TeamList; @@ -8,6 +8,8 @@ from ..models.membership import Membership; from ..models.preferences import Preferences; +T = TypeVar('T') + class Teams(Service): def __init__(self, client) -> None: @@ -17,7 +19,8 @@ def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> TeamList: + total: Optional[bool] = None, + model_type: Type[T] = dict ) -> TeamList[T]: """ Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. @@ -30,10 +33,12 @@ def list( total : Optional[bool] When set to false, the total count returned will be 0 and will not be calculated. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - TeamList - API response as a typed Pydantic model + TeamList[T] API response as a typed Pydantic model Raises ------ @@ -54,14 +59,15 @@ def list( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=TeamList) + return TeamList.with_data(response, model_type) def create( self, team_id: str, name: str, - roles: Optional[List[str]] = None ) -> Team: + roles: Optional[List[str]] = None, + model_type: Type[T] = dict ) -> Team[T]: """ Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. @@ -74,10 +80,12 @@ def create( roles : Optional[List[str]] Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Team - API response as a typed Pydantic model + Team[T] API response as a typed Pydantic model Raises ------ @@ -103,12 +111,13 @@ def create( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Team) + return Team.with_data(response, model_type) def get( self, - team_id: str ) -> Team: + team_id: str, + model_type: Type[T] = dict ) -> Team[T]: """ Get a team by its ID. All team members have read access for this resource. @@ -117,10 +126,12 @@ def get( team_id : str Team ID. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Team - API response as a typed Pydantic model + Team[T] API response as a typed Pydantic model Raises ------ @@ -139,13 +150,14 @@ def get( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=Team) + return Team.with_data(response, model_type) def update_name( self, team_id: str, - name: str ) -> Team: + name: str, + model_type: Type[T] = dict ) -> Team[T]: """ Update the team's name by its unique ID. @@ -156,10 +168,12 @@ def update_name( name : str New team name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Team - API response as a typed Pydantic model + Team[T] API response as a typed Pydantic model Raises ------ @@ -183,7 +197,7 @@ def update_name( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Team) + return Team.with_data(response, model_type) def delete( @@ -245,8 +259,7 @@ def list_memberships( Returns ------- - MembershipList - API response as a typed Pydantic model + MembershipList API response as a typed Pydantic model Raises ------ @@ -312,8 +325,7 @@ def create_membership( Returns ------- - Membership - API response as a typed Pydantic model + Membership API response as a typed Pydantic model Raises ------ @@ -366,8 +378,7 @@ def get_membership( Returns ------- - Membership - API response as a typed Pydantic model + Membership API response as a typed Pydantic model Raises ------ @@ -413,8 +424,7 @@ def update_membership( Returns ------- - Membership - API response as a typed Pydantic model + Membership API response as a typed Pydantic model Raises ------ @@ -514,8 +524,7 @@ def update_membership_status( Returns ------- - Membership - API response as a typed Pydantic model + Membership API response as a typed Pydantic model Raises ------ @@ -552,7 +561,8 @@ def update_membership_status( def get_prefs( self, - team_id: str ) -> Preferences: + team_id: str, + model_type: Type[T] = dict ) -> Preferences[T]: """ Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). @@ -561,10 +571,12 @@ def get_prefs( team_id : str Team ID. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Preferences - API response as a typed Pydantic model + Preferences[T] API response as a typed Pydantic model Raises ------ @@ -583,13 +595,14 @@ def get_prefs( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=Preferences) + return Preferences.with_data(response, model_type) def update_prefs( self, team_id: str, - prefs: Dict[str, Any] ) -> Preferences: + prefs: Dict[str, Any], + model_type: Type[T] = dict ) -> Preferences[T]: """ Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. @@ -600,10 +613,12 @@ def update_prefs( prefs : Dict[str, Any] Prefs key-value JSON object. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Preferences - API response as a typed Pydantic model + Preferences[T] API response as a typed Pydantic model Raises ------ @@ -627,5 +642,5 @@ def update_prefs( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Preferences) + return Preferences.with_data(response, model_type) diff --git a/appwrite/services/tokens.py b/appwrite/services/tokens.py index 41da60e..4338c2b 100644 --- a/appwrite/services/tokens.py +++ b/appwrite/services/tokens.py @@ -32,8 +32,7 @@ def list( Returns ------- - ResourceTokenList - API response as a typed Pydantic model + ResourceTokenList API response as a typed Pydantic model Raises ------ @@ -82,8 +81,7 @@ def create_file_token( Returns ------- - ResourceToken - API response as a typed Pydantic model + ResourceToken API response as a typed Pydantic model Raises ------ @@ -124,8 +122,7 @@ def get( Returns ------- - ResourceToken - API response as a typed Pydantic model + ResourceToken API response as a typed Pydantic model Raises ------ @@ -163,8 +160,7 @@ def update( Returns ------- - ResourceToken - API response as a typed Pydantic model + ResourceToken API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/users.py b/appwrite/services/users.py index 981d91a..db3e906 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -1,5 +1,5 @@ from ..service import Service -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union, Type, TypeVar from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated from ..models.user_list import UserList; @@ -20,6 +20,8 @@ from ..models.target import Target; from ..models.token import Token; +T = TypeVar('T') + class Users(Service): def __init__(self, client) -> None: @@ -29,7 +31,8 @@ def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> UserList: + total: Optional[bool] = None, + model_type: Type[T] = dict ) -> UserList[T]: """ Get a list of all the project's users. You can use the query params to filter your results. @@ -42,10 +45,12 @@ def list( total : Optional[bool] When set to false, the total count returned will be 0 and will not be calculated. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - UserList - API response as a typed Pydantic model + UserList[T] API response as a typed Pydantic model Raises ------ @@ -66,7 +71,7 @@ def list( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=UserList) + return UserList.with_data(response, model_type) def create( @@ -75,7 +80,8 @@ def create( email: Optional[str] = None, phone: Optional[str] = None, password: Optional[str] = None, - name: Optional[str] = None ) -> User: + name: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Create a new user. @@ -92,10 +98,12 @@ def create( name : Optional[str] User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -121,7 +129,7 @@ def create( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_argon2_user( @@ -129,7 +137,8 @@ def create_argon2_user( user_id: str, email: str, password: str, - name: Optional[str] = None ) -> User: + name: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -144,10 +153,12 @@ def create_argon2_user( name : Optional[str] User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -177,7 +188,7 @@ def create_argon2_user( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_bcrypt_user( @@ -185,7 +196,8 @@ def create_bcrypt_user( user_id: str, email: str, password: str, - name: Optional[str] = None ) -> User: + name: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -200,10 +212,12 @@ def create_bcrypt_user( name : Optional[str] User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -233,7 +247,7 @@ def create_bcrypt_user( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def list_identities( @@ -255,8 +269,7 @@ def list_identities( Returns ------- - IdentityList - API response as a typed Pydantic model + IdentityList API response as a typed Pydantic model Raises ------ @@ -322,7 +335,8 @@ def create_md5_user( user_id: str, email: str, password: str, - name: Optional[str] = None ) -> User: + name: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -337,10 +351,12 @@ def create_md5_user( name : Optional[str] User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -370,7 +386,7 @@ def create_md5_user( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_ph_pass_user( @@ -378,7 +394,8 @@ def create_ph_pass_user( user_id: str, email: str, password: str, - name: Optional[str] = None ) -> User: + name: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -393,10 +410,12 @@ def create_ph_pass_user( name : Optional[str] User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -426,7 +445,7 @@ def create_ph_pass_user( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_scrypt_user( @@ -439,7 +458,8 @@ def create_scrypt_user( password_memory: float, password_parallel: float, password_length: float, - name: Optional[str] = None ) -> User: + name: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -464,10 +484,12 @@ def create_scrypt_user( name : Optional[str] User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -517,7 +539,7 @@ def create_scrypt_user( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_scrypt_modified_user( @@ -528,7 +550,8 @@ def create_scrypt_modified_user( password_salt: str, password_salt_separator: str, password_signer_key: str, - name: Optional[str] = None ) -> User: + name: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -549,10 +572,12 @@ def create_scrypt_modified_user( name : Optional[str] User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -594,7 +619,7 @@ def create_scrypt_modified_user( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_sha_user( @@ -603,7 +628,8 @@ def create_sha_user( email: str, password: str, password_version: Optional[PasswordHash] = None, - name: Optional[str] = None ) -> User: + name: Optional[str] = None, + model_type: Type[T] = dict ) -> User[T]: """ Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -620,10 +646,12 @@ def create_sha_user( name : Optional[str] User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -655,12 +683,13 @@ def create_sha_user( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def get( self, - user_id: str ) -> User: + user_id: str, + model_type: Type[T] = dict ) -> User[T]: """ Get a user by its unique ID. @@ -669,10 +698,12 @@ def get( user_id : str User ID. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -691,7 +722,7 @@ def get( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def delete( @@ -734,7 +765,8 @@ def delete( def update_email( self, user_id: str, - email: str ) -> User: + email: str, + model_type: Type[T] = dict ) -> User[T]: """ Update the user email by its unique ID. @@ -745,10 +777,12 @@ def update_email( email : str User email. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -772,7 +806,7 @@ def update_email( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def create_jwt( @@ -794,8 +828,7 @@ def create_jwt( Returns ------- - Jwt - API response as a typed Pydantic model + Jwt API response as a typed Pydantic model Raises ------ @@ -825,7 +858,8 @@ def create_jwt( def update_labels( self, user_id: str, - labels: List[str] ) -> User: + labels: List[str], + model_type: Type[T] = dict ) -> User[T]: """ Update the user labels by its unique ID. @@ -838,10 +872,12 @@ def update_labels( labels : List[str] Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -865,7 +901,7 @@ def update_labels( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def list_logs( @@ -887,8 +923,7 @@ def list_logs( Returns ------- - LogList - API response as a typed Pydantic model + LogList API response as a typed Pydantic model Raises ------ @@ -936,8 +971,7 @@ def list_memberships( Returns ------- - MembershipList - API response as a typed Pydantic model + MembershipList API response as a typed Pydantic model Raises ------ @@ -968,7 +1002,8 @@ def list_memberships( def update_mfa( self, user_id: str, - mfa: bool ) -> User: + mfa: bool, + model_type: Type[T] = dict ) -> User[T]: """ Enable or disable MFA on a user account. @@ -979,10 +1014,12 @@ def update_mfa( mfa : bool Enable or disable MFA. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -1006,7 +1043,7 @@ def update_mfa( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def delete_mfa_authenticator( @@ -1066,8 +1103,7 @@ def list_mfa_factors( Returns ------- - MfaFactors - API response as a typed Pydantic model + MfaFactors API response as a typed Pydantic model Raises ------ @@ -1102,8 +1138,7 @@ def get_mfa_recovery_codes( Returns ------- - MfaRecoveryCodes - API response as a typed Pydantic model + MfaRecoveryCodes API response as a typed Pydantic model Raises ------ @@ -1138,8 +1173,7 @@ def update_mfa_recovery_codes( Returns ------- - MfaRecoveryCodes - API response as a typed Pydantic model + MfaRecoveryCodes API response as a typed Pydantic model Raises ------ @@ -1175,8 +1209,7 @@ def create_mfa_recovery_codes( Returns ------- - MfaRecoveryCodes - API response as a typed Pydantic model + MfaRecoveryCodes API response as a typed Pydantic model Raises ------ @@ -1202,7 +1235,8 @@ def create_mfa_recovery_codes( def update_name( self, user_id: str, - name: str ) -> User: + name: str, + model_type: Type[T] = dict ) -> User[T]: """ Update the user name by its unique ID. @@ -1213,10 +1247,12 @@ def update_name( name : str User name. Max length: 128 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -1240,13 +1276,14 @@ def update_name( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def update_password( self, user_id: str, - password: str ) -> User: + password: str, + model_type: Type[T] = dict ) -> User[T]: """ Update the user password by its unique ID. @@ -1257,10 +1294,12 @@ def update_password( password : str New user password. Must be at least 8 chars. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -1284,13 +1323,14 @@ def update_password( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def update_phone( self, user_id: str, - number: str ) -> User: + number: str, + model_type: Type[T] = dict ) -> User[T]: """ Update the user phone by its unique ID. @@ -1301,10 +1341,12 @@ def update_phone( number : str User phone number. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -1328,12 +1370,13 @@ def update_phone( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def get_prefs( self, - user_id: str ) -> Preferences: + user_id: str, + model_type: Type[T] = dict ) -> Preferences[T]: """ Get the user preferences by its unique ID. @@ -1342,10 +1385,12 @@ def get_prefs( user_id : str User ID. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Preferences - API response as a typed Pydantic model + Preferences[T] API response as a typed Pydantic model Raises ------ @@ -1364,13 +1409,14 @@ def get_prefs( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=Preferences) + return Preferences.with_data(response, model_type) def update_prefs( self, user_id: str, - prefs: Dict[str, Any] ) -> Preferences: + prefs: Dict[str, Any], + model_type: Type[T] = dict ) -> Preferences[T]: """ Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. @@ -1381,10 +1427,12 @@ def update_prefs( prefs : Dict[str, Any] Prefs key-value JSON object. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - Preferences - API response as a typed Pydantic model + Preferences[T] API response as a typed Pydantic model Raises ------ @@ -1408,7 +1456,7 @@ def update_prefs( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=Preferences) + return Preferences.with_data(response, model_type) def list_sessions( @@ -1427,8 +1475,7 @@ def list_sessions( Returns ------- - SessionList - API response as a typed Pydantic model + SessionList API response as a typed Pydantic model Raises ------ @@ -1467,8 +1514,7 @@ def create_session( Returns ------- - Session - API response as a typed Pydantic model + Session API response as a typed Pydantic model Raises ------ @@ -1575,7 +1621,8 @@ def delete_session( def update_status( self, user_id: str, - status: bool ) -> User: + status: bool, + model_type: Type[T] = dict ) -> User[T]: """ Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. @@ -1586,10 +1633,12 @@ def update_status( status : bool User Status. To activate the user pass `true` and to block the user pass `false`. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -1613,7 +1662,7 @@ def update_status( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def list_targets( @@ -1635,8 +1684,7 @@ def list_targets( Returns ------- - TargetList - API response as a typed Pydantic model + TargetList API response as a typed Pydantic model Raises ------ @@ -1690,8 +1738,7 @@ def create_target( Returns ------- - Target - API response as a typed Pydantic model + Target API response as a typed Pydantic model Raises ------ @@ -1746,8 +1793,7 @@ def get_target( Returns ------- - Target - API response as a typed Pydantic model + Target API response as a typed Pydantic model Raises ------ @@ -1798,8 +1844,7 @@ def update_target( Returns ------- - Target - API response as a typed Pydantic model + Target API response as a typed Pydantic model Raises ------ @@ -1896,8 +1941,7 @@ def create_token( Returns ------- - Token - API response as a typed Pydantic model + Token API response as a typed Pydantic model Raises ------ @@ -1927,7 +1971,8 @@ def create_token( def update_email_verification( self, user_id: str, - email_verification: bool ) -> User: + email_verification: bool, + model_type: Type[T] = dict ) -> User[T]: """ Update the user email verification status by its unique ID. @@ -1938,10 +1983,12 @@ def update_email_verification( email_verification : bool User email verification status. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -1965,13 +2012,14 @@ def update_email_verification( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) def update_phone_verification( self, user_id: str, - phone_verification: bool ) -> User: + phone_verification: bool, + model_type: Type[T] = dict ) -> User[T]: """ Update the user phone verification status by its unique ID. @@ -1982,10 +2030,12 @@ def update_phone_verification( phone_verification : bool User phone verification status. + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + Returns ------- - User - API response as a typed Pydantic model + User[T] API response as a typed Pydantic model Raises ------ @@ -2009,5 +2059,5 @@ def update_phone_verification( 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=User) + return User.with_data(response, model_type) From ccf8debfdc062245e573dc1030ebac1c4d56808a Mon Sep 17 00:00:00 2001 From: root <chiragaggarwal5k@gmail.com> Date: Sat, 7 Mar 2026 09:02:23 +0000 Subject: [PATCH 6/6] chore: update Python SDK to 16.0.0 --- appwrite/services/account.py | 255 ++++++++++++++------- appwrite/services/activities.py | 12 +- appwrite/services/avatars.py | 24 +- appwrite/services/backups.py | 66 ++++-- appwrite/services/databases.py | 393 +++++++++++++++++++++----------- appwrite/services/functions.py | 141 ++++++++---- appwrite/services/graphql.py | 6 +- appwrite/services/health.py | 174 +++++++++----- appwrite/services/locale.py | 48 ++-- appwrite/services/messaging.py | 276 ++++++++++++++-------- appwrite/services/sites.py | 135 +++++++---- appwrite/services/storage.py | 63 +++-- appwrite/services/tables_db.py | 393 +++++++++++++++++++++----------- appwrite/services/teams.py | 72 ++++-- appwrite/services/tokens.py | 27 ++- appwrite/services/users.py | 234 ++++++++++++------- 16 files changed, 1546 insertions(+), 773 deletions(-) diff --git a/appwrite/services/account.py b/appwrite/services/account.py index b6ab073..ab3ef0c 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -27,7 +27,8 @@ def __init__(self, client) -> None: def get( self, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Get the currently logged in user. @@ -39,7 +40,8 @@ def get( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -62,7 +64,8 @@ def create( email: str, password: str, name: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). @@ -82,7 +85,8 @@ def create( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -119,7 +123,8 @@ def update_email( self, email: str, password: str, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. @@ -137,7 +142,8 @@ def update_email( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -167,7 +173,8 @@ def update_email( def list_identities( self, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> IdentityList: + total: Optional[bool] = None + ) -> IdentityList: """ Get the list of identities for the currently logged in user. @@ -180,7 +187,8 @@ def list_identities( Returns ------- - IdentityList API response as a typed Pydantic model + IdentityList + API response as a typed Pydantic model Raises ------ @@ -204,7 +212,8 @@ def list_identities( def delete_identity( self, - identity_id: str ) -> Dict[str, Any]: + identity_id: str + ) -> Dict[str, Any]: """ Delete an identity by its unique ID. @@ -241,7 +250,8 @@ def delete_identity( def create_jwt( self, - duration: Optional[float] = None ) -> Jwt: + duration: Optional[float] = None + ) -> Jwt: """ Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. @@ -252,7 +262,8 @@ def create_jwt( Returns ------- - Jwt API response as a typed Pydantic model + Jwt + API response as a typed Pydantic model Raises ------ @@ -276,7 +287,8 @@ def create_jwt( def list_logs( self, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> LogList: + total: Optional[bool] = None + ) -> LogList: """ Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. @@ -289,7 +301,8 @@ def list_logs( Returns ------- - LogList API response as a typed Pydantic model + LogList + API response as a typed Pydantic model Raises ------ @@ -314,7 +327,8 @@ def list_logs( def update_mfa( self, mfa: bool, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Enable or disable MFA on an account. @@ -328,7 +342,8 @@ def update_mfa( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -353,7 +368,8 @@ def update_mfa( def create_mfa_authenticator( self, - type: AuthenticatorType ) -> MfaType: + type: AuthenticatorType + ) -> MfaType: """ Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. @@ -364,7 +380,8 @@ def create_mfa_authenticator( Returns ------- - MfaType API response as a typed Pydantic model + MfaType + API response as a typed Pydantic model Raises ------ @@ -391,7 +408,8 @@ def update_mfa_authenticator( self, type: AuthenticatorType, otp: str, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. @@ -407,7 +425,8 @@ def update_mfa_authenticator( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -436,7 +455,8 @@ def update_mfa_authenticator( def delete_mfa_authenticator( self, - type: AuthenticatorType ) -> Dict[str, Any]: + type: AuthenticatorType + ) -> Dict[str, Any]: """ Delete an authenticator for a user by ID. @@ -473,7 +493,8 @@ def delete_mfa_authenticator( def create_mfa_challenge( self, - factor: AuthenticationFactor ) -> MfaChallenge: + factor: AuthenticationFactor + ) -> MfaChallenge: """ Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. @@ -484,7 +505,8 @@ def create_mfa_challenge( Returns ------- - MfaChallenge API response as a typed Pydantic model + MfaChallenge + API response as a typed Pydantic model Raises ------ @@ -510,7 +532,8 @@ def create_mfa_challenge( def update_mfa_challenge( self, challenge_id: str, - otp: str ) -> Session: + otp: str + ) -> Session: """ Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. @@ -523,7 +546,8 @@ def update_mfa_challenge( Returns ------- - Session API response as a typed Pydantic model + Session + API response as a typed Pydantic model Raises ------ @@ -551,13 +575,15 @@ def update_mfa_challenge( def list_mfa_factors( - self ) -> MfaFactors: + self + ) -> MfaFactors: """ List the factors available on the account to be used as a MFA challange. Returns ------- - MfaFactors API response as a typed Pydantic model + MfaFactors + API response as a typed Pydantic model Raises ------ @@ -575,13 +601,15 @@ def list_mfa_factors( def get_mfa_recovery_codes( - self ) -> MfaRecoveryCodes: + self + ) -> MfaRecoveryCodes: """ Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. Returns ------- - MfaRecoveryCodes API response as a typed Pydantic model + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -599,13 +627,15 @@ def get_mfa_recovery_codes( def create_mfa_recovery_codes( - self ) -> MfaRecoveryCodes: + self + ) -> MfaRecoveryCodes: """ Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. Returns ------- - MfaRecoveryCodes API response as a typed Pydantic model + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -624,13 +654,15 @@ def create_mfa_recovery_codes( def update_mfa_recovery_codes( - self ) -> MfaRecoveryCodes: + self + ) -> MfaRecoveryCodes: """ Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. Returns ------- - MfaRecoveryCodes API response as a typed Pydantic model + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -651,7 +683,8 @@ def update_mfa_recovery_codes( def update_name( self, name: str, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update currently logged in user account name. @@ -665,7 +698,8 @@ def update_name( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -692,7 +726,8 @@ def update_password( self, password: str, old_password: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. @@ -708,7 +743,8 @@ def update_password( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -737,7 +773,8 @@ def update_phone( self, phone: str, password: str, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. @@ -753,7 +790,8 @@ def update_phone( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -782,7 +820,8 @@ def update_phone( def get_prefs( self, - model_type: Type[T] = dict ) -> Preferences[T]: + model_type: Type[T] = dict + ) -> Preferences[T]: """ Get the preferences as a key-value object for the currently logged in user. @@ -794,7 +833,8 @@ def get_prefs( Returns ------- - Preferences[T] API response as a typed Pydantic model + Preferences[T] + API response as a typed Pydantic model Raises ------ @@ -814,7 +854,8 @@ def get_prefs( def update_prefs( self, prefs: Dict[str, Any], - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. @@ -828,7 +869,8 @@ def update_prefs( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -854,7 +896,8 @@ def update_prefs( def create_recovery( self, email: str, - url: str ) -> Token: + url: str + ) -> Token: """ Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour. @@ -867,7 +910,8 @@ def create_recovery( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -898,7 +942,8 @@ def update_recovery( self, user_id: str, secret: str, - password: str ) -> Token: + password: str + ) -> Token: """ Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint. @@ -915,7 +960,8 @@ def update_recovery( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -947,13 +993,15 @@ def update_recovery( def list_sessions( - self ) -> SessionList: + self + ) -> SessionList: """ Get the list of active sessions across different devices for the currently logged in user. Returns ------- - SessionList API response as a typed Pydantic model + SessionList + API response as a typed Pydantic model Raises ------ @@ -971,7 +1019,8 @@ def list_sessions( def delete_sessions( - self ) -> Dict[str, Any]: + self + ) -> Dict[str, Any]: """ Delete all sessions from the user account and remove any sessions cookies from the end client. @@ -997,13 +1046,15 @@ def delete_sessions( def create_anonymous_session( - self ) -> Session: + self + ) -> Session: """ Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). Returns ------- - Session API response as a typed Pydantic model + Session + API response as a typed Pydantic model Raises ------ @@ -1024,7 +1075,8 @@ def create_anonymous_session( def create_email_password_session( self, email: str, - password: str ) -> Session: + password: str + ) -> Session: """ Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. @@ -1039,7 +1091,8 @@ def create_email_password_session( Returns ------- - Session API response as a typed Pydantic model + Session + API response as a typed Pydantic model Raises ------ @@ -1070,7 +1123,8 @@ def create_email_password_session( def update_magic_url_session( self, user_id: str, - secret: str ) -> Session: + secret: str + ) -> Session: """ Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -1085,7 +1139,8 @@ def update_magic_url_session( Returns ------- - Session API response as a typed Pydantic model + Session + API response as a typed Pydantic model Raises ------ @@ -1116,7 +1171,8 @@ def update_magic_url_session( def update_phone_session( self, user_id: str, - secret: str ) -> Session: + secret: str + ) -> Session: """ Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -1131,7 +1187,8 @@ def update_phone_session( Returns ------- - Session API response as a typed Pydantic model + Session + API response as a typed Pydantic model Raises ------ @@ -1161,7 +1218,8 @@ def update_phone_session( def create_session( self, user_id: str, - secret: str ) -> Session: + secret: str + ) -> Session: """ Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. @@ -1174,7 +1232,8 @@ def create_session( Returns ------- - Session API response as a typed Pydantic model + Session + API response as a typed Pydantic model Raises ------ @@ -1203,7 +1262,8 @@ def create_session( def get_session( self, - session_id: str ) -> Session: + session_id: str + ) -> Session: """ Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. @@ -1214,7 +1274,8 @@ def get_session( Returns ------- - Session API response as a typed Pydantic model + Session + API response as a typed Pydantic model Raises ------ @@ -1238,7 +1299,8 @@ def get_session( def update_session( self, - session_id: str ) -> Session: + session_id: str + ) -> Session: """ Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. @@ -1249,7 +1311,8 @@ def update_session( Returns ------- - Session API response as a typed Pydantic model + Session + API response as a typed Pydantic model Raises ------ @@ -1274,7 +1337,8 @@ def update_session( def delete_session( self, - session_id: str ) -> Dict[str, Any]: + session_id: str + ) -> Dict[str, Any]: """ Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. @@ -1311,7 +1375,8 @@ def delete_session( def update_status( self, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. @@ -1323,7 +1388,8 @@ def update_status( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -1345,7 +1411,8 @@ def create_email_token( self, user_id: str, email: str, - phrase: Optional[bool] = None ) -> Token: + phrase: Optional[bool] = None + ) -> Token: """ Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. @@ -1363,7 +1430,8 @@ def create_email_token( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -1397,7 +1465,8 @@ def create_magic_url_token( user_id: str, email: str, url: Optional[str] = None, - phrase: Optional[bool] = None ) -> Token: + phrase: Optional[bool] = None + ) -> Token: """ Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. @@ -1417,7 +1486,8 @@ def create_magic_url_token( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -1453,7 +1523,8 @@ def create_o_auth2_token( provider: OAuthProvider, success: Optional[str] = None, failure: Optional[str] = None, - scopes: Optional[List[str]] = None ) -> str: + scopes: Optional[List[str]] = None + ) -> str: """ Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. @@ -1506,7 +1577,8 @@ def create_o_auth2_token( def create_phone_token( self, user_id: str, - phone: str ) -> Token: + phone: str + ) -> Token: """ Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. @@ -1521,7 +1593,8 @@ def create_phone_token( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -1550,7 +1623,8 @@ def create_phone_token( def create_email_verification( self, - url: str ) -> Token: + url: str + ) -> Token: """ Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. @@ -1564,7 +1638,8 @@ def create_email_verification( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -1590,7 +1665,8 @@ def create_email_verification( @deprecated("This API has been deprecated since 1.8.0. Please use `account.create_email_verification` instead.") def create_verification( self, - url: str ) -> Token: + url: str + ) -> Token: """ Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. @@ -1606,7 +1682,8 @@ def create_verification( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -1632,7 +1709,8 @@ def create_verification( def update_email_verification( self, user_id: str, - secret: str ) -> Token: + secret: str + ) -> Token: """ Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -1645,7 +1723,8 @@ def update_email_verification( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -1676,7 +1755,8 @@ def update_email_verification( def update_verification( self, user_id: str, - secret: str ) -> Token: + secret: str + ) -> Token: """ Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -1691,7 +1771,8 @@ def update_verification( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -1719,13 +1800,15 @@ def update_verification( def create_phone_verification( - self ) -> Token: + self + ) -> Token: """ Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -1746,7 +1829,8 @@ def create_phone_verification( def update_phone_verification( self, user_id: str, - secret: str ) -> Token: + secret: str + ) -> Token: """ Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. @@ -1759,7 +1843,8 @@ def update_phone_verification( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/activities.py b/appwrite/services/activities.py index 7e65465..4c50a8f 100644 --- a/appwrite/services/activities.py +++ b/appwrite/services/activities.py @@ -12,7 +12,8 @@ def __init__(self, client) -> None: def list_events( self, - queries: Optional[str] = None ) -> ActivityEventList: + queries: Optional[str] = None + ) -> ActivityEventList: """ List all events for selected filters. @@ -23,7 +24,8 @@ def list_events( Returns ------- - ActivityEventList API response as a typed Pydantic model + ActivityEventList + API response as a typed Pydantic model Raises ------ @@ -45,7 +47,8 @@ def list_events( def get_event( self, - event_id: str ) -> ActivityEvent: + event_id: str + ) -> ActivityEvent: """ Get event by ID. @@ -57,7 +60,8 @@ def get_event( Returns ------- - ActivityEvent API response as a typed Pydantic model + ActivityEvent + API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index 17b397b..f437c04 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -20,7 +20,8 @@ def get_browser( code: Browser, width: Optional[float] = None, height: Optional[float] = None, - quality: Optional[float] = None ) -> bytes: + quality: Optional[float] = None + ) -> bytes: """ You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. @@ -73,7 +74,8 @@ def get_credit_card( code: CreditCard, width: Optional[float] = None, height: Optional[float] = None, - quality: Optional[float] = None ) -> bytes: + quality: Optional[float] = None + ) -> bytes: """ The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. @@ -124,7 +126,8 @@ def get_credit_card( def get_favicon( self, - url: str ) -> bytes: + url: str + ) -> bytes: """ Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. @@ -165,7 +168,8 @@ def get_flag( code: Flag, width: Optional[float] = None, height: Optional[float] = None, - quality: Optional[float] = None ) -> bytes: + quality: Optional[float] = None + ) -> bytes: """ You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. @@ -218,7 +222,8 @@ def get_image( self, url: str, width: Optional[float] = None, - height: Optional[float] = None ) -> bytes: + height: Optional[float] = None + ) -> bytes: """ Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. @@ -269,7 +274,8 @@ def get_initials( name: Optional[str] = None, width: Optional[float] = None, height: Optional[float] = None, - background: Optional[str] = None ) -> bytes: + background: Optional[str] = None + ) -> bytes: """ Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. @@ -323,7 +329,8 @@ def get_qr( text: str, size: Optional[float] = None, margin: Optional[float] = None, - download: Optional[bool] = None ) -> bytes: + download: Optional[bool] = None + ) -> bytes: """ Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. @@ -391,7 +398,8 @@ def get_screenshot( width: Optional[float] = None, height: Optional[float] = None, quality: Optional[float] = None, - output: Optional[ImageFormat] = None ) -> bytes: + output: Optional[ImageFormat] = None + ) -> bytes: """ Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. diff --git a/appwrite/services/backups.py b/appwrite/services/backups.py index 755fadb..ce05f0a 100644 --- a/appwrite/services/backups.py +++ b/appwrite/services/backups.py @@ -17,7 +17,8 @@ def __init__(self, client) -> None: def list_archives( self, - queries: Optional[List[str]] = None ) -> BackupArchiveList: + queries: Optional[List[str]] = None + ) -> BackupArchiveList: """ List all archives for a project. @@ -28,7 +29,8 @@ def list_archives( Returns ------- - BackupArchiveList API response as a typed Pydantic model + BackupArchiveList + API response as a typed Pydantic model Raises ------ @@ -51,7 +53,8 @@ def list_archives( def create_archive( self, services: List[BackupServices], - resource_id: Optional[str] = None ) -> BackupArchive: + resource_id: Optional[str] = None + ) -> BackupArchive: """ Create a new archive asynchronously for a project. @@ -64,7 +67,8 @@ def create_archive( Returns ------- - BackupArchive API response as a typed Pydantic model + BackupArchive + API response as a typed Pydantic model Raises ------ @@ -90,7 +94,8 @@ def create_archive( def get_archive( self, - archive_id: str ) -> BackupArchive: + archive_id: str + ) -> BackupArchive: """ Get a backup archive using it's ID. @@ -101,7 +106,8 @@ def get_archive( Returns ------- - BackupArchive API response as a typed Pydantic model + BackupArchive + API response as a typed Pydantic model Raises ------ @@ -125,7 +131,8 @@ def get_archive( def delete_archive( self, - archive_id: str ) -> Dict[str, Any]: + archive_id: str + ) -> Dict[str, Any]: """ Delete an existing archive for a project. @@ -162,7 +169,8 @@ def delete_archive( def list_policies( self, - queries: Optional[List[str]] = None ) -> BackupPolicyList: + queries: Optional[List[str]] = None + ) -> BackupPolicyList: """ List all policies for a project. @@ -173,7 +181,8 @@ def list_policies( Returns ------- - BackupPolicyList API response as a typed Pydantic model + BackupPolicyList + API response as a typed Pydantic model Raises ------ @@ -201,7 +210,8 @@ def create_policy( schedule: str, name: Optional[str] = None, resource_id: Optional[str] = None, - enabled: Optional[bool] = None ) -> BackupPolicy: + enabled: Optional[bool] = None + ) -> BackupPolicy: """ Create a new backup policy. @@ -224,7 +234,8 @@ def create_policy( Returns ------- - BackupPolicy API response as a typed Pydantic model + BackupPolicy + API response as a typed Pydantic model Raises ------ @@ -266,7 +277,8 @@ def create_policy( def get_policy( self, - policy_id: str ) -> BackupPolicy: + policy_id: str + ) -> BackupPolicy: """ Get a backup policy using it's ID. @@ -277,7 +289,8 @@ def get_policy( Returns ------- - BackupPolicy API response as a typed Pydantic model + BackupPolicy + API response as a typed Pydantic model Raises ------ @@ -305,7 +318,8 @@ def update_policy( name: Optional[str] = None, retention: Optional[float] = None, schedule: Optional[str] = None, - enabled: Optional[bool] = None ) -> BackupPolicy: + enabled: Optional[bool] = None + ) -> BackupPolicy: """ Update an existing policy using it's ID. @@ -324,7 +338,8 @@ def update_policy( Returns ------- - BackupPolicy API response as a typed Pydantic model + BackupPolicy + API response as a typed Pydantic model Raises ------ @@ -354,7 +369,8 @@ def update_policy( def delete_policy( self, - policy_id: str ) -> Dict[str, Any]: + policy_id: str + ) -> Dict[str, Any]: """ Delete a policy using it's ID. @@ -394,7 +410,8 @@ def create_restoration( archive_id: str, services: List[BackupServices], new_resource_id: Optional[str] = None, - new_resource_name: Optional[str] = None ) -> BackupRestoration: + new_resource_name: Optional[str] = None + ) -> BackupRestoration: """ Create and trigger a new restoration for a backup on a project. @@ -411,7 +428,8 @@ def create_restoration( Returns ------- - BackupRestoration API response as a typed Pydantic model + BackupRestoration + API response as a typed Pydantic model Raises ------ @@ -444,7 +462,8 @@ def create_restoration( def list_restorations( self, - queries: Optional[List[str]] = None ) -> BackupRestorationList: + queries: Optional[List[str]] = None + ) -> BackupRestorationList: """ List all backup restorations for a project. @@ -455,7 +474,8 @@ def list_restorations( Returns ------- - BackupRestorationList API response as a typed Pydantic model + BackupRestorationList + API response as a typed Pydantic model Raises ------ @@ -477,7 +497,8 @@ def list_restorations( def get_restoration( self, - restoration_id: str ) -> BackupRestoration: + restoration_id: str + ) -> BackupRestoration: """ Get the current status of a backup restoration. @@ -488,7 +509,8 @@ def get_restoration( Returns ------- - BackupRestoration API response as a typed Pydantic model + BackupRestoration + API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 2595561..f68dc40 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -47,7 +47,8 @@ def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> DatabaseList: + total: Optional[bool] = None + ) -> DatabaseList: """ Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. @@ -64,7 +65,8 @@ def list( Returns ------- - DatabaseList API response as a typed Pydantic model + DatabaseList + API response as a typed Pydantic model Raises ------ @@ -93,7 +95,8 @@ def create( self, database_id: str, name: str, - enabled: Optional[bool] = None ) -> Database: + enabled: Optional[bool] = None + ) -> Database: """ Create a new Database. @@ -111,7 +114,8 @@ def create( Returns ------- - Database API response as a typed Pydantic model + Database + API response as a typed Pydantic model Raises ------ @@ -142,7 +146,8 @@ def create( def list_transactions( self, - queries: Optional[List[str]] = None ) -> TransactionList: + queries: Optional[List[str]] = None + ) -> TransactionList: """ List transactions across all databases. @@ -153,7 +158,8 @@ def list_transactions( Returns ------- - TransactionList API response as a typed Pydantic model + TransactionList + API response as a typed Pydantic model Raises ------ @@ -175,7 +181,8 @@ def list_transactions( def create_transaction( self, - ttl: Optional[float] = None ) -> Transaction: + ttl: Optional[float] = None + ) -> Transaction: """ Create a new transaction. @@ -186,7 +193,8 @@ def create_transaction( Returns ------- - Transaction API response as a typed Pydantic model + Transaction + API response as a typed Pydantic model Raises ------ @@ -209,7 +217,8 @@ def create_transaction( def get_transaction( self, - transaction_id: str ) -> Transaction: + transaction_id: str + ) -> Transaction: """ Get a transaction by its unique ID. @@ -220,7 +229,8 @@ def get_transaction( Returns ------- - Transaction API response as a typed Pydantic model + Transaction + API response as a typed Pydantic model Raises ------ @@ -246,7 +256,8 @@ def update_transaction( self, transaction_id: str, commit: Optional[bool] = None, - rollback: Optional[bool] = None ) -> Transaction: + rollback: Optional[bool] = None + ) -> Transaction: """ Update a transaction, to either commit or roll back its operations. @@ -261,7 +272,8 @@ def update_transaction( Returns ------- - Transaction API response as a typed Pydantic model + Transaction + API response as a typed Pydantic model Raises ------ @@ -290,7 +302,8 @@ def update_transaction( def delete_transaction( self, - transaction_id: str ) -> Dict[str, Any]: + transaction_id: str + ) -> Dict[str, Any]: """ Delete a transaction by its unique ID. @@ -328,7 +341,8 @@ def delete_transaction( def create_operations( self, transaction_id: str, - operations: Optional[List[Dict[str, Any]]] = None ) -> Transaction: + operations: Optional[List[Dict[str, Any]]] = None + ) -> Transaction: """ Create multiple operations in a single transaction. @@ -341,7 +355,8 @@ def create_operations( Returns ------- - Transaction API response as a typed Pydantic model + Transaction + API response as a typed Pydantic model Raises ------ @@ -369,7 +384,8 @@ def create_operations( @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get` instead.") def get( self, - database_id: str ) -> Database: + database_id: str + ) -> Database: """ Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. @@ -382,7 +398,8 @@ def get( Returns ------- - Database API response as a typed Pydantic model + Database + API response as a typed Pydantic model Raises ------ @@ -409,7 +426,8 @@ def update( self, database_id: str, name: Optional[str] = None, - enabled: Optional[bool] = None ) -> Database: + enabled: Optional[bool] = None + ) -> Database: """ Update a database by its unique ID. @@ -426,7 +444,8 @@ def update( Returns ------- - Database API response as a typed Pydantic model + Database + API response as a typed Pydantic model Raises ------ @@ -456,7 +475,8 @@ def update( @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete` instead.") def delete( self, - database_id: str ) -> Dict[str, Any]: + database_id: str + ) -> Dict[str, Any]: """ Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. @@ -499,7 +519,8 @@ def list_collections( database_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> CollectionList: + total: Optional[bool] = None + ) -> CollectionList: """ Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. @@ -518,7 +539,8 @@ def list_collections( Returns ------- - CollectionList API response as a typed Pydantic model + CollectionList + API response as a typed Pydantic model Raises ------ @@ -556,7 +578,8 @@ def create_collection( document_security: Optional[bool] = None, enabled: Optional[bool] = None, attributes: Optional[List[Dict[str, Any]]] = None, - indexes: Optional[List[Dict[str, Any]]] = None ) -> Collection: + indexes: Optional[List[Dict[str, Any]]] = None + ) -> Collection: """ Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -583,7 +606,8 @@ def create_collection( Returns ------- - Collection API response as a typed Pydantic model + Collection + API response as a typed Pydantic model Raises ------ @@ -627,7 +651,8 @@ def create_collection( def get_collection( self, database_id: str, - collection_id: str ) -> Collection: + collection_id: str + ) -> Collection: """ Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. @@ -642,7 +667,8 @@ def get_collection( Returns ------- - Collection API response as a typed Pydantic model + Collection + API response as a typed Pydantic model Raises ------ @@ -676,7 +702,8 @@ def update_collection( name: Optional[str] = None, permissions: Optional[List[str]] = None, document_security: Optional[bool] = None, - enabled: Optional[bool] = None ) -> Collection: + enabled: Optional[bool] = None + ) -> Collection: """ Update a collection by its unique ID. @@ -699,7 +726,8 @@ def update_collection( Returns ------- - Collection API response as a typed Pydantic model + Collection + API response as a typed Pydantic model Raises ------ @@ -737,7 +765,8 @@ def update_collection( def delete_collection( self, database_id: str, - collection_id: str ) -> Dict[str, Any]: + collection_id: str + ) -> Dict[str, Any]: """ Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. @@ -786,7 +815,8 @@ def list_attributes( database_id: str, collection_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> AttributeList: + total: Optional[bool] = None + ) -> AttributeList: """ List attributes in the collection. @@ -805,7 +835,8 @@ def list_attributes( Returns ------- - AttributeList API response as a typed Pydantic model + AttributeList + API response as a typed Pydantic model Raises ------ @@ -843,7 +874,8 @@ def create_boolean_attribute( key: str, required: bool, default: Optional[bool] = None, - array: Optional[bool] = None ) -> AttributeBoolean: + array: Optional[bool] = None + ) -> AttributeBoolean: """ Create a boolean attribute. @@ -867,7 +899,8 @@ def create_boolean_attribute( Returns ------- - AttributeBoolean API response as a typed Pydantic model + AttributeBoolean + API response as a typed Pydantic model Raises ------ @@ -913,7 +946,8 @@ def update_boolean_attribute( key: str, required: bool, default: Optional[bool], - new_key: Optional[str] = None ) -> AttributeBoolean: + new_key: Optional[str] = None + ) -> AttributeBoolean: """ Update a boolean attribute. Changing the `default` value will not update already existing documents. @@ -936,7 +970,8 @@ def update_boolean_attribute( Returns ------- - AttributeBoolean API response as a typed Pydantic model + AttributeBoolean + API response as a typed Pydantic model Raises ------ @@ -981,7 +1016,8 @@ def create_datetime_attribute( key: str, required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> AttributeDatetime: + array: Optional[bool] = None + ) -> AttributeDatetime: """ Create a date time attribute according to the ISO 8601 standard. @@ -1004,7 +1040,8 @@ def create_datetime_attribute( Returns ------- - AttributeDatetime API response as a typed Pydantic model + AttributeDatetime + API response as a typed Pydantic model Raises ------ @@ -1050,7 +1087,8 @@ def update_datetime_attribute( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> AttributeDatetime: + new_key: Optional[str] = None + ) -> AttributeDatetime: """ Update a date time attribute. Changing the `default` value will not update already existing documents. @@ -1073,7 +1111,8 @@ def update_datetime_attribute( Returns ------- - AttributeDatetime API response as a typed Pydantic model + AttributeDatetime + API response as a typed Pydantic model Raises ------ @@ -1118,7 +1157,8 @@ def create_email_attribute( key: str, required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> AttributeEmail: + array: Optional[bool] = None + ) -> AttributeEmail: """ Create an email attribute. @@ -1142,7 +1182,8 @@ def create_email_attribute( Returns ------- - AttributeEmail API response as a typed Pydantic model + AttributeEmail + API response as a typed Pydantic model Raises ------ @@ -1188,7 +1229,8 @@ def update_email_attribute( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> AttributeEmail: + new_key: Optional[str] = None + ) -> AttributeEmail: """ Update an email attribute. Changing the `default` value will not update already existing documents. @@ -1212,7 +1254,8 @@ def update_email_attribute( Returns ------- - AttributeEmail API response as a typed Pydantic model + AttributeEmail + API response as a typed Pydantic model Raises ------ @@ -1258,7 +1301,8 @@ def create_enum_attribute( elements: List[str], required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> AttributeEnum: + array: Optional[bool] = None + ) -> AttributeEnum: """ Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. @@ -1284,7 +1328,8 @@ def create_enum_attribute( Returns ------- - AttributeEnum API response as a typed Pydantic model + AttributeEnum + API response as a typed Pydantic model Raises ------ @@ -1335,7 +1380,8 @@ def update_enum_attribute( elements: List[str], required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> AttributeEnum: + new_key: Optional[str] = None + ) -> AttributeEnum: """ Update an enum attribute. Changing the `default` value will not update already existing documents. @@ -1361,7 +1407,8 @@ def update_enum_attribute( Returns ------- - AttributeEnum API response as a typed Pydantic model + AttributeEnum + API response as a typed Pydantic model Raises ------ @@ -1412,7 +1459,8 @@ def create_float_attribute( min: Optional[float] = None, max: Optional[float] = None, default: Optional[float] = None, - array: Optional[bool] = None ) -> AttributeFloat: + array: Optional[bool] = None + ) -> AttributeFloat: """ Create a float attribute. Optionally, minimum and maximum values can be provided. @@ -1440,7 +1488,8 @@ def create_float_attribute( Returns ------- - AttributeFloat API response as a typed Pydantic model + AttributeFloat + API response as a typed Pydantic model Raises ------ @@ -1490,7 +1539,8 @@ def update_float_attribute( default: Optional[float], min: Optional[float] = None, max: Optional[float] = None, - new_key: Optional[str] = None ) -> AttributeFloat: + new_key: Optional[str] = None + ) -> AttributeFloat: """ Update a float attribute. Changing the `default` value will not update already existing documents. @@ -1518,7 +1568,8 @@ def update_float_attribute( Returns ------- - AttributeFloat API response as a typed Pydantic model + AttributeFloat + API response as a typed Pydantic model Raises ------ @@ -1567,7 +1618,8 @@ def create_integer_attribute( min: Optional[float] = None, max: Optional[float] = None, default: Optional[float] = None, - array: Optional[bool] = None ) -> AttributeInteger: + array: Optional[bool] = None + ) -> AttributeInteger: """ Create an integer attribute. Optionally, minimum and maximum values can be provided. @@ -1595,7 +1647,8 @@ def create_integer_attribute( Returns ------- - AttributeInteger API response as a typed Pydantic model + AttributeInteger + API response as a typed Pydantic model Raises ------ @@ -1645,7 +1698,8 @@ def update_integer_attribute( default: Optional[float], min: Optional[float] = None, max: Optional[float] = None, - new_key: Optional[str] = None ) -> AttributeInteger: + new_key: Optional[str] = None + ) -> AttributeInteger: """ Update an integer attribute. Changing the `default` value will not update already existing documents. @@ -1673,7 +1727,8 @@ def update_integer_attribute( Returns ------- - AttributeInteger API response as a typed Pydantic model + AttributeInteger + API response as a typed Pydantic model Raises ------ @@ -1720,7 +1775,8 @@ def create_ip_attribute( key: str, required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> AttributeIp: + array: Optional[bool] = None + ) -> AttributeIp: """ Create IP address attribute. @@ -1744,7 +1800,8 @@ def create_ip_attribute( Returns ------- - AttributeIp API response as a typed Pydantic model + AttributeIp + API response as a typed Pydantic model Raises ------ @@ -1790,7 +1847,8 @@ def update_ip_attribute( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> AttributeIp: + new_key: Optional[str] = None + ) -> AttributeIp: """ Update an ip attribute. Changing the `default` value will not update already existing documents. @@ -1814,7 +1872,8 @@ def update_ip_attribute( Returns ------- - AttributeIp API response as a typed Pydantic model + AttributeIp + API response as a typed Pydantic model Raises ------ @@ -1858,7 +1917,8 @@ def create_line_attribute( collection_id: str, key: str, required: bool, - default: Optional[List[Any]] = None ) -> AttributeLine: + default: Optional[List[Any]] = None + ) -> AttributeLine: """ Create a geometric line attribute. @@ -1879,7 +1939,8 @@ def create_line_attribute( Returns ------- - AttributeLine API response as a typed Pydantic model + AttributeLine + API response as a typed Pydantic model Raises ------ @@ -1923,7 +1984,8 @@ def update_line_attribute( key: str, required: bool, default: Optional[List[Any]] = None, - new_key: Optional[str] = None ) -> AttributeLine: + new_key: Optional[str] = None + ) -> AttributeLine: """ Update a line attribute. Changing the `default` value will not update already existing documents. @@ -1946,7 +2008,8 @@ def update_line_attribute( Returns ------- - AttributeLine API response as a typed Pydantic model + AttributeLine + API response as a typed Pydantic model Raises ------ @@ -1991,7 +2054,8 @@ def create_longtext_attribute( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> AttributeLongtext: + encrypt: Optional[bool] = None + ) -> AttributeLongtext: """ Create a longtext attribute. @@ -2015,7 +2079,8 @@ def create_longtext_attribute( Returns ------- - AttributeLongtext API response as a typed Pydantic model + AttributeLongtext + API response as a typed Pydantic model Raises ------ @@ -2062,7 +2127,8 @@ def update_longtext_attribute( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> AttributeLongtext: + new_key: Optional[str] = None + ) -> AttributeLongtext: """ Update a longtext attribute. Changing the `default` value will not update already existing documents. @@ -2084,7 +2150,8 @@ def update_longtext_attribute( Returns ------- - AttributeLongtext API response as a typed Pydantic model + AttributeLongtext + API response as a typed Pydantic model Raises ------ @@ -2129,7 +2196,8 @@ def create_mediumtext_attribute( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> AttributeMediumtext: + encrypt: Optional[bool] = None + ) -> AttributeMediumtext: """ Create a mediumtext attribute. @@ -2153,7 +2221,8 @@ def create_mediumtext_attribute( Returns ------- - AttributeMediumtext API response as a typed Pydantic model + AttributeMediumtext + API response as a typed Pydantic model Raises ------ @@ -2200,7 +2269,8 @@ def update_mediumtext_attribute( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> AttributeMediumtext: + new_key: Optional[str] = None + ) -> AttributeMediumtext: """ Update a mediumtext attribute. Changing the `default` value will not update already existing documents. @@ -2222,7 +2292,8 @@ def update_mediumtext_attribute( Returns ------- - AttributeMediumtext API response as a typed Pydantic model + AttributeMediumtext + API response as a typed Pydantic model Raises ------ @@ -2266,7 +2337,8 @@ def create_point_attribute( collection_id: str, key: str, required: bool, - default: Optional[List[Any]] = None ) -> AttributePoint: + default: Optional[List[Any]] = None + ) -> AttributePoint: """ Create a geometric point attribute. @@ -2287,7 +2359,8 @@ def create_point_attribute( Returns ------- - AttributePoint API response as a typed Pydantic model + AttributePoint + API response as a typed Pydantic model Raises ------ @@ -2331,7 +2404,8 @@ def update_point_attribute( key: str, required: bool, default: Optional[List[Any]] = None, - new_key: Optional[str] = None ) -> AttributePoint: + new_key: Optional[str] = None + ) -> AttributePoint: """ Update a point attribute. Changing the `default` value will not update already existing documents. @@ -2354,7 +2428,8 @@ def update_point_attribute( Returns ------- - AttributePoint API response as a typed Pydantic model + AttributePoint + API response as a typed Pydantic model Raises ------ @@ -2398,7 +2473,8 @@ def create_polygon_attribute( collection_id: str, key: str, required: bool, - default: Optional[List[Any]] = None ) -> AttributePolygon: + default: Optional[List[Any]] = None + ) -> AttributePolygon: """ Create a geometric polygon attribute. @@ -2419,7 +2495,8 @@ def create_polygon_attribute( Returns ------- - AttributePolygon API response as a typed Pydantic model + AttributePolygon + API response as a typed Pydantic model Raises ------ @@ -2463,7 +2540,8 @@ def update_polygon_attribute( key: str, required: bool, default: Optional[List[Any]] = None, - new_key: Optional[str] = None ) -> AttributePolygon: + new_key: Optional[str] = None + ) -> AttributePolygon: """ Update a polygon attribute. Changing the `default` value will not update already existing documents. @@ -2486,7 +2564,8 @@ def update_polygon_attribute( Returns ------- - AttributePolygon API response as a typed Pydantic model + AttributePolygon + API response as a typed Pydantic model Raises ------ @@ -2533,7 +2612,8 @@ def create_relationship_attribute( two_way: Optional[bool] = None, key: Optional[str] = None, two_way_key: Optional[str] = None, - on_delete: Optional[RelationMutate] = None ) -> AttributeRelationship: + on_delete: Optional[RelationMutate] = None + ) -> AttributeRelationship: """ Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -2561,7 +2641,8 @@ def create_relationship_attribute( Returns ------- - AttributeRelationship API response as a typed Pydantic model + AttributeRelationship + API response as a typed Pydantic model Raises ------ @@ -2609,7 +2690,8 @@ def update_relationship_attribute( collection_id: str, key: str, on_delete: Optional[RelationMutate] = None, - new_key: Optional[str] = None ) -> AttributeRelationship: + new_key: Optional[str] = None + ) -> AttributeRelationship: """ Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). @@ -2631,7 +2713,8 @@ def update_relationship_attribute( Returns ------- - AttributeRelationship API response as a typed Pydantic model + AttributeRelationship + API response as a typed Pydantic model Raises ------ @@ -2675,7 +2758,8 @@ def create_string_attribute( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> AttributeString: + encrypt: Optional[bool] = None + ) -> AttributeString: """ Create a string attribute. @@ -2703,7 +2787,8 @@ def create_string_attribute( Returns ------- - AttributeString API response as a typed Pydantic model + AttributeString + API response as a typed Pydantic model Raises ------ @@ -2756,7 +2841,8 @@ def update_string_attribute( required: bool, default: Optional[str], size: Optional[float] = None, - new_key: Optional[str] = None ) -> AttributeString: + new_key: Optional[str] = None + ) -> AttributeString: """ Update a string attribute. Changing the `default` value will not update already existing documents. @@ -2782,7 +2868,8 @@ def update_string_attribute( Returns ------- - AttributeString API response as a typed Pydantic model + AttributeString + API response as a typed Pydantic model Raises ------ @@ -2828,7 +2915,8 @@ def create_text_attribute( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> AttributeText: + encrypt: Optional[bool] = None + ) -> AttributeText: """ Create a text attribute. @@ -2852,7 +2940,8 @@ def create_text_attribute( Returns ------- - AttributeText API response as a typed Pydantic model + AttributeText + API response as a typed Pydantic model Raises ------ @@ -2899,7 +2988,8 @@ def update_text_attribute( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> AttributeText: + new_key: Optional[str] = None + ) -> AttributeText: """ Update a text attribute. Changing the `default` value will not update already existing documents. @@ -2921,7 +3011,8 @@ def update_text_attribute( Returns ------- - AttributeText API response as a typed Pydantic model + AttributeText + API response as a typed Pydantic model Raises ------ @@ -2966,7 +3057,8 @@ def create_url_attribute( key: str, required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> AttributeUrl: + array: Optional[bool] = None + ) -> AttributeUrl: """ Create a URL attribute. @@ -2990,7 +3082,8 @@ def create_url_attribute( Returns ------- - AttributeUrl API response as a typed Pydantic model + AttributeUrl + API response as a typed Pydantic model Raises ------ @@ -3036,7 +3129,8 @@ def update_url_attribute( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> AttributeUrl: + new_key: Optional[str] = None + ) -> AttributeUrl: """ Update an url attribute. Changing the `default` value will not update already existing documents. @@ -3060,7 +3154,8 @@ def update_url_attribute( Returns ------- - AttributeUrl API response as a typed Pydantic model + AttributeUrl + API response as a typed Pydantic model Raises ------ @@ -3106,7 +3201,8 @@ def create_varchar_attribute( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> AttributeVarchar: + encrypt: Optional[bool] = None + ) -> AttributeVarchar: """ Create a varchar attribute. @@ -3132,7 +3228,8 @@ def create_varchar_attribute( Returns ------- - AttributeVarchar API response as a typed Pydantic model + AttributeVarchar + API response as a typed Pydantic model Raises ------ @@ -3184,7 +3281,8 @@ def update_varchar_attribute( required: bool, default: Optional[str], size: Optional[float] = None, - new_key: Optional[str] = None ) -> AttributeVarchar: + new_key: Optional[str] = None + ) -> AttributeVarchar: """ Update a varchar attribute. Changing the `default` value will not update already existing documents. @@ -3208,7 +3306,8 @@ def update_varchar_attribute( Returns ------- - AttributeVarchar API response as a typed Pydantic model + AttributeVarchar + API response as a typed Pydantic model Raises ------ @@ -3251,7 +3350,8 @@ def get_attribute( self, database_id: str, collection_id: str, - key: str ) -> Union[AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString]: + key: str + ) -> Union[AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString]: """ Get attribute by ID. @@ -3304,7 +3404,8 @@ def delete_attribute( self, database_id: str, collection_id: str, - key: str ) -> Dict[str, Any]: + key: str + ) -> Dict[str, Any]: """ Deletes an attribute. @@ -3362,7 +3463,8 @@ def list_documents( transaction_id: Optional[str] = None, total: Optional[bool] = None, ttl: Optional[float] = None, - model_type: Type[T] = dict ) -> DocumentList[T]: + model_type: Type[T] = dict + ) -> DocumentList[T]: """ Get a list of all the user's documents in a given collection. You can use the query params to filter your results. @@ -3388,7 +3490,8 @@ def list_documents( Returns ------- - DocumentList[T] API response as a typed Pydantic model + DocumentList[T] + API response as a typed Pydantic model Raises ------ @@ -3431,7 +3534,8 @@ def create_document( data: Dict[str, Any], permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Document[T]: + model_type: Type[T] = dict + ) -> Document[T]: """ Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3457,7 +3561,8 @@ def create_document( Returns ------- - Document[T] API response as a typed Pydantic model + Document[T] + API response as a typed Pydantic model Raises ------ @@ -3501,7 +3606,8 @@ def create_documents( collection_id: str, documents: List[Dict[str, Any]], transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> DocumentList[T]: + model_type: Type[T] = dict + ) -> DocumentList[T]: """ Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3523,7 +3629,8 @@ def create_documents( Returns ------- - DocumentList[T] API response as a typed Pydantic model + DocumentList[T] + API response as a typed Pydantic model Raises ------ @@ -3562,7 +3669,8 @@ def upsert_documents( collection_id: str, documents: List[Dict[str, Any]], transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> DocumentList[T]: + model_type: Type[T] = dict + ) -> DocumentList[T]: """ Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3585,7 +3693,8 @@ def upsert_documents( Returns ------- - DocumentList[T] API response as a typed Pydantic model + DocumentList[T] + API response as a typed Pydantic model Raises ------ @@ -3625,7 +3734,8 @@ def update_documents( data: Optional[Dict[str, Any]] = None, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> DocumentList[T]: + model_type: Type[T] = dict + ) -> DocumentList[T]: """ Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. @@ -3649,7 +3759,8 @@ def update_documents( Returns ------- - DocumentList[T] API response as a typed Pydantic model + DocumentList[T] + API response as a typed Pydantic model Raises ------ @@ -3688,7 +3799,8 @@ def delete_documents( collection_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> DocumentList[T]: + model_type: Type[T] = dict + ) -> DocumentList[T]: """ Bulk delete documents using queries, if no queries are passed then all documents are deleted. @@ -3710,7 +3822,8 @@ def delete_documents( Returns ------- - DocumentList[T] API response as a typed Pydantic model + DocumentList[T] + API response as a typed Pydantic model Raises ------ @@ -3748,7 +3861,8 @@ def get_document( document_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Document[T]: + model_type: Type[T] = dict + ) -> Document[T]: """ Get a document by its unique ID. This endpoint response returns a JSON object with the document data. @@ -3772,7 +3886,8 @@ def get_document( Returns ------- - Document[T] API response as a typed Pydantic model + Document[T] + API response as a typed Pydantic model Raises ------ @@ -3815,7 +3930,8 @@ def upsert_document( data: Optional[Dict[str, Any]] = None, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Document[T]: + model_type: Type[T] = dict + ) -> Document[T]: """ Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -3841,7 +3957,8 @@ def upsert_document( Returns ------- - Document[T] API response as a typed Pydantic model + Document[T] + API response as a typed Pydantic model Raises ------ @@ -3885,7 +4002,8 @@ def update_document( data: Optional[Dict[str, Any]] = None, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Document[T]: + model_type: Type[T] = dict + ) -> Document[T]: """ Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -3911,7 +4029,8 @@ def update_document( Returns ------- - Document[T] API response as a typed Pydantic model + Document[T] + API response as a typed Pydantic model Raises ------ @@ -3952,7 +4071,8 @@ def delete_document( database_id: str, collection_id: str, document_id: str, - transaction_id: Optional[str] = None ) -> Dict[str, Any]: + transaction_id: Optional[str] = None + ) -> Dict[str, Any]: """ Delete a document by its unique ID. @@ -4014,7 +4134,8 @@ def decrement_document_attribute( value: Optional[float] = None, min: Optional[float] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Document[T]: + model_type: Type[T] = dict + ) -> Document[T]: """ Decrement a specific attribute of a document by a given value. @@ -4042,7 +4163,8 @@ def decrement_document_attribute( Returns ------- - Document[T] API response as a typed Pydantic model + Document[T] + API response as a typed Pydantic model Raises ------ @@ -4091,7 +4213,8 @@ def increment_document_attribute( value: Optional[float] = None, max: Optional[float] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Document[T]: + model_type: Type[T] = dict + ) -> Document[T]: """ Increment a specific attribute of a document by a given value. @@ -4119,7 +4242,8 @@ def increment_document_attribute( Returns ------- - Document[T] API response as a typed Pydantic model + Document[T] + API response as a typed Pydantic model Raises ------ @@ -4164,7 +4288,8 @@ def list_indexes( database_id: str, collection_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> IndexList: + total: Optional[bool] = None + ) -> IndexList: """ List indexes in the collection. @@ -4183,7 +4308,8 @@ def list_indexes( Returns ------- - IndexList API response as a typed Pydantic model + IndexList + API response as a typed Pydantic model Raises ------ @@ -4222,7 +4348,8 @@ def create_index( type: IndexType, attributes: List[str], orders: Optional[List[OrderBy]] = None, - lengths: Optional[List[float]] = None ) -> Index: + lengths: Optional[List[float]] = None + ) -> Index: """ Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. Attributes can be `key`, `fulltext`, and `unique`. @@ -4248,7 +4375,8 @@ def create_index( Returns ------- - Index API response as a typed Pydantic model + Index + API response as a typed Pydantic model Raises ------ @@ -4296,7 +4424,8 @@ def get_index( self, database_id: str, collection_id: str, - key: str ) -> Index: + key: str + ) -> Index: """ Get an index by its unique ID. @@ -4313,7 +4442,8 @@ def get_index( Returns ------- - Index API response as a typed Pydantic model + Index + API response as a typed Pydantic model Raises ------ @@ -4348,7 +4478,8 @@ def delete_index( self, database_id: str, collection_id: str, - key: str ) -> Dict[str, Any]: + key: str + ) -> Dict[str, Any]: """ Delete an index. diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index 0fdddff..e637020 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -29,7 +29,8 @@ def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> FunctionList: + total: Optional[bool] = None + ) -> FunctionList: """ Get a list of all the project's functions. You can use the query params to filter your results. @@ -44,7 +45,8 @@ def list( Returns ------- - FunctionList API response as a typed Pydantic model + FunctionList + API response as a typed Pydantic model Raises ------ @@ -87,7 +89,8 @@ def create( provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, - specification: Optional[str] = None ) -> Function: + specification: Optional[str] = None + ) -> Function: """ Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. @@ -132,7 +135,8 @@ def create( Returns ------- - Function API response as a typed Pydantic model + Function + API response as a typed Pydantic model Raises ------ @@ -194,13 +198,15 @@ def create( def list_runtimes( - self ) -> RuntimeList: + self + ) -> RuntimeList: """ Get a list of all runtimes that are currently active on your instance. Returns ------- - RuntimeList API response as a typed Pydantic model + RuntimeList + API response as a typed Pydantic model Raises ------ @@ -218,13 +224,15 @@ def list_runtimes( def list_specifications( - self ) -> SpecificationList: + self + ) -> SpecificationList: """ List allowed function specifications for this instance. Returns ------- - SpecificationList API response as a typed Pydantic model + SpecificationList + API response as a typed Pydantic model Raises ------ @@ -243,7 +251,8 @@ def list_specifications( def get( self, - function_id: str ) -> Function: + function_id: str + ) -> Function: """ Get a function by its unique ID. @@ -254,7 +263,8 @@ def get( Returns ------- - Function API response as a typed Pydantic model + Function + API response as a typed Pydantic model Raises ------ @@ -295,7 +305,8 @@ def update( provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, - specification: Optional[str] = None ) -> Function: + specification: Optional[str] = None + ) -> Function: """ Update function by its unique ID. @@ -340,7 +351,8 @@ def update( Returns ------- - Function API response as a typed Pydantic model + Function + API response as a typed Pydantic model Raises ------ @@ -400,7 +412,8 @@ def update( def delete( self, - function_id: str ) -> Dict[str, Any]: + function_id: str + ) -> Dict[str, Any]: """ Delete a function by its unique ID. @@ -438,7 +451,8 @@ def delete( def update_function_deployment( self, function_id: str, - deployment_id: str ) -> Function: + deployment_id: str + ) -> Function: """ Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. @@ -451,7 +465,8 @@ def update_function_deployment( Returns ------- - Function API response as a typed Pydantic model + Function + API response as a typed Pydantic model Raises ------ @@ -483,7 +498,8 @@ def list_deployments( function_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> DeploymentList: + total: Optional[bool] = None + ) -> DeploymentList: """ Get a list of all the function's code deployments. You can use the query params to filter your results. @@ -500,7 +516,8 @@ def list_deployments( Returns ------- - DeploymentList API response as a typed Pydantic model + DeploymentList + API response as a typed Pydantic model Raises ------ @@ -535,7 +552,8 @@ def create_deployment( activate: bool, entrypoint: Optional[str] = None, commands: Optional[str] = None, - on_progress = None ) -> Deployment: + on_progress = None + ) -> Deployment: """ Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. @@ -560,7 +578,8 @@ def create_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -604,7 +623,8 @@ def create_duplicate_deployment( self, function_id: str, deployment_id: str, - build_id: Optional[str] = None ) -> Deployment: + build_id: Optional[str] = None + ) -> Deployment: """ Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. @@ -619,7 +639,8 @@ def create_duplicate_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -656,7 +677,8 @@ def create_template_deployment( root_directory: str, type: TemplateReferenceType, reference: str, - activate: Optional[bool] = None ) -> Deployment: + activate: Optional[bool] = None + ) -> Deployment: """ Create a deployment based on a template. @@ -681,7 +703,8 @@ def create_template_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -731,7 +754,8 @@ def create_vcs_deployment( function_id: str, type: VCSReferenceType, reference: str, - activate: Optional[bool] = None ) -> Deployment: + activate: Optional[bool] = None + ) -> Deployment: """ Create a deployment when a function is connected to VCS. @@ -750,7 +774,8 @@ def create_vcs_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -786,7 +811,8 @@ def create_vcs_deployment( def get_deployment( self, function_id: str, - deployment_id: str ) -> Deployment: + deployment_id: str + ) -> Deployment: """ Get a function deployment by its unique ID. @@ -799,7 +825,8 @@ def get_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -828,7 +855,8 @@ def get_deployment( def delete_deployment( self, function_id: str, - deployment_id: str ) -> Dict[str, Any]: + deployment_id: str + ) -> Dict[str, Any]: """ Delete a code deployment by its unique ID. @@ -873,7 +901,8 @@ def get_deployment_download( self, function_id: str, deployment_id: str, - type: Optional[DeploymentDownloadType] = None ) -> bytes: + type: Optional[DeploymentDownloadType] = None + ) -> bytes: """ Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. @@ -920,7 +949,8 @@ def get_deployment_download( def update_deployment_status( self, function_id: str, - deployment_id: str ) -> Deployment: + deployment_id: str + ) -> Deployment: """ Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. @@ -933,7 +963,8 @@ def update_deployment_status( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -964,7 +995,8 @@ def list_executions( self, function_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> ExecutionList: + total: Optional[bool] = None + ) -> ExecutionList: """ Get a list of all the current user function execution logs. You can use the query params to filter your results. @@ -979,7 +1011,8 @@ def list_executions( Returns ------- - ExecutionList API response as a typed Pydantic model + ExecutionList + API response as a typed Pydantic model Raises ------ @@ -1013,7 +1046,8 @@ def create_execution( path: Optional[str] = None, method: Optional[ExecutionMethod] = None, headers: Optional[Dict[str, Any]] = None, - scheduled_at: Optional[str] = None ) -> Execution: + scheduled_at: Optional[str] = None + ) -> Execution: """ Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. @@ -1036,7 +1070,8 @@ def create_execution( Returns ------- - Execution API response as a typed Pydantic model + Execution + API response as a typed Pydantic model Raises ------ @@ -1073,7 +1108,8 @@ def create_execution( def get_execution( self, function_id: str, - execution_id: str ) -> Execution: + execution_id: str + ) -> Execution: """ Get a function execution log by its unique ID. @@ -1086,7 +1122,8 @@ def get_execution( Returns ------- - Execution API response as a typed Pydantic model + Execution + API response as a typed Pydantic model Raises ------ @@ -1115,7 +1152,8 @@ def get_execution( def delete_execution( self, function_id: str, - execution_id: str ) -> Dict[str, Any]: + execution_id: str + ) -> Dict[str, Any]: """ Delete a function execution by its unique ID. @@ -1158,7 +1196,8 @@ def delete_execution( def list_variables( self, - function_id: str ) -> VariableList: + function_id: str + ) -> VariableList: """ Get a list of all variables of a specific function. @@ -1169,7 +1208,8 @@ def list_variables( Returns ------- - VariableList API response as a typed Pydantic model + VariableList + API response as a typed Pydantic model Raises ------ @@ -1196,7 +1236,8 @@ def create_variable( function_id: str, key: str, value: str, - secret: Optional[bool] = None ) -> Variable: + secret: Optional[bool] = None + ) -> Variable: """ Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. @@ -1213,7 +1254,8 @@ def create_variable( Returns ------- - Variable API response as a typed Pydantic model + Variable + API response as a typed Pydantic model Raises ------ @@ -1249,7 +1291,8 @@ def create_variable( def get_variable( self, function_id: str, - variable_id: str ) -> Variable: + variable_id: str + ) -> Variable: """ Get a variable by its unique ID. @@ -1262,7 +1305,8 @@ def get_variable( Returns ------- - Variable API response as a typed Pydantic model + Variable + API response as a typed Pydantic model Raises ------ @@ -1294,7 +1338,8 @@ def update_variable( variable_id: str, key: str, value: Optional[str] = None, - secret: Optional[bool] = None ) -> Variable: + secret: Optional[bool] = None + ) -> Variable: """ Update variable by its unique ID. @@ -1313,7 +1358,8 @@ def update_variable( Returns ------- - Variable API response as a typed Pydantic model + Variable + API response as a typed Pydantic model Raises ------ @@ -1349,7 +1395,8 @@ def update_variable( def delete_variable( self, function_id: str, - variable_id: str ) -> Dict[str, Any]: + variable_id: str + ) -> Dict[str, Any]: """ Delete a variable by its unique ID. diff --git a/appwrite/services/graphql.py b/appwrite/services/graphql.py index 7ea15c1..12b6668 100644 --- a/appwrite/services/graphql.py +++ b/appwrite/services/graphql.py @@ -10,7 +10,8 @@ def __init__(self, client) -> None: def query( self, - query: Dict[str, Any] ) -> Dict[str, Any]: + query: Dict[str, Any] + ) -> Dict[str, Any]: """ Execute a GraphQL mutation. @@ -48,7 +49,8 @@ def query( def mutation( self, - query: Dict[str, Any] ) -> Dict[str, Any]: + query: Dict[str, Any] + ) -> Dict[str, Any]: """ Execute a GraphQL mutation. diff --git a/appwrite/services/health.py b/appwrite/services/health.py index 0fc4a98..35c5366 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -16,13 +16,15 @@ def __init__(self, client) -> None: super(Health, self).__init__(client) def get( - self ) -> HealthStatus: + self + ) -> HealthStatus: """ Check the Appwrite HTTP server is up and responsive. Returns ------- - HealthStatus API response as a typed Pydantic model + HealthStatus + API response as a typed Pydantic model Raises ------ @@ -40,13 +42,15 @@ def get( def get_antivirus( - self ) -> HealthAntivirus: + self + ) -> HealthAntivirus: """ Check the Appwrite Antivirus server is up and connection is successful. Returns ------- - HealthAntivirus API response as a typed Pydantic model + HealthAntivirus + API response as a typed Pydantic model Raises ------ @@ -64,13 +68,15 @@ def get_antivirus( def get_cache( - self ) -> HealthStatusList: + self + ) -> HealthStatusList: """ Check the Appwrite in-memory cache servers are up and connection is successful. Returns ------- - HealthStatusList API response as a typed Pydantic model + HealthStatusList + API response as a typed Pydantic model Raises ------ @@ -89,7 +95,8 @@ def get_cache( def get_certificate( self, - domain: Optional[str] = None ) -> HealthCertificate: + domain: Optional[str] = None + ) -> HealthCertificate: """ Get the SSL certificate for a domain @@ -100,7 +107,8 @@ def get_certificate( Returns ------- - HealthCertificate API response as a typed Pydantic model + HealthCertificate + API response as a typed Pydantic model Raises ------ @@ -123,7 +131,8 @@ def get_certificate( def get_console_pausing( self, threshold: Optional[float] = None, - inactivity_days: Optional[float] = None ) -> HealthStatus: + inactivity_days: Optional[float] = None + ) -> HealthStatus: """ Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking. @@ -137,7 +146,8 @@ def get_console_pausing( Returns ------- - HealthStatus API response as a typed Pydantic model + HealthStatus + API response as a typed Pydantic model Raises ------ @@ -160,13 +170,15 @@ def get_console_pausing( def get_db( - self ) -> HealthStatusList: + self + ) -> HealthStatusList: """ Check the Appwrite database servers are up and connection is successful. Returns ------- - HealthStatusList API response as a typed Pydantic model + HealthStatusList + API response as a typed Pydantic model Raises ------ @@ -184,13 +196,15 @@ def get_db( def get_pub_sub( - self ) -> HealthStatusList: + self + ) -> HealthStatusList: """ Check the Appwrite pub-sub servers are up and connection is successful. Returns ------- - HealthStatusList API response as a typed Pydantic model + HealthStatusList + API response as a typed Pydantic model Raises ------ @@ -209,7 +223,8 @@ def get_pub_sub( def get_queue_audits( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server. @@ -220,7 +235,8 @@ def get_queue_audits( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -242,7 +258,8 @@ def get_queue_audits( def get_queue_billing_project_aggregation( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get billing project aggregation queue. @@ -253,7 +270,8 @@ def get_queue_billing_project_aggregation( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -275,7 +293,8 @@ def get_queue_billing_project_aggregation( def get_queue_billing_team_aggregation( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get billing team aggregation queue. @@ -286,7 +305,8 @@ def get_queue_billing_team_aggregation( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -308,7 +328,8 @@ def get_queue_billing_team_aggregation( def get_queue_builds( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of builds that are waiting to be processed in the Appwrite internal queue server. @@ -319,7 +340,8 @@ def get_queue_builds( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -341,7 +363,8 @@ def get_queue_builds( def get_queue_priority_builds( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the priority builds queue size. @@ -352,7 +375,8 @@ def get_queue_priority_builds( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -374,7 +398,8 @@ def get_queue_priority_builds( def get_queue_certificates( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. @@ -385,7 +410,8 @@ def get_queue_certificates( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -408,7 +434,8 @@ def get_queue_certificates( def get_queue_databases( self, name: Optional[str] = None, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. @@ -421,7 +448,8 @@ def get_queue_databases( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -445,7 +473,8 @@ def get_queue_databases( def get_queue_deletes( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. @@ -456,7 +485,8 @@ def get_queue_deletes( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -479,7 +509,8 @@ def get_queue_deletes( def get_failed_jobs( self, name: Name, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Returns the amount of failed jobs in a given queue. @@ -493,7 +524,8 @@ def get_failed_jobs( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -519,7 +551,8 @@ def get_failed_jobs( def get_queue_functions( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of function executions that are waiting to be processed in the Appwrite internal queue server. @@ -530,7 +563,8 @@ def get_queue_functions( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -552,7 +586,8 @@ def get_queue_functions( def get_queue_logs( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of logs that are waiting to be processed in the Appwrite internal queue server. @@ -563,7 +598,8 @@ def get_queue_logs( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -585,7 +621,8 @@ def get_queue_logs( def get_queue_mails( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of mails that are waiting to be processed in the Appwrite internal queue server. @@ -596,7 +633,8 @@ def get_queue_mails( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -618,7 +656,8 @@ def get_queue_mails( def get_queue_messaging( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of messages that are waiting to be processed in the Appwrite internal queue server. @@ -629,7 +668,8 @@ def get_queue_messaging( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -651,7 +691,8 @@ def get_queue_messaging( def get_queue_migrations( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. @@ -662,7 +703,8 @@ def get_queue_migrations( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -684,7 +726,8 @@ def get_queue_migrations( def get_queue_region_manager( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get region manager queue. @@ -695,7 +738,8 @@ def get_queue_region_manager( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -717,7 +761,8 @@ def get_queue_region_manager( def get_queue_stats_resources( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. @@ -728,7 +773,8 @@ def get_queue_stats_resources( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -750,7 +796,8 @@ def get_queue_stats_resources( def get_queue_usage( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of metrics that are waiting to be processed in the Appwrite internal queue server. @@ -761,7 +808,8 @@ def get_queue_usage( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -783,7 +831,8 @@ def get_queue_usage( def get_queue_threats( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get threats queue. @@ -794,7 +843,8 @@ def get_queue_threats( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -816,7 +866,8 @@ def get_queue_threats( def get_queue_webhooks( self, - threshold: Optional[float] = None ) -> HealthQueue: + threshold: Optional[float] = None + ) -> HealthQueue: """ Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. @@ -827,7 +878,8 @@ def get_queue_webhooks( Returns ------- - HealthQueue API response as a typed Pydantic model + HealthQueue + API response as a typed Pydantic model Raises ------ @@ -848,13 +900,15 @@ def get_queue_webhooks( def get_storage( - self ) -> HealthStatus: + self + ) -> HealthStatus: """ Check the Appwrite storage device is up and connection is successful. Returns ------- - HealthStatus API response as a typed Pydantic model + HealthStatus + API response as a typed Pydantic model Raises ------ @@ -872,13 +926,15 @@ def get_storage( def get_storage_local( - self ) -> HealthStatus: + self + ) -> HealthStatus: """ Check the Appwrite local storage device is up and connection is successful. Returns ------- - HealthStatus API response as a typed Pydantic model + HealthStatus + API response as a typed Pydantic model Raises ------ @@ -896,13 +952,15 @@ def get_storage_local( def get_time( - self ) -> HealthTime: + self + ) -> HealthTime: """ Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP. Returns ------- - HealthTime API response as a typed Pydantic model + HealthTime + API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/locale.py b/appwrite/services/locale.py index 0969153..a2573e6 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -16,7 +16,8 @@ def __init__(self, client) -> None: super(Locale, self).__init__(client) def get( - self ) -> LocaleModel: + self + ) -> LocaleModel: """ Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language. @@ -24,7 +25,8 @@ def get( Returns ------- - LocaleModel API response as a typed Pydantic model + LocaleModel + API response as a typed Pydantic model Raises ------ @@ -42,13 +44,15 @@ def get( def list_codes( - self ) -> LocaleCodeList: + self + ) -> LocaleCodeList: """ List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). Returns ------- - LocaleCodeList API response as a typed Pydantic model + LocaleCodeList + API response as a typed Pydantic model Raises ------ @@ -66,13 +70,15 @@ def list_codes( def list_continents( - self ) -> ContinentList: + self + ) -> ContinentList: """ List of all continents. You can use the locale header to get the data in a supported language. Returns ------- - ContinentList API response as a typed Pydantic model + ContinentList + API response as a typed Pydantic model Raises ------ @@ -90,13 +96,15 @@ def list_continents( def list_countries( - self ) -> CountryList: + self + ) -> CountryList: """ List of all countries. You can use the locale header to get the data in a supported language. Returns ------- - CountryList API response as a typed Pydantic model + CountryList + API response as a typed Pydantic model Raises ------ @@ -114,13 +122,15 @@ def list_countries( def list_countries_eu( - self ) -> CountryList: + self + ) -> CountryList: """ List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. Returns ------- - CountryList API response as a typed Pydantic model + CountryList + API response as a typed Pydantic model Raises ------ @@ -138,13 +148,15 @@ def list_countries_eu( def list_countries_phones( - self ) -> PhoneList: + self + ) -> PhoneList: """ List of all countries phone codes. You can use the locale header to get the data in a supported language. Returns ------- - PhoneList API response as a typed Pydantic model + PhoneList + API response as a typed Pydantic model Raises ------ @@ -162,13 +174,15 @@ def list_countries_phones( def list_currencies( - self ) -> CurrencyList: + self + ) -> CurrencyList: """ List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language. Returns ------- - CurrencyList API response as a typed Pydantic model + CurrencyList + API response as a typed Pydantic model Raises ------ @@ -186,13 +200,15 @@ def list_currencies( def list_languages( - self ) -> LanguageList: + self + ) -> LanguageList: """ List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language. Returns ------- - LanguageList API response as a typed Pydantic model + LanguageList + API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/messaging.py b/appwrite/services/messaging.py index e7b2e87..7a29714 100644 --- a/appwrite/services/messaging.py +++ b/appwrite/services/messaging.py @@ -24,7 +24,8 @@ def list_messages( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> MessageList: + total: Optional[bool] = None + ) -> MessageList: """ Get a list of all messages from the current Appwrite project. @@ -39,7 +40,8 @@ def list_messages( Returns ------- - MessageList API response as a typed Pydantic model + MessageList + API response as a typed Pydantic model Raises ------ @@ -76,7 +78,8 @@ def create_email( attachments: Optional[List[str]] = None, draft: Optional[bool] = None, html: Optional[bool] = None, - scheduled_at: Optional[str] = None ) -> Message: + scheduled_at: Optional[str] = None + ) -> Message: """ Create a new email message. @@ -109,7 +112,8 @@ def create_email( Returns ------- - Message API response as a typed Pydantic model + Message + API response as a typed Pydantic model Raises ------ @@ -170,7 +174,8 @@ def update_email( cc: Optional[List[str]] = None, bcc: Optional[List[str]] = None, scheduled_at: Optional[str] = None, - attachments: Optional[List[str]] = None ) -> Message: + attachments: Optional[List[str]] = None + ) -> Message: """ Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. @@ -204,7 +209,8 @@ def update_email( Returns ------- - Message API response as a typed Pydantic model + Message + API response as a typed Pydantic model Raises ------ @@ -258,7 +264,8 @@ def create_push( scheduled_at: Optional[str] = None, content_available: Optional[bool] = None, critical: Optional[bool] = None, - priority: Optional[MessagePriority] = None ) -> Message: + priority: Optional[MessagePriority] = None + ) -> Message: """ Create a new push notification. @@ -305,7 +312,8 @@ def create_push( Returns ------- - Message API response as a typed Pydantic model + Message + API response as a typed Pydantic model Raises ------ @@ -382,7 +390,8 @@ def update_push( scheduled_at: Optional[str] = None, content_available: Optional[bool] = None, critical: Optional[bool] = None, - priority: Optional[MessagePriority] = None ) -> Message: + priority: Optional[MessagePriority] = None + ) -> Message: """ Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. @@ -430,7 +439,8 @@ def update_push( Returns ------- - Message API response as a typed Pydantic model + Message + API response as a typed Pydantic model Raises ------ @@ -479,7 +489,8 @@ def create_sms( users: Optional[List[str]] = None, targets: Optional[List[str]] = None, draft: Optional[bool] = None, - scheduled_at: Optional[str] = None ) -> Message: + scheduled_at: Optional[str] = None + ) -> Message: """ Create a new SMS message. @@ -502,7 +513,8 @@ def create_sms( Returns ------- - Message API response as a typed Pydantic model + Message + API response as a typed Pydantic model Raises ------ @@ -546,7 +558,8 @@ def update_sms( targets: Optional[List[str]] = None, content: Optional[str] = None, draft: Optional[bool] = None, - scheduled_at: Optional[str] = None ) -> Message: + scheduled_at: Optional[str] = None + ) -> Message: """ Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. @@ -570,7 +583,8 @@ def update_sms( Returns ------- - Message API response as a typed Pydantic model + Message + API response as a typed Pydantic model Raises ------ @@ -601,7 +615,8 @@ def update_sms( def get_message( self, - message_id: str ) -> Message: + message_id: str + ) -> Message: """ Get a message by its unique ID. @@ -613,7 +628,8 @@ def get_message( Returns ------- - Message API response as a typed Pydantic model + Message + API response as a typed Pydantic model Raises ------ @@ -637,7 +653,8 @@ def get_message( def delete( self, - message_id: str ) -> Dict[str, Any]: + message_id: str + ) -> Dict[str, Any]: """ Delete a message. If the message is not a draft or scheduled, but has been sent, this will not recall the message. @@ -676,7 +693,8 @@ def list_message_logs( self, message_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> LogList: + total: Optional[bool] = None + ) -> LogList: """ Get the message activity logs listed by its unique ID. @@ -691,7 +709,8 @@ def list_message_logs( Returns ------- - LogList API response as a typed Pydantic model + LogList + API response as a typed Pydantic model Raises ------ @@ -721,7 +740,8 @@ def list_targets( self, message_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> TargetList: + total: Optional[bool] = None + ) -> TargetList: """ Get a list of the targets associated with a message. @@ -736,7 +756,8 @@ def list_targets( Returns ------- - TargetList API response as a typed Pydantic model + TargetList + API response as a typed Pydantic model Raises ------ @@ -766,7 +787,8 @@ def list_providers( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> ProviderList: + total: Optional[bool] = None + ) -> ProviderList: """ Get a list of all providers from the current Appwrite project. @@ -781,7 +803,8 @@ def list_providers( Returns ------- - ProviderList API response as a typed Pydantic model + ProviderList + API response as a typed Pydantic model Raises ------ @@ -814,7 +837,8 @@ def create_apns_provider( team_id: Optional[str] = None, bundle_id: Optional[str] = None, sandbox: Optional[bool] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new Apple Push Notification service provider. @@ -839,7 +863,8 @@ def create_apns_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -886,7 +911,8 @@ def update_apns_provider( auth_key_id: Optional[str] = None, team_id: Optional[str] = None, bundle_id: Optional[str] = None, - sandbox: Optional[bool] = None ) -> Provider: + sandbox: Optional[bool] = None + ) -> Provider: """ Update a Apple Push Notification service provider by its unique ID. @@ -911,7 +937,8 @@ def update_apns_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -951,7 +978,8 @@ def create_fcm_provider( provider_id: str, name: str, service_account_json: Optional[Dict[str, Any]] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new Firebase Cloud Messaging provider. @@ -968,7 +996,8 @@ def create_fcm_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1002,7 +1031,8 @@ def update_fcm_provider( provider_id: str, name: Optional[str] = None, enabled: Optional[bool] = None, - service_account_json: Optional[Dict[str, Any]] = None ) -> Provider: + service_account_json: Optional[Dict[str, Any]] = None + ) -> Provider: """ Update a Firebase Cloud Messaging provider by its unique ID. @@ -1019,7 +1049,8 @@ def update_fcm_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1057,7 +1088,8 @@ def create_mailgun_provider( from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new Mailgun provider. @@ -1086,7 +1118,8 @@ def create_mailgun_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1138,7 +1171,8 @@ def update_mailgun_provider( from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, - reply_to_email: Optional[str] = None ) -> Provider: + reply_to_email: Optional[str] = None + ) -> Provider: """ Update a Mailgun provider by its unique ID. @@ -1167,7 +1201,8 @@ def update_mailgun_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1213,7 +1248,8 @@ def create_msg91_provider( template_id: Optional[str] = None, sender_id: Optional[str] = None, auth_key: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new MSG91 provider. @@ -1234,7 +1270,8 @@ def create_msg91_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1275,7 +1312,8 @@ def update_msg91_provider( enabled: Optional[bool] = None, template_id: Optional[str] = None, sender_id: Optional[str] = None, - auth_key: Optional[str] = None ) -> Provider: + auth_key: Optional[str] = None + ) -> Provider: """ Update a MSG91 provider by its unique ID. @@ -1296,7 +1334,8 @@ def update_msg91_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1337,7 +1376,8 @@ def create_resend_provider( from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new Resend provider. @@ -1362,7 +1402,8 @@ def create_resend_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1409,7 +1450,8 @@ def update_resend_provider( from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, - reply_to_email: Optional[str] = None ) -> Provider: + reply_to_email: Optional[str] = None + ) -> Provider: """ Update a Resend provider by its unique ID. @@ -1434,7 +1476,8 @@ def update_resend_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1479,7 +1522,8 @@ def create_sendgrid_provider( from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new Sendgrid provider. @@ -1504,7 +1548,8 @@ def create_sendgrid_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1551,7 +1596,8 @@ def update_sendgrid_provider( from_name: Optional[str] = None, from_email: Optional[str] = None, reply_to_name: Optional[str] = None, - reply_to_email: Optional[str] = None ) -> Provider: + reply_to_email: Optional[str] = None + ) -> Provider: """ Update a Sendgrid provider by its unique ID. @@ -1576,7 +1622,8 @@ def update_sendgrid_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1627,7 +1674,8 @@ def create_smtp_provider( from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new SMTP provider. @@ -1664,7 +1712,8 @@ def create_smtp_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1731,7 +1780,8 @@ def update_smtp_provider( from_email: Optional[str] = None, reply_to_name: Optional[str] = None, reply_to_email: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Update a SMTP provider by its unique ID. @@ -1768,7 +1818,8 @@ def update_smtp_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1821,7 +1872,8 @@ def create_telesign_provider( xfrom: Optional[str] = None, customer_id: Optional[str] = None, api_key: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new Telesign provider. @@ -1842,7 +1894,8 @@ def create_telesign_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1883,7 +1936,8 @@ def update_telesign_provider( enabled: Optional[bool] = None, customer_id: Optional[str] = None, api_key: Optional[str] = None, - xfrom: Optional[str] = None ) -> Provider: + xfrom: Optional[str] = None + ) -> Provider: """ Update a Telesign provider by its unique ID. @@ -1904,7 +1958,8 @@ def update_telesign_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -1943,7 +1998,8 @@ def create_textmagic_provider( xfrom: Optional[str] = None, username: Optional[str] = None, api_key: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new Textmagic provider. @@ -1964,7 +2020,8 @@ def create_textmagic_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -2005,7 +2062,8 @@ def update_textmagic_provider( enabled: Optional[bool] = None, username: Optional[str] = None, api_key: Optional[str] = None, - xfrom: Optional[str] = None ) -> Provider: + xfrom: Optional[str] = None + ) -> Provider: """ Update a Textmagic provider by its unique ID. @@ -2026,7 +2084,8 @@ def update_textmagic_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -2065,7 +2124,8 @@ def create_twilio_provider( xfrom: Optional[str] = None, account_sid: Optional[str] = None, auth_token: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new Twilio provider. @@ -2086,7 +2146,8 @@ def create_twilio_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -2127,7 +2188,8 @@ def update_twilio_provider( enabled: Optional[bool] = None, account_sid: Optional[str] = None, auth_token: Optional[str] = None, - xfrom: Optional[str] = None ) -> Provider: + xfrom: Optional[str] = None + ) -> Provider: """ Update a Twilio provider by its unique ID. @@ -2148,7 +2210,8 @@ def update_twilio_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -2187,7 +2250,8 @@ def create_vonage_provider( xfrom: Optional[str] = None, api_key: Optional[str] = None, api_secret: Optional[str] = None, - enabled: Optional[bool] = None ) -> Provider: + enabled: Optional[bool] = None + ) -> Provider: """ Create a new Vonage provider. @@ -2208,7 +2272,8 @@ def create_vonage_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -2249,7 +2314,8 @@ def update_vonage_provider( enabled: Optional[bool] = None, api_key: Optional[str] = None, api_secret: Optional[str] = None, - xfrom: Optional[str] = None ) -> Provider: + xfrom: Optional[str] = None + ) -> Provider: """ Update a Vonage provider by its unique ID. @@ -2270,7 +2336,8 @@ def update_vonage_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -2304,7 +2371,8 @@ def update_vonage_provider( def get_provider( self, - provider_id: str ) -> Provider: + provider_id: str + ) -> Provider: """ Get a provider by its unique ID. @@ -2316,7 +2384,8 @@ def get_provider( Returns ------- - Provider API response as a typed Pydantic model + Provider + API response as a typed Pydantic model Raises ------ @@ -2340,7 +2409,8 @@ def get_provider( def delete_provider( self, - provider_id: str ) -> Dict[str, Any]: + provider_id: str + ) -> Dict[str, Any]: """ Delete a provider by its unique ID. @@ -2379,7 +2449,8 @@ def list_provider_logs( self, provider_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> LogList: + total: Optional[bool] = None + ) -> LogList: """ Get the provider activity logs listed by its unique ID. @@ -2394,7 +2465,8 @@ def list_provider_logs( Returns ------- - LogList API response as a typed Pydantic model + LogList + API response as a typed Pydantic model Raises ------ @@ -2424,7 +2496,8 @@ def list_subscriber_logs( self, subscriber_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> LogList: + total: Optional[bool] = None + ) -> LogList: """ Get the subscriber activity logs listed by its unique ID. @@ -2439,7 +2512,8 @@ def list_subscriber_logs( Returns ------- - LogList API response as a typed Pydantic model + LogList + API response as a typed Pydantic model Raises ------ @@ -2469,7 +2543,8 @@ def list_topics( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> TopicList: + total: Optional[bool] = None + ) -> TopicList: """ Get a list of all topics from the current Appwrite project. @@ -2484,7 +2559,8 @@ def list_topics( Returns ------- - TopicList API response as a typed Pydantic model + TopicList + API response as a typed Pydantic model Raises ------ @@ -2512,7 +2588,8 @@ def create_topic( self, topic_id: str, name: str, - subscribe: Optional[List[str]] = None ) -> Topic: + subscribe: Optional[List[str]] = None + ) -> Topic: """ Create a new topic. @@ -2527,7 +2604,8 @@ def create_topic( Returns ------- - Topic API response as a typed Pydantic model + Topic + API response as a typed Pydantic model Raises ------ @@ -2558,7 +2636,8 @@ def create_topic( def get_topic( self, - topic_id: str ) -> Topic: + topic_id: str + ) -> Topic: """ Get a topic by its unique ID. @@ -2570,7 +2649,8 @@ def get_topic( Returns ------- - Topic API response as a typed Pydantic model + Topic + API response as a typed Pydantic model Raises ------ @@ -2596,7 +2676,8 @@ def update_topic( self, topic_id: str, name: Optional[str] = None, - subscribe: Optional[List[str]] = None ) -> Topic: + subscribe: Optional[List[str]] = None + ) -> Topic: """ Update a topic by its unique ID. @@ -2612,7 +2693,8 @@ def update_topic( Returns ------- - Topic API response as a typed Pydantic model + Topic + API response as a typed Pydantic model Raises ------ @@ -2639,7 +2721,8 @@ def update_topic( def delete_topic( self, - topic_id: str ) -> Dict[str, Any]: + topic_id: str + ) -> Dict[str, Any]: """ Delete a topic by its unique ID. @@ -2678,7 +2761,8 @@ def list_topic_logs( self, topic_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> LogList: + total: Optional[bool] = None + ) -> LogList: """ Get the topic activity logs listed by its unique ID. @@ -2693,7 +2777,8 @@ def list_topic_logs( Returns ------- - LogList API response as a typed Pydantic model + LogList + API response as a typed Pydantic model Raises ------ @@ -2724,7 +2809,8 @@ def list_subscribers( topic_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> SubscriberList: + total: Optional[bool] = None + ) -> SubscriberList: """ Get a list of all subscribers from the current Appwrite project. @@ -2741,7 +2827,8 @@ def list_subscribers( Returns ------- - SubscriberList API response as a typed Pydantic model + SubscriberList + API response as a typed Pydantic model Raises ------ @@ -2773,7 +2860,8 @@ def create_subscriber( self, topic_id: str, subscriber_id: str, - target_id: str ) -> Subscriber: + target_id: str + ) -> Subscriber: """ Create a new subscriber. @@ -2788,7 +2876,8 @@ def create_subscriber( Returns ------- - Subscriber API response as a typed Pydantic model + Subscriber + API response as a typed Pydantic model Raises ------ @@ -2822,7 +2911,8 @@ def create_subscriber( def get_subscriber( self, topic_id: str, - subscriber_id: str ) -> Subscriber: + subscriber_id: str + ) -> Subscriber: """ Get a subscriber by its unique ID. @@ -2836,7 +2926,8 @@ def get_subscriber( Returns ------- - Subscriber API response as a typed Pydantic model + Subscriber + API response as a typed Pydantic model Raises ------ @@ -2865,7 +2956,8 @@ def get_subscriber( def delete_subscriber( self, topic_id: str, - subscriber_id: str ) -> Dict[str, Any]: + subscriber_id: str + ) -> Dict[str, Any]: """ Delete a subscriber by its unique ID. diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index 0dc2019..86ebd6b 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -29,7 +29,8 @@ def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> SiteList: + total: Optional[bool] = None + ) -> SiteList: """ Get a list of all the project's sites. You can use the query params to filter your results. @@ -44,7 +45,8 @@ def list( Returns ------- - SiteList API response as a typed Pydantic model + SiteList + API response as a typed Pydantic model Raises ------ @@ -87,7 +89,8 @@ def create( provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, - specification: Optional[str] = None ) -> Site: + specification: Optional[str] = None + ) -> Site: """ Create a new site. @@ -132,7 +135,8 @@ def create( Returns ------- - Site API response as a typed Pydantic model + Site + API response as a typed Pydantic model Raises ------ @@ -196,13 +200,15 @@ def create( def list_frameworks( - self ) -> FrameworkList: + self + ) -> FrameworkList: """ Get a list of all frameworks that are currently available on the server instance. Returns ------- - FrameworkList API response as a typed Pydantic model + FrameworkList + API response as a typed Pydantic model Raises ------ @@ -220,13 +226,15 @@ def list_frameworks( def list_specifications( - self ) -> SpecificationList: + self + ) -> SpecificationList: """ List allowed site specifications for this instance. Returns ------- - SpecificationList API response as a typed Pydantic model + SpecificationList + API response as a typed Pydantic model Raises ------ @@ -245,7 +253,8 @@ def list_specifications( def get( self, - site_id: str ) -> Site: + site_id: str + ) -> Site: """ Get a site by its unique ID. @@ -256,7 +265,8 @@ def get( Returns ------- - Site API response as a typed Pydantic model + Site + API response as a typed Pydantic model Raises ------ @@ -297,7 +307,8 @@ def update( provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, - specification: Optional[str] = None ) -> Site: + specification: Optional[str] = None + ) -> Site: """ Update site by its unique ID. @@ -342,7 +353,8 @@ def update( Returns ------- - Site API response as a typed Pydantic model + Site + API response as a typed Pydantic model Raises ------ @@ -405,7 +417,8 @@ def update( def delete( self, - site_id: str ) -> Dict[str, Any]: + site_id: str + ) -> Dict[str, Any]: """ Delete a site by its unique ID. @@ -443,7 +456,8 @@ def delete( def update_site_deployment( self, site_id: str, - deployment_id: str ) -> Site: + deployment_id: str + ) -> Site: """ Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. @@ -456,7 +470,8 @@ def update_site_deployment( Returns ------- - Site API response as a typed Pydantic model + Site + API response as a typed Pydantic model Raises ------ @@ -488,7 +503,8 @@ def list_deployments( site_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> DeploymentList: + total: Optional[bool] = None + ) -> DeploymentList: """ Get a list of all the site's code deployments. You can use the query params to filter your results. @@ -505,7 +521,8 @@ def list_deployments( Returns ------- - DeploymentList API response as a typed Pydantic model + DeploymentList + API response as a typed Pydantic model Raises ------ @@ -541,7 +558,8 @@ def create_deployment( build_command: Optional[str] = None, output_directory: Optional[str] = None, activate: Optional[bool] = None, - on_progress = None ) -> Deployment: + on_progress = None + ) -> Deployment: """ Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID. @@ -564,7 +582,8 @@ def create_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -607,7 +626,8 @@ def create_deployment( def create_duplicate_deployment( self, site_id: str, - deployment_id: str ) -> Deployment: + deployment_id: str + ) -> Deployment: """ Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. @@ -620,7 +640,8 @@ def create_duplicate_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -655,7 +676,8 @@ def create_template_deployment( root_directory: str, type: TemplateReferenceType, reference: str, - activate: Optional[bool] = None ) -> Deployment: + activate: Optional[bool] = None + ) -> Deployment: """ Create a deployment based on a template. @@ -680,7 +702,8 @@ def create_template_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -730,7 +753,8 @@ def create_vcs_deployment( site_id: str, type: VCSReferenceType, reference: str, - activate: Optional[bool] = None ) -> Deployment: + activate: Optional[bool] = None + ) -> Deployment: """ Create a deployment when a site is connected to VCS. @@ -749,7 +773,8 @@ def create_vcs_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -785,7 +810,8 @@ def create_vcs_deployment( def get_deployment( self, site_id: str, - deployment_id: str ) -> Deployment: + deployment_id: str + ) -> Deployment: """ Get a site deployment by its unique ID. @@ -798,7 +824,8 @@ def get_deployment( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -827,7 +854,8 @@ def get_deployment( def delete_deployment( self, site_id: str, - deployment_id: str ) -> Dict[str, Any]: + deployment_id: str + ) -> Dict[str, Any]: """ Delete a site deployment by its unique ID. @@ -872,7 +900,8 @@ def get_deployment_download( self, site_id: str, deployment_id: str, - type: Optional[DeploymentDownloadType] = None ) -> bytes: + type: Optional[DeploymentDownloadType] = None + ) -> bytes: """ Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. @@ -919,7 +948,8 @@ def get_deployment_download( def update_deployment_status( self, site_id: str, - deployment_id: str ) -> Deployment: + deployment_id: str + ) -> Deployment: """ Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. @@ -932,7 +962,8 @@ def update_deployment_status( Returns ------- - Deployment API response as a typed Pydantic model + Deployment + API response as a typed Pydantic model Raises ------ @@ -963,7 +994,8 @@ def list_logs( self, site_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> ExecutionList: + total: Optional[bool] = None + ) -> ExecutionList: """ Get a list of all site logs. You can use the query params to filter your results. @@ -978,7 +1010,8 @@ def list_logs( Returns ------- - ExecutionList API response as a typed Pydantic model + ExecutionList + API response as a typed Pydantic model Raises ------ @@ -1007,7 +1040,8 @@ def list_logs( def get_log( self, site_id: str, - log_id: str ) -> Execution: + log_id: str + ) -> Execution: """ Get a site request log by its unique ID. @@ -1020,7 +1054,8 @@ def get_log( Returns ------- - Execution API response as a typed Pydantic model + Execution + API response as a typed Pydantic model Raises ------ @@ -1049,7 +1084,8 @@ def get_log( def delete_log( self, site_id: str, - log_id: str ) -> Dict[str, Any]: + log_id: str + ) -> Dict[str, Any]: """ Delete a site log by its unique ID. @@ -1092,7 +1128,8 @@ def delete_log( def list_variables( self, - site_id: str ) -> VariableList: + site_id: str + ) -> VariableList: """ Get a list of all variables of a specific site. @@ -1103,7 +1140,8 @@ def list_variables( Returns ------- - VariableList API response as a typed Pydantic model + VariableList + API response as a typed Pydantic model Raises ------ @@ -1130,7 +1168,8 @@ def create_variable( site_id: str, key: str, value: str, - secret: Optional[bool] = None ) -> Variable: + secret: Optional[bool] = None + ) -> Variable: """ Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. @@ -1147,7 +1186,8 @@ def create_variable( Returns ------- - Variable API response as a typed Pydantic model + Variable + API response as a typed Pydantic model Raises ------ @@ -1183,7 +1223,8 @@ def create_variable( def get_variable( self, site_id: str, - variable_id: str ) -> Variable: + variable_id: str + ) -> Variable: """ Get a variable by its unique ID. @@ -1196,7 +1237,8 @@ def get_variable( Returns ------- - Variable API response as a typed Pydantic model + Variable + API response as a typed Pydantic model Raises ------ @@ -1228,7 +1270,8 @@ def update_variable( variable_id: str, key: str, value: Optional[str] = None, - secret: Optional[bool] = None ) -> Variable: + secret: Optional[bool] = None + ) -> Variable: """ Update variable by its unique ID. @@ -1247,7 +1290,8 @@ def update_variable( Returns ------- - Variable API response as a typed Pydantic model + Variable + API response as a typed Pydantic model Raises ------ @@ -1283,7 +1327,8 @@ def update_variable( def delete_variable( self, site_id: str, - variable_id: str ) -> Dict[str, Any]: + variable_id: str + ) -> Dict[str, Any]: """ Delete a variable by its unique ID. diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index 72bc61b..3e6d468 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -20,7 +20,8 @@ def list_buckets( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> BucketList: + total: Optional[bool] = None + ) -> BucketList: """ Get a list of all the storage buckets. You can use the query params to filter your results. @@ -35,7 +36,8 @@ def list_buckets( Returns ------- - BucketList API response as a typed Pydantic model + BucketList + API response as a typed Pydantic model Raises ------ @@ -71,7 +73,8 @@ def create_bucket( compression: Optional[Compression] = None, encryption: Optional[bool] = None, antivirus: Optional[bool] = None, - transformations: Optional[bool] = None ) -> Bucket: + transformations: Optional[bool] = None + ) -> Bucket: """ Create a new storage bucket. @@ -102,7 +105,8 @@ def create_bucket( Returns ------- - Bucket API response as a typed Pydantic model + Bucket + API response as a typed Pydantic model Raises ------ @@ -148,7 +152,8 @@ def create_bucket( def get_bucket( self, - bucket_id: str ) -> Bucket: + bucket_id: str + ) -> Bucket: """ Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata. @@ -159,7 +164,8 @@ def get_bucket( Returns ------- - Bucket API response as a typed Pydantic model + Bucket + API response as a typed Pydantic model Raises ------ @@ -193,7 +199,8 @@ def update_bucket( compression: Optional[Compression] = None, encryption: Optional[bool] = None, antivirus: Optional[bool] = None, - transformations: Optional[bool] = None ) -> Bucket: + transformations: Optional[bool] = None + ) -> Bucket: """ Update a storage bucket by its unique ID. @@ -224,7 +231,8 @@ def update_bucket( Returns ------- - Bucket API response as a typed Pydantic model + Bucket + API response as a typed Pydantic model Raises ------ @@ -270,7 +278,8 @@ def update_bucket( def delete_bucket( self, - bucket_id: str ) -> Dict[str, Any]: + bucket_id: str + ) -> Dict[str, Any]: """ Delete a storage bucket by its unique ID. @@ -310,7 +319,8 @@ def list_files( bucket_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> FileList: + total: Optional[bool] = None + ) -> FileList: """ Get a list of all the user files. You can use the query params to filter your results. @@ -327,7 +337,8 @@ def list_files( Returns ------- - FileList API response as a typed Pydantic model + FileList + API response as a typed Pydantic model Raises ------ @@ -361,7 +372,8 @@ def create_file( file_id: str, file: InputFile, permissions: Optional[List[str]] = None, - on_progress = None ) -> File: + on_progress = None + ) -> File: """ Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. @@ -387,7 +399,8 @@ def create_file( Returns ------- - File API response as a typed Pydantic model + File + API response as a typed Pydantic model Raises ------ @@ -429,7 +442,8 @@ def create_file( def get_file( self, bucket_id: str, - file_id: str ) -> File: + file_id: str + ) -> File: """ Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. @@ -442,7 +456,8 @@ def get_file( Returns ------- - File API response as a typed Pydantic model + File + API response as a typed Pydantic model Raises ------ @@ -473,7 +488,8 @@ def update_file( bucket_id: str, file_id: str, name: Optional[str] = None, - permissions: Optional[List[str]] = None ) -> File: + permissions: Optional[List[str]] = None + ) -> File: """ Update a file by its unique ID. Only users with write permissions have access to update this resource. @@ -490,7 +506,8 @@ def update_file( Returns ------- - File API response as a typed Pydantic model + File + API response as a typed Pydantic model Raises ------ @@ -523,7 +540,8 @@ def update_file( def delete_file( self, bucket_id: str, - file_id: str ) -> Dict[str, Any]: + file_id: str + ) -> Dict[str, Any]: """ Delete a file by its unique ID. Only users with write permissions have access to delete this resource. @@ -568,7 +586,8 @@ def get_file_download( self, bucket_id: str, file_id: str, - token: Optional[str] = None ) -> bytes: + token: Optional[str] = None + ) -> bytes: """ Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. @@ -627,7 +646,8 @@ def get_file_preview( rotation: Optional[float] = None, background: Optional[str] = None, output: Optional[ImageFormat] = None, - token: Optional[str] = None ) -> bytes: + token: Optional[str] = None + ) -> bytes: """ Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB. @@ -719,7 +739,8 @@ def get_file_view( self, bucket_id: str, file_id: str, - token: Optional[str] = None ) -> bytes: + token: Optional[str] = None + ) -> bytes: """ Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index e5f2a0f..949c6be 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -46,7 +46,8 @@ def list( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> DatabaseList: + total: Optional[bool] = None + ) -> DatabaseList: """ Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. @@ -61,7 +62,8 @@ def list( Returns ------- - DatabaseList API response as a typed Pydantic model + DatabaseList + API response as a typed Pydantic model Raises ------ @@ -89,7 +91,8 @@ def create( self, database_id: str, name: str, - enabled: Optional[bool] = None ) -> Database: + enabled: Optional[bool] = None + ) -> Database: """ Create a new Database. @@ -105,7 +108,8 @@ def create( Returns ------- - Database API response as a typed Pydantic model + Database + API response as a typed Pydantic model Raises ------ @@ -136,7 +140,8 @@ def create( def list_transactions( self, - queries: Optional[List[str]] = None ) -> TransactionList: + queries: Optional[List[str]] = None + ) -> TransactionList: """ List transactions across all databases. @@ -147,7 +152,8 @@ def list_transactions( Returns ------- - TransactionList API response as a typed Pydantic model + TransactionList + API response as a typed Pydantic model Raises ------ @@ -169,7 +175,8 @@ def list_transactions( def create_transaction( self, - ttl: Optional[float] = None ) -> Transaction: + ttl: Optional[float] = None + ) -> Transaction: """ Create a new transaction. @@ -180,7 +187,8 @@ def create_transaction( Returns ------- - Transaction API response as a typed Pydantic model + Transaction + API response as a typed Pydantic model Raises ------ @@ -203,7 +211,8 @@ def create_transaction( def get_transaction( self, - transaction_id: str ) -> Transaction: + transaction_id: str + ) -> Transaction: """ Get a transaction by its unique ID. @@ -214,7 +223,8 @@ def get_transaction( Returns ------- - Transaction API response as a typed Pydantic model + Transaction + API response as a typed Pydantic model Raises ------ @@ -240,7 +250,8 @@ def update_transaction( self, transaction_id: str, commit: Optional[bool] = None, - rollback: Optional[bool] = None ) -> Transaction: + rollback: Optional[bool] = None + ) -> Transaction: """ Update a transaction, to either commit or roll back its operations. @@ -255,7 +266,8 @@ def update_transaction( Returns ------- - Transaction API response as a typed Pydantic model + Transaction + API response as a typed Pydantic model Raises ------ @@ -284,7 +296,8 @@ def update_transaction( def delete_transaction( self, - transaction_id: str ) -> Dict[str, Any]: + transaction_id: str + ) -> Dict[str, Any]: """ Delete a transaction by its unique ID. @@ -322,7 +335,8 @@ def delete_transaction( def create_operations( self, transaction_id: str, - operations: Optional[List[Dict[str, Any]]] = None ) -> Transaction: + operations: Optional[List[Dict[str, Any]]] = None + ) -> Transaction: """ Create multiple operations in a single transaction. @@ -335,7 +349,8 @@ def create_operations( Returns ------- - Transaction API response as a typed Pydantic model + Transaction + API response as a typed Pydantic model Raises ------ @@ -362,7 +377,8 @@ def create_operations( def get( self, - database_id: str ) -> Database: + database_id: str + ) -> Database: """ Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. @@ -373,7 +389,8 @@ def get( Returns ------- - Database API response as a typed Pydantic model + Database + API response as a typed Pydantic model Raises ------ @@ -399,7 +416,8 @@ def update( self, database_id: str, name: Optional[str] = None, - enabled: Optional[bool] = None ) -> Database: + enabled: Optional[bool] = None + ) -> Database: """ Update a database by its unique ID. @@ -414,7 +432,8 @@ def update( Returns ------- - Database API response as a typed Pydantic model + Database + API response as a typed Pydantic model Raises ------ @@ -443,7 +462,8 @@ def update( def delete( self, - database_id: str ) -> Dict[str, Any]: + database_id: str + ) -> Dict[str, Any]: """ Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. @@ -483,7 +503,8 @@ def list_tables( database_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> TableList: + total: Optional[bool] = None + ) -> TableList: """ Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. @@ -500,7 +521,8 @@ def list_tables( Returns ------- - TableList API response as a typed Pydantic model + TableList + API response as a typed Pydantic model Raises ------ @@ -537,7 +559,8 @@ def create_table( row_security: Optional[bool] = None, enabled: Optional[bool] = None, columns: Optional[List[Dict[str, Any]]] = None, - indexes: Optional[List[Dict[str, Any]]] = None ) -> Table: + indexes: Optional[List[Dict[str, Any]]] = None + ) -> Table: """ Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -562,7 +585,8 @@ def create_table( Returns ------- - Table API response as a typed Pydantic model + Table + API response as a typed Pydantic model Raises ------ @@ -605,7 +629,8 @@ def create_table( def get_table( self, database_id: str, - table_id: str ) -> Table: + table_id: str + ) -> Table: """ Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. @@ -618,7 +643,8 @@ def get_table( Returns ------- - Table API response as a typed Pydantic model + Table + API response as a typed Pydantic model Raises ------ @@ -651,7 +677,8 @@ def update_table( name: Optional[str] = None, permissions: Optional[List[str]] = None, row_security: Optional[bool] = None, - enabled: Optional[bool] = None ) -> Table: + enabled: Optional[bool] = None + ) -> Table: """ Update a table by its unique ID. @@ -672,7 +699,8 @@ def update_table( Returns ------- - Table API response as a typed Pydantic model + Table + API response as a typed Pydantic model Raises ------ @@ -709,7 +737,8 @@ def update_table( def delete_table( self, database_id: str, - table_id: str ) -> Dict[str, Any]: + table_id: str + ) -> Dict[str, Any]: """ Delete a table by its unique ID. Only users with write permissions have access to delete this resource. @@ -755,7 +784,8 @@ def list_columns( database_id: str, table_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> ColumnList: + total: Optional[bool] = None + ) -> ColumnList: """ List columns in the table. @@ -772,7 +802,8 @@ def list_columns( Returns ------- - ColumnList API response as a typed Pydantic model + ColumnList + API response as a typed Pydantic model Raises ------ @@ -809,7 +840,8 @@ def create_boolean_column( key: str, required: bool, default: Optional[bool] = None, - array: Optional[bool] = None ) -> ColumnBoolean: + array: Optional[bool] = None + ) -> ColumnBoolean: """ Create a boolean column. @@ -831,7 +863,8 @@ def create_boolean_column( Returns ------- - ColumnBoolean API response as a typed Pydantic model + ColumnBoolean + API response as a typed Pydantic model Raises ------ @@ -876,7 +909,8 @@ def update_boolean_column( key: str, required: bool, default: Optional[bool], - new_key: Optional[str] = None ) -> ColumnBoolean: + new_key: Optional[str] = None + ) -> ColumnBoolean: """ Update a boolean column. Changing the `default` value will not update already existing rows. @@ -897,7 +931,8 @@ def update_boolean_column( Returns ------- - ColumnBoolean API response as a typed Pydantic model + ColumnBoolean + API response as a typed Pydantic model Raises ------ @@ -941,7 +976,8 @@ def create_datetime_column( key: str, required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> ColumnDatetime: + array: Optional[bool] = None + ) -> ColumnDatetime: """ Create a date time column according to the ISO 8601 standard. @@ -962,7 +998,8 @@ def create_datetime_column( Returns ------- - ColumnDatetime API response as a typed Pydantic model + ColumnDatetime + API response as a typed Pydantic model Raises ------ @@ -1007,7 +1044,8 @@ def update_datetime_column( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> ColumnDatetime: + new_key: Optional[str] = None + ) -> ColumnDatetime: """ Update a date time column. Changing the `default` value will not update already existing rows. @@ -1028,7 +1066,8 @@ def update_datetime_column( Returns ------- - ColumnDatetime API response as a typed Pydantic model + ColumnDatetime + API response as a typed Pydantic model Raises ------ @@ -1072,7 +1111,8 @@ def create_email_column( key: str, required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> ColumnEmail: + array: Optional[bool] = None + ) -> ColumnEmail: """ Create an email column. @@ -1094,7 +1134,8 @@ def create_email_column( Returns ------- - ColumnEmail API response as a typed Pydantic model + ColumnEmail + API response as a typed Pydantic model Raises ------ @@ -1139,7 +1180,8 @@ def update_email_column( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> ColumnEmail: + new_key: Optional[str] = None + ) -> ColumnEmail: """ Update an email column. Changing the `default` value will not update already existing rows. @@ -1161,7 +1203,8 @@ def update_email_column( Returns ------- - ColumnEmail API response as a typed Pydantic model + ColumnEmail + API response as a typed Pydantic model Raises ------ @@ -1206,7 +1249,8 @@ def create_enum_column( elements: List[str], required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> ColumnEnum: + array: Optional[bool] = None + ) -> ColumnEnum: """ Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. @@ -1229,7 +1273,8 @@ def create_enum_column( Returns ------- - ColumnEnum API response as a typed Pydantic model + ColumnEnum + API response as a typed Pydantic model Raises ------ @@ -1279,7 +1324,8 @@ def update_enum_column( elements: List[str], required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> ColumnEnum: + new_key: Optional[str] = None + ) -> ColumnEnum: """ Update an enum column. Changing the `default` value will not update already existing rows. @@ -1303,7 +1349,8 @@ def update_enum_column( Returns ------- - ColumnEnum API response as a typed Pydantic model + ColumnEnum + API response as a typed Pydantic model Raises ------ @@ -1353,7 +1400,8 @@ def create_float_column( min: Optional[float] = None, max: Optional[float] = None, default: Optional[float] = None, - array: Optional[bool] = None ) -> ColumnFloat: + array: Optional[bool] = None + ) -> ColumnFloat: """ Create a float column. Optionally, minimum and maximum values can be provided. @@ -1379,7 +1427,8 @@ def create_float_column( Returns ------- - ColumnFloat API response as a typed Pydantic model + ColumnFloat + API response as a typed Pydantic model Raises ------ @@ -1428,7 +1477,8 @@ def update_float_column( default: Optional[float], min: Optional[float] = None, max: Optional[float] = None, - new_key: Optional[str] = None ) -> ColumnFloat: + new_key: Optional[str] = None + ) -> ColumnFloat: """ Update a float column. Changing the `default` value will not update already existing rows. @@ -1454,7 +1504,8 @@ def update_float_column( Returns ------- - ColumnFloat API response as a typed Pydantic model + ColumnFloat + API response as a typed Pydantic model Raises ------ @@ -1502,7 +1553,8 @@ def create_integer_column( min: Optional[float] = None, max: Optional[float] = None, default: Optional[float] = None, - array: Optional[bool] = None ) -> ColumnInteger: + array: Optional[bool] = None + ) -> ColumnInteger: """ Create an integer column. Optionally, minimum and maximum values can be provided. @@ -1528,7 +1580,8 @@ def create_integer_column( Returns ------- - ColumnInteger API response as a typed Pydantic model + ColumnInteger + API response as a typed Pydantic model Raises ------ @@ -1577,7 +1630,8 @@ def update_integer_column( default: Optional[float], min: Optional[float] = None, max: Optional[float] = None, - new_key: Optional[str] = None ) -> ColumnInteger: + new_key: Optional[str] = None + ) -> ColumnInteger: """ Update an integer column. Changing the `default` value will not update already existing rows. @@ -1603,7 +1657,8 @@ def update_integer_column( Returns ------- - ColumnInteger API response as a typed Pydantic model + ColumnInteger + API response as a typed Pydantic model Raises ------ @@ -1649,7 +1704,8 @@ def create_ip_column( key: str, required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> ColumnIp: + array: Optional[bool] = None + ) -> ColumnIp: """ Create IP address column. @@ -1671,7 +1727,8 @@ def create_ip_column( Returns ------- - ColumnIp API response as a typed Pydantic model + ColumnIp + API response as a typed Pydantic model Raises ------ @@ -1716,7 +1773,8 @@ def update_ip_column( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> ColumnIp: + new_key: Optional[str] = None + ) -> ColumnIp: """ Update an ip column. Changing the `default` value will not update already existing rows. @@ -1738,7 +1796,8 @@ def update_ip_column( Returns ------- - ColumnIp API response as a typed Pydantic model + ColumnIp + API response as a typed Pydantic model Raises ------ @@ -1781,7 +1840,8 @@ def create_line_column( table_id: str, key: str, required: bool, - default: Optional[List[Any]] = None ) -> ColumnLine: + default: Optional[List[Any]] = None + ) -> ColumnLine: """ Create a geometric line column. @@ -1800,7 +1860,8 @@ def create_line_column( Returns ------- - ColumnLine API response as a typed Pydantic model + ColumnLine + API response as a typed Pydantic model Raises ------ @@ -1843,7 +1904,8 @@ def update_line_column( key: str, required: bool, default: Optional[List[Any]] = None, - new_key: Optional[str] = None ) -> ColumnLine: + new_key: Optional[str] = None + ) -> ColumnLine: """ Update a line column. Changing the `default` value will not update already existing rows. @@ -1864,7 +1926,8 @@ def update_line_column( Returns ------- - ColumnLine API response as a typed Pydantic model + ColumnLine + API response as a typed Pydantic model Raises ------ @@ -1909,7 +1972,8 @@ def create_longtext_column( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> ColumnLongtext: + encrypt: Optional[bool] = None + ) -> ColumnLongtext: """ Create a longtext column. @@ -1933,7 +1997,8 @@ def create_longtext_column( Returns ------- - ColumnLongtext API response as a typed Pydantic model + ColumnLongtext + API response as a typed Pydantic model Raises ------ @@ -1980,7 +2045,8 @@ def update_longtext_column( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> ColumnLongtext: + new_key: Optional[str] = None + ) -> ColumnLongtext: """ Update a longtext column. Changing the `default` value will not update already existing rows. @@ -2002,7 +2068,8 @@ def update_longtext_column( Returns ------- - ColumnLongtext API response as a typed Pydantic model + ColumnLongtext + API response as a typed Pydantic model Raises ------ @@ -2047,7 +2114,8 @@ def create_mediumtext_column( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> ColumnMediumtext: + encrypt: Optional[bool] = None + ) -> ColumnMediumtext: """ Create a mediumtext column. @@ -2071,7 +2139,8 @@ def create_mediumtext_column( Returns ------- - ColumnMediumtext API response as a typed Pydantic model + ColumnMediumtext + API response as a typed Pydantic model Raises ------ @@ -2118,7 +2187,8 @@ def update_mediumtext_column( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> ColumnMediumtext: + new_key: Optional[str] = None + ) -> ColumnMediumtext: """ Update a mediumtext column. Changing the `default` value will not update already existing rows. @@ -2140,7 +2210,8 @@ def update_mediumtext_column( Returns ------- - ColumnMediumtext API response as a typed Pydantic model + ColumnMediumtext + API response as a typed Pydantic model Raises ------ @@ -2183,7 +2254,8 @@ def create_point_column( table_id: str, key: str, required: bool, - default: Optional[List[Any]] = None ) -> ColumnPoint: + default: Optional[List[Any]] = None + ) -> ColumnPoint: """ Create a geometric point column. @@ -2202,7 +2274,8 @@ def create_point_column( Returns ------- - ColumnPoint API response as a typed Pydantic model + ColumnPoint + API response as a typed Pydantic model Raises ------ @@ -2245,7 +2318,8 @@ def update_point_column( key: str, required: bool, default: Optional[List[Any]] = None, - new_key: Optional[str] = None ) -> ColumnPoint: + new_key: Optional[str] = None + ) -> ColumnPoint: """ Update a point column. Changing the `default` value will not update already existing rows. @@ -2266,7 +2340,8 @@ def update_point_column( Returns ------- - ColumnPoint API response as a typed Pydantic model + ColumnPoint + API response as a typed Pydantic model Raises ------ @@ -2309,7 +2384,8 @@ def create_polygon_column( table_id: str, key: str, required: bool, - default: Optional[List[Any]] = None ) -> ColumnPolygon: + default: Optional[List[Any]] = None + ) -> ColumnPolygon: """ Create a geometric polygon column. @@ -2328,7 +2404,8 @@ def create_polygon_column( Returns ------- - ColumnPolygon API response as a typed Pydantic model + ColumnPolygon + API response as a typed Pydantic model Raises ------ @@ -2371,7 +2448,8 @@ def update_polygon_column( key: str, required: bool, default: Optional[List[Any]] = None, - new_key: Optional[str] = None ) -> ColumnPolygon: + new_key: Optional[str] = None + ) -> ColumnPolygon: """ Update a polygon column. Changing the `default` value will not update already existing rows. @@ -2392,7 +2470,8 @@ def update_polygon_column( Returns ------- - ColumnPolygon API response as a typed Pydantic model + ColumnPolygon + API response as a typed Pydantic model Raises ------ @@ -2438,7 +2517,8 @@ def create_relationship_column( two_way: Optional[bool] = None, key: Optional[str] = None, two_way_key: Optional[str] = None, - on_delete: Optional[RelationMutate] = None ) -> ColumnRelationship: + on_delete: Optional[RelationMutate] = None + ) -> ColumnRelationship: """ Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). @@ -2464,7 +2544,8 @@ def create_relationship_column( Returns ------- - ColumnRelationship API response as a typed Pydantic model + ColumnRelationship + API response as a typed Pydantic model Raises ------ @@ -2515,7 +2596,8 @@ def create_string_column( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> ColumnString: + encrypt: Optional[bool] = None + ) -> ColumnString: """ Create a string column. @@ -2543,7 +2625,8 @@ def create_string_column( Returns ------- - ColumnString API response as a typed Pydantic model + ColumnString + API response as a typed Pydantic model Raises ------ @@ -2596,7 +2679,8 @@ def update_string_column( required: bool, default: Optional[str], size: Optional[float] = None, - new_key: Optional[str] = None ) -> ColumnString: + new_key: Optional[str] = None + ) -> ColumnString: """ Update a string column. Changing the `default` value will not update already existing rows. @@ -2622,7 +2706,8 @@ def update_string_column( Returns ------- - ColumnString API response as a typed Pydantic model + ColumnString + API response as a typed Pydantic model Raises ------ @@ -2668,7 +2753,8 @@ def create_text_column( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> ColumnText: + encrypt: Optional[bool] = None + ) -> ColumnText: """ Create a text column. @@ -2692,7 +2778,8 @@ def create_text_column( Returns ------- - ColumnText API response as a typed Pydantic model + ColumnText + API response as a typed Pydantic model Raises ------ @@ -2739,7 +2826,8 @@ def update_text_column( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> ColumnText: + new_key: Optional[str] = None + ) -> ColumnText: """ Update a text column. Changing the `default` value will not update already existing rows. @@ -2761,7 +2849,8 @@ def update_text_column( Returns ------- - ColumnText API response as a typed Pydantic model + ColumnText + API response as a typed Pydantic model Raises ------ @@ -2805,7 +2894,8 @@ def create_url_column( key: str, required: bool, default: Optional[str] = None, - array: Optional[bool] = None ) -> ColumnUrl: + array: Optional[bool] = None + ) -> ColumnUrl: """ Create a URL column. @@ -2827,7 +2917,8 @@ def create_url_column( Returns ------- - ColumnUrl API response as a typed Pydantic model + ColumnUrl + API response as a typed Pydantic model Raises ------ @@ -2872,7 +2963,8 @@ def update_url_column( key: str, required: bool, default: Optional[str], - new_key: Optional[str] = None ) -> ColumnUrl: + new_key: Optional[str] = None + ) -> ColumnUrl: """ Update an url column. Changing the `default` value will not update already existing rows. @@ -2894,7 +2986,8 @@ def update_url_column( Returns ------- - ColumnUrl API response as a typed Pydantic model + ColumnUrl + API response as a typed Pydantic model Raises ------ @@ -2940,7 +3033,8 @@ def create_varchar_column( required: bool, default: Optional[str] = None, array: Optional[bool] = None, - encrypt: Optional[bool] = None ) -> ColumnVarchar: + encrypt: Optional[bool] = None + ) -> ColumnVarchar: """ Create a varchar column. @@ -2966,7 +3060,8 @@ def create_varchar_column( Returns ------- - ColumnVarchar API response as a typed Pydantic model + ColumnVarchar + API response as a typed Pydantic model Raises ------ @@ -3018,7 +3113,8 @@ def update_varchar_column( required: bool, default: Optional[str], size: Optional[float] = None, - new_key: Optional[str] = None ) -> ColumnVarchar: + new_key: Optional[str] = None + ) -> ColumnVarchar: """ Update a varchar column. Changing the `default` value will not update already existing rows. @@ -3042,7 +3138,8 @@ def update_varchar_column( Returns ------- - ColumnVarchar API response as a typed Pydantic model + ColumnVarchar + API response as a typed Pydantic model Raises ------ @@ -3084,7 +3181,8 @@ def get_column( self, database_id: str, table_id: str, - key: str ) -> Union[ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString]: + key: str + ) -> Union[ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString]: """ Get column by ID. @@ -3134,7 +3232,8 @@ def delete_column( self, database_id: str, table_id: str, - key: str ) -> Dict[str, Any]: + key: str + ) -> Dict[str, Any]: """ Deletes a column. @@ -3187,7 +3286,8 @@ def update_relationship_column( table_id: str, key: str, on_delete: Optional[RelationMutate] = None, - new_key: Optional[str] = None ) -> ColumnRelationship: + new_key: Optional[str] = None + ) -> ColumnRelationship: """ Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). @@ -3207,7 +3307,8 @@ def update_relationship_column( Returns ------- - ColumnRelationship API response as a typed Pydantic model + ColumnRelationship + API response as a typed Pydantic model Raises ------ @@ -3245,7 +3346,8 @@ def list_indexes( database_id: str, table_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> ColumnIndexList: + total: Optional[bool] = None + ) -> ColumnIndexList: """ List indexes on the table. @@ -3262,7 +3364,8 @@ def list_indexes( Returns ------- - ColumnIndexList API response as a typed Pydantic model + ColumnIndexList + API response as a typed Pydantic model Raises ------ @@ -3300,7 +3403,8 @@ def create_index( type: IndexType, columns: List[str], orders: Optional[List[OrderBy]] = None, - lengths: Optional[List[float]] = None ) -> ColumnIndex: + lengths: Optional[List[float]] = None + ) -> ColumnIndex: """ Creates an index on the columns listed. Your index should include all the columns you will query in a single request. Type can be `key`, `fulltext`, or `unique`. @@ -3324,7 +3428,8 @@ def create_index( Returns ------- - ColumnIndex API response as a typed Pydantic model + ColumnIndex + API response as a typed Pydantic model Raises ------ @@ -3371,7 +3476,8 @@ def get_index( self, database_id: str, table_id: str, - key: str ) -> ColumnIndex: + key: str + ) -> ColumnIndex: """ Get index by ID. @@ -3386,7 +3492,8 @@ def get_index( Returns ------- - ColumnIndex API response as a typed Pydantic model + ColumnIndex + API response as a typed Pydantic model Raises ------ @@ -3420,7 +3527,8 @@ def delete_index( self, database_id: str, table_id: str, - key: str ) -> Dict[str, Any]: + key: str + ) -> Dict[str, Any]: """ Delete an index. @@ -3475,7 +3583,8 @@ def list_rows( transaction_id: Optional[str] = None, total: Optional[bool] = None, ttl: Optional[float] = None, - model_type: Type[T] = dict ) -> RowList[T]: + model_type: Type[T] = dict + ) -> RowList[T]: """ Get a list of all the user's rows in a given table. You can use the query params to filter your results. @@ -3499,7 +3608,8 @@ def list_rows( Returns ------- - RowList[T] API response as a typed Pydantic model + RowList[T] + API response as a typed Pydantic model Raises ------ @@ -3541,7 +3651,8 @@ def create_row( data: Dict[str, Any], permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Row[T]: + model_type: Type[T] = dict + ) -> Row[T]: """ Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3565,7 +3676,8 @@ def create_row( Returns ------- - Row[T] API response as a typed Pydantic model + Row[T] + API response as a typed Pydantic model Raises ------ @@ -3608,7 +3720,8 @@ def create_rows( table_id: str, rows: List[Dict[str, Any]], transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> RowList[T]: + model_type: Type[T] = dict + ) -> RowList[T]: """ Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3628,7 +3741,8 @@ def create_rows( Returns ------- - RowList[T] API response as a typed Pydantic model + RowList[T] + API response as a typed Pydantic model Raises ------ @@ -3666,7 +3780,8 @@ def upsert_rows( table_id: str, rows: List[Dict[str, Any]], transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> RowList[T]: + model_type: Type[T] = dict + ) -> RowList[T]: """ Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3687,7 +3802,8 @@ def upsert_rows( Returns ------- - RowList[T] API response as a typed Pydantic model + RowList[T] + API response as a typed Pydantic model Raises ------ @@ -3726,7 +3842,8 @@ def update_rows( data: Optional[Dict[str, Any]] = None, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> RowList[T]: + model_type: Type[T] = dict + ) -> RowList[T]: """ Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. @@ -3748,7 +3865,8 @@ def update_rows( Returns ------- - RowList[T] API response as a typed Pydantic model + RowList[T] + API response as a typed Pydantic model Raises ------ @@ -3786,7 +3904,8 @@ def delete_rows( table_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> RowList[T]: + model_type: Type[T] = dict + ) -> RowList[T]: """ Bulk delete rows using queries, if no queries are passed then all rows are deleted. @@ -3806,7 +3925,8 @@ def delete_rows( Returns ------- - RowList[T] API response as a typed Pydantic model + RowList[T] + API response as a typed Pydantic model Raises ------ @@ -3843,7 +3963,8 @@ def get_row( row_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Row[T]: + model_type: Type[T] = dict + ) -> Row[T]: """ Get a row by its unique ID. This endpoint response returns a JSON object with the row data. @@ -3865,7 +3986,8 @@ def get_row( Returns ------- - Row[T] API response as a typed Pydantic model + Row[T] + API response as a typed Pydantic model Raises ------ @@ -3907,7 +4029,8 @@ def upsert_row( data: Optional[Dict[str, Any]] = None, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Row[T]: + model_type: Type[T] = dict + ) -> Row[T]: """ Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -3931,7 +4054,8 @@ def upsert_row( Returns ------- - Row[T] API response as a typed Pydantic model + Row[T] + API response as a typed Pydantic model Raises ------ @@ -3974,7 +4098,8 @@ def update_row( data: Optional[Dict[str, Any]] = None, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Row[T]: + model_type: Type[T] = dict + ) -> Row[T]: """ Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -3998,7 +4123,8 @@ def update_row( Returns ------- - Row[T] API response as a typed Pydantic model + Row[T] + API response as a typed Pydantic model Raises ------ @@ -4038,7 +4164,8 @@ def delete_row( database_id: str, table_id: str, row_id: str, - transaction_id: Optional[str] = None ) -> Dict[str, Any]: + transaction_id: Optional[str] = None + ) -> Dict[str, Any]: """ Delete a row by its unique ID. @@ -4097,7 +4224,8 @@ def decrement_row_column( value: Optional[float] = None, min: Optional[float] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Row[T]: + model_type: Type[T] = dict + ) -> Row[T]: """ Decrement a specific column of a row by a given value. @@ -4123,7 +4251,8 @@ def decrement_row_column( Returns ------- - Row[T] API response as a typed Pydantic model + Row[T] + API response as a typed Pydantic model Raises ------ @@ -4171,7 +4300,8 @@ def increment_row_column( value: Optional[float] = None, max: Optional[float] = None, transaction_id: Optional[str] = None, - model_type: Type[T] = dict ) -> Row[T]: + model_type: Type[T] = dict + ) -> Row[T]: """ Increment a specific column of a row by a given value. @@ -4197,7 +4327,8 @@ def increment_row_column( Returns ------- - Row[T] API response as a typed Pydantic model + Row[T] + API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 3353e8a..6557f87 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -20,7 +20,8 @@ def list( queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None, - model_type: Type[T] = dict ) -> TeamList[T]: + model_type: Type[T] = dict + ) -> TeamList[T]: """ Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. @@ -38,7 +39,8 @@ def list( Returns ------- - TeamList[T] API response as a typed Pydantic model + TeamList[T] + API response as a typed Pydantic model Raises ------ @@ -67,7 +69,8 @@ def create( team_id: str, name: str, roles: Optional[List[str]] = None, - model_type: Type[T] = dict ) -> Team[T]: + model_type: Type[T] = dict + ) -> Team[T]: """ Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. @@ -85,7 +88,8 @@ def create( Returns ------- - Team[T] API response as a typed Pydantic model + Team[T] + API response as a typed Pydantic model Raises ------ @@ -117,7 +121,8 @@ def create( def get( self, team_id: str, - model_type: Type[T] = dict ) -> Team[T]: + model_type: Type[T] = dict + ) -> Team[T]: """ Get a team by its ID. All team members have read access for this resource. @@ -131,7 +136,8 @@ def get( Returns ------- - Team[T] API response as a typed Pydantic model + Team[T] + API response as a typed Pydantic model Raises ------ @@ -157,7 +163,8 @@ def update_name( self, team_id: str, name: str, - model_type: Type[T] = dict ) -> Team[T]: + model_type: Type[T] = dict + ) -> Team[T]: """ Update the team's name by its unique ID. @@ -173,7 +180,8 @@ def update_name( Returns ------- - Team[T] API response as a typed Pydantic model + Team[T] + API response as a typed Pydantic model Raises ------ @@ -202,7 +210,8 @@ def update_name( def delete( self, - team_id: str ) -> Dict[str, Any]: + team_id: str + ) -> Dict[str, Any]: """ Delete a team using its ID. Only team members with the owner role can delete the team. @@ -242,7 +251,8 @@ def list_memberships( team_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> MembershipList: + total: Optional[bool] = None + ) -> MembershipList: """ Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. @@ -259,7 +269,8 @@ def list_memberships( Returns ------- - MembershipList API response as a typed Pydantic model + MembershipList + API response as a typed Pydantic model Raises ------ @@ -295,7 +306,8 @@ def create_membership( user_id: Optional[str] = None, phone: Optional[str] = None, url: Optional[str] = None, - name: Optional[str] = None ) -> Membership: + name: Optional[str] = None + ) -> Membership: """ Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. @@ -325,7 +337,8 @@ def create_membership( Returns ------- - Membership API response as a typed Pydantic model + Membership + API response as a typed Pydantic model Raises ------ @@ -365,7 +378,8 @@ def create_membership( def get_membership( self, team_id: str, - membership_id: str ) -> Membership: + membership_id: str + ) -> Membership: """ Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console. @@ -378,7 +392,8 @@ def get_membership( Returns ------- - Membership API response as a typed Pydantic model + Membership + API response as a typed Pydantic model Raises ------ @@ -408,7 +423,8 @@ def update_membership( self, team_id: str, membership_id: str, - roles: List[str] ) -> Membership: + roles: List[str] + ) -> Membership: """ Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). @@ -424,7 +440,8 @@ def update_membership( Returns ------- - Membership API response as a typed Pydantic model + Membership + API response as a typed Pydantic model Raises ------ @@ -458,7 +475,8 @@ def update_membership( def delete_membership( self, team_id: str, - membership_id: str ) -> Dict[str, Any]: + membership_id: str + ) -> Dict[str, Any]: """ This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted. @@ -504,7 +522,8 @@ def update_membership_status( team_id: str, membership_id: str, user_id: str, - secret: str ) -> Membership: + secret: str + ) -> Membership: """ Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. @@ -524,7 +543,8 @@ def update_membership_status( Returns ------- - Membership API response as a typed Pydantic model + Membership + API response as a typed Pydantic model Raises ------ @@ -562,7 +582,8 @@ def update_membership_status( def get_prefs( self, team_id: str, - model_type: Type[T] = dict ) -> Preferences[T]: + model_type: Type[T] = dict + ) -> Preferences[T]: """ Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). @@ -576,7 +597,8 @@ def get_prefs( Returns ------- - Preferences[T] API response as a typed Pydantic model + Preferences[T] + API response as a typed Pydantic model Raises ------ @@ -602,7 +624,8 @@ def update_prefs( self, team_id: str, prefs: Dict[str, Any], - model_type: Type[T] = dict ) -> Preferences[T]: + model_type: Type[T] = dict + ) -> Preferences[T]: """ Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. @@ -618,7 +641,8 @@ def update_prefs( Returns ------- - Preferences[T] API response as a typed Pydantic model + Preferences[T] + API response as a typed Pydantic model Raises ------ diff --git a/appwrite/services/tokens.py b/appwrite/services/tokens.py index 4338c2b..215e9cc 100644 --- a/appwrite/services/tokens.py +++ b/appwrite/services/tokens.py @@ -15,7 +15,8 @@ def list( bucket_id: str, file_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> ResourceTokenList: + total: Optional[bool] = None + ) -> ResourceTokenList: """ List all the tokens created for a specific file or bucket. You can use the query params to filter your results. @@ -32,7 +33,8 @@ def list( Returns ------- - ResourceTokenList API response as a typed Pydantic model + ResourceTokenList + API response as a typed Pydantic model Raises ------ @@ -66,7 +68,8 @@ def create_file_token( self, bucket_id: str, file_id: str, - expire: Optional[str] = None ) -> ResourceToken: + expire: Optional[str] = None + ) -> ResourceToken: """ Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. @@ -81,7 +84,8 @@ def create_file_token( Returns ------- - ResourceToken API response as a typed Pydantic model + ResourceToken + API response as a typed Pydantic model Raises ------ @@ -111,7 +115,8 @@ def create_file_token( def get( self, - token_id: str ) -> ResourceToken: + token_id: str + ) -> ResourceToken: """ Get a token by its unique ID. @@ -122,7 +127,8 @@ def get( Returns ------- - ResourceToken API response as a typed Pydantic model + ResourceToken + API response as a typed Pydantic model Raises ------ @@ -147,7 +153,8 @@ def get( def update( self, token_id: str, - expire: Optional[str] = None ) -> ResourceToken: + expire: Optional[str] = None + ) -> ResourceToken: """ Update a token by its unique ID. Use this endpoint to update a token's expiry date. @@ -160,7 +167,8 @@ def update( Returns ------- - ResourceToken API response as a typed Pydantic model + ResourceToken + API response as a typed Pydantic model Raises ------ @@ -186,7 +194,8 @@ def update( def delete( self, - token_id: str ) -> Dict[str, Any]: + token_id: str + ) -> Dict[str, Any]: """ Delete a token by its unique ID. diff --git a/appwrite/services/users.py b/appwrite/services/users.py index db3e906..605af8c 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -32,7 +32,8 @@ def list( queries: Optional[List[str]] = None, search: Optional[str] = None, total: Optional[bool] = None, - model_type: Type[T] = dict ) -> UserList[T]: + model_type: Type[T] = dict + ) -> UserList[T]: """ Get a list of all the project's users. You can use the query params to filter your results. @@ -50,7 +51,8 @@ def list( Returns ------- - UserList[T] API response as a typed Pydantic model + UserList[T] + API response as a typed Pydantic model Raises ------ @@ -81,7 +83,8 @@ def create( phone: Optional[str] = None, password: Optional[str] = None, name: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Create a new user. @@ -103,7 +106,8 @@ def create( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -138,7 +142,8 @@ def create_argon2_user( email: str, password: str, name: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -158,7 +163,8 @@ def create_argon2_user( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -197,7 +203,8 @@ def create_bcrypt_user( email: str, password: str, name: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -217,7 +224,8 @@ def create_bcrypt_user( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -254,7 +262,8 @@ def list_identities( self, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> IdentityList: + total: Optional[bool] = None + ) -> IdentityList: """ Get identities for all users. @@ -269,7 +278,8 @@ def list_identities( Returns ------- - IdentityList API response as a typed Pydantic model + IdentityList + API response as a typed Pydantic model Raises ------ @@ -295,7 +305,8 @@ def list_identities( def delete_identity( self, - identity_id: str ) -> Dict[str, Any]: + identity_id: str + ) -> Dict[str, Any]: """ Delete an identity by its unique ID. @@ -336,7 +347,8 @@ def create_md5_user( email: str, password: str, name: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -356,7 +368,8 @@ def create_md5_user( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -395,7 +408,8 @@ def create_ph_pass_user( email: str, password: str, name: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -415,7 +429,8 @@ def create_ph_pass_user( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -459,7 +474,8 @@ def create_scrypt_user( password_parallel: float, password_length: float, name: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -489,7 +505,8 @@ def create_scrypt_user( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -551,7 +568,8 @@ def create_scrypt_modified_user( password_salt_separator: str, password_signer_key: str, name: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -577,7 +595,8 @@ def create_scrypt_modified_user( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -629,7 +648,8 @@ def create_sha_user( password: str, password_version: Optional[PasswordHash] = None, name: Optional[str] = None, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. @@ -651,7 +671,8 @@ def create_sha_user( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -689,7 +710,8 @@ def create_sha_user( def get( self, user_id: str, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Get a user by its unique ID. @@ -703,7 +725,8 @@ def get( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -727,7 +750,8 @@ def get( def delete( self, - user_id: str ) -> Dict[str, Any]: + user_id: str + ) -> Dict[str, Any]: """ Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. @@ -766,7 +790,8 @@ def update_email( self, user_id: str, email: str, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update the user email by its unique ID. @@ -782,7 +807,8 @@ def update_email( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -813,7 +839,8 @@ def create_jwt( self, user_id: str, session_id: Optional[str] = None, - duration: Optional[float] = None ) -> Jwt: + duration: Optional[float] = None + ) -> Jwt: """ Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. @@ -828,7 +855,8 @@ def create_jwt( Returns ------- - Jwt API response as a typed Pydantic model + Jwt + API response as a typed Pydantic model Raises ------ @@ -859,7 +887,8 @@ def update_labels( self, user_id: str, labels: List[str], - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update the user labels by its unique ID. @@ -877,7 +906,8 @@ def update_labels( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -908,7 +938,8 @@ def list_logs( self, user_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> LogList: + total: Optional[bool] = None + ) -> LogList: """ Get the user activity logs list by its unique ID. @@ -923,7 +954,8 @@ def list_logs( Returns ------- - LogList API response as a typed Pydantic model + LogList + API response as a typed Pydantic model Raises ------ @@ -954,7 +986,8 @@ def list_memberships( user_id: str, queries: Optional[List[str]] = None, search: Optional[str] = None, - total: Optional[bool] = None ) -> MembershipList: + total: Optional[bool] = None + ) -> MembershipList: """ Get the user membership list by its unique ID. @@ -971,7 +1004,8 @@ def list_memberships( Returns ------- - MembershipList API response as a typed Pydantic model + MembershipList + API response as a typed Pydantic model Raises ------ @@ -1003,7 +1037,8 @@ def update_mfa( self, user_id: str, mfa: bool, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Enable or disable MFA on a user account. @@ -1019,7 +1054,8 @@ def update_mfa( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -1049,7 +1085,8 @@ def update_mfa( def delete_mfa_authenticator( self, user_id: str, - type: AuthenticatorType ) -> Dict[str, Any]: + type: AuthenticatorType + ) -> Dict[str, Any]: """ Delete an authenticator app. @@ -1092,7 +1129,8 @@ def delete_mfa_authenticator( def list_mfa_factors( self, - user_id: str ) -> MfaFactors: + user_id: str + ) -> MfaFactors: """ List the factors available on the account to be used as a MFA challange. @@ -1103,7 +1141,8 @@ def list_mfa_factors( Returns ------- - MfaFactors API response as a typed Pydantic model + MfaFactors + API response as a typed Pydantic model Raises ------ @@ -1127,7 +1166,8 @@ def list_mfa_factors( def get_mfa_recovery_codes( self, - user_id: str ) -> MfaRecoveryCodes: + user_id: str + ) -> MfaRecoveryCodes: """ Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. @@ -1138,7 +1178,8 @@ def get_mfa_recovery_codes( Returns ------- - MfaRecoveryCodes API response as a typed Pydantic model + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -1162,7 +1203,8 @@ def get_mfa_recovery_codes( def update_mfa_recovery_codes( self, - user_id: str ) -> MfaRecoveryCodes: + user_id: str + ) -> MfaRecoveryCodes: """ Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. @@ -1173,7 +1215,8 @@ def update_mfa_recovery_codes( Returns ------- - MfaRecoveryCodes API response as a typed Pydantic model + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -1198,7 +1241,8 @@ def update_mfa_recovery_codes( def create_mfa_recovery_codes( self, - user_id: str ) -> MfaRecoveryCodes: + user_id: str + ) -> MfaRecoveryCodes: """ Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. @@ -1209,7 +1253,8 @@ def create_mfa_recovery_codes( Returns ------- - MfaRecoveryCodes API response as a typed Pydantic model + MfaRecoveryCodes + API response as a typed Pydantic model Raises ------ @@ -1236,7 +1281,8 @@ def update_name( self, user_id: str, name: str, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update the user name by its unique ID. @@ -1252,7 +1298,8 @@ def update_name( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -1283,7 +1330,8 @@ def update_password( self, user_id: str, password: str, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update the user password by its unique ID. @@ -1299,7 +1347,8 @@ def update_password( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -1330,7 +1379,8 @@ def update_phone( self, user_id: str, number: str, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update the user phone by its unique ID. @@ -1346,7 +1396,8 @@ def update_phone( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -1376,7 +1427,8 @@ def update_phone( def get_prefs( self, user_id: str, - model_type: Type[T] = dict ) -> Preferences[T]: + model_type: Type[T] = dict + ) -> Preferences[T]: """ Get the user preferences by its unique ID. @@ -1390,7 +1442,8 @@ def get_prefs( Returns ------- - Preferences[T] API response as a typed Pydantic model + Preferences[T] + API response as a typed Pydantic model Raises ------ @@ -1416,7 +1469,8 @@ def update_prefs( self, user_id: str, prefs: Dict[str, Any], - model_type: Type[T] = dict ) -> Preferences[T]: + model_type: Type[T] = dict + ) -> Preferences[T]: """ Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. @@ -1432,7 +1486,8 @@ def update_prefs( Returns ------- - Preferences[T] API response as a typed Pydantic model + Preferences[T] + API response as a typed Pydantic model Raises ------ @@ -1462,7 +1517,8 @@ def update_prefs( def list_sessions( self, user_id: str, - total: Optional[bool] = None ) -> SessionList: + total: Optional[bool] = None + ) -> SessionList: """ Get the user sessions list by its unique ID. @@ -1475,7 +1531,8 @@ def list_sessions( Returns ------- - SessionList API response as a typed Pydantic model + SessionList + API response as a typed Pydantic model Raises ------ @@ -1501,7 +1558,8 @@ def list_sessions( def create_session( self, - user_id: str ) -> Session: + user_id: str + ) -> Session: """ Creates a session for a user. Returns an immediately usable session object. @@ -1514,7 +1572,8 @@ def create_session( Returns ------- - Session API response as a typed Pydantic model + Session + API response as a typed Pydantic model Raises ------ @@ -1539,7 +1598,8 @@ def create_session( def delete_sessions( self, - user_id: str ) -> Dict[str, Any]: + user_id: str + ) -> Dict[str, Any]: """ Delete all user's sessions by using the user's unique ID. @@ -1577,7 +1637,8 @@ def delete_sessions( def delete_session( self, user_id: str, - session_id: str ) -> Dict[str, Any]: + session_id: str + ) -> Dict[str, Any]: """ Delete a user sessions by its unique ID. @@ -1622,7 +1683,8 @@ def update_status( self, user_id: str, status: bool, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. @@ -1638,7 +1700,8 @@ def update_status( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -1669,7 +1732,8 @@ def list_targets( self, user_id: str, queries: Optional[List[str]] = None, - total: Optional[bool] = None ) -> TargetList: + total: Optional[bool] = None + ) -> TargetList: """ List the messaging targets that are associated with a user. @@ -1684,7 +1748,8 @@ def list_targets( Returns ------- - TargetList API response as a typed Pydantic model + TargetList + API response as a typed Pydantic model Raises ------ @@ -1717,7 +1782,8 @@ def create_target( provider_type: MessagingProviderType, identifier: str, provider_id: Optional[str] = None, - name: Optional[str] = None ) -> Target: + name: Optional[str] = None + ) -> Target: """ Create a messaging target. @@ -1738,7 +1804,8 @@ def create_target( Returns ------- - Target API response as a typed Pydantic model + Target + API response as a typed Pydantic model Raises ------ @@ -1780,7 +1847,8 @@ def create_target( def get_target( self, user_id: str, - target_id: str ) -> Target: + target_id: str + ) -> Target: """ Get a user's push notification target by ID. @@ -1793,7 +1861,8 @@ def get_target( Returns ------- - Target API response as a typed Pydantic model + Target + API response as a typed Pydantic model Raises ------ @@ -1825,7 +1894,8 @@ def update_target( target_id: str, identifier: Optional[str] = None, provider_id: Optional[str] = None, - name: Optional[str] = None ) -> Target: + name: Optional[str] = None + ) -> Target: """ Update a messaging target. @@ -1844,7 +1914,8 @@ def update_target( Returns ------- - Target API response as a typed Pydantic model + Target + API response as a typed Pydantic model Raises ------ @@ -1880,7 +1951,8 @@ def update_target( def delete_target( self, user_id: str, - target_id: str ) -> Dict[str, Any]: + target_id: str + ) -> Dict[str, Any]: """ Delete a messaging target. @@ -1925,7 +1997,8 @@ def create_token( self, user_id: str, length: Optional[float] = None, - expire: Optional[float] = None ) -> Token: + expire: Optional[float] = None + ) -> Token: """ Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. @@ -1941,7 +2014,8 @@ def create_token( Returns ------- - Token API response as a typed Pydantic model + Token + API response as a typed Pydantic model Raises ------ @@ -1972,7 +2046,8 @@ def update_email_verification( self, user_id: str, email_verification: bool, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update the user email verification status by its unique ID. @@ -1988,7 +2063,8 @@ def update_email_verification( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------ @@ -2019,7 +2095,8 @@ def update_phone_verification( self, user_id: str, phone_verification: bool, - model_type: Type[T] = dict ) -> User[T]: + model_type: Type[T] = dict + ) -> User[T]: """ Update the user phone verification status by its unique ID. @@ -2035,7 +2112,8 @@ def update_phone_verification( Returns ------- - User[T] API response as a typed Pydantic model + User[T] + API response as a typed Pydantic model Raises ------