diff --git a/CHANGELOG.md b/CHANGELOG.md index 9766bdd6..fae7025a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 18.1.0 + +* Added: Introduced `bigint` create/update APIs for legacy Databases attributes +* Added: Introduced `bigint` create/update APIs for `TablesDB` columns +* Updated: Extended key-list query filters with `key`, `resourceType`, `resourceId`, and `secret` + ## 18.0.0 * [BREAKING] Renamed Webhook model fields: `security` → `tls`, `httpUser` → `authUsername`, `httpPass` → `authPassword`, `signatureKey` → `secret` diff --git a/README.md b/README.md index f615f2f7..c0446358 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Python SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.9.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.4-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/releases).** +**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/releases).** Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Python SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/appwrite/client.py b/appwrite/client.py index 52ec0d12..cebc8d0a 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -15,12 +15,12 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : f'AppwritePythonSDK/18.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/18.1.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': '18.0.0', - 'X-Appwrite-Response-Format' : '1.9.1', + 'x-sdk-version': '18.1.0', + 'X-Appwrite-Response-Format' : '1.9.4', } def set_self_signed(self, status=True): @@ -75,6 +75,18 @@ def set_forwarded_user_agent(self, value): self._global_headers['x-forwarded-user-agent'] = value return self + def set_dev_key(self, value): + """Your secret dev API key""" + + self._global_headers['x-appwrite-dev-key'] = value + return self + + def set_cookie(self, value): + """The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes.""" + + self._global_headers['cookie'] = value + return self + def set_impersonate_user_id(self, value): """Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.""" diff --git a/appwrite/encoders/value_class_encoder.py b/appwrite/encoders/value_class_encoder.py index 3be7fa6b..028b0786 100644 --- a/appwrite/encoders/value_class_encoder.py +++ b/appwrite/encoders/value_class_encoder.py @@ -24,8 +24,16 @@ from ..enums.name import Name from ..enums.message_priority import MessagePriority from ..enums.smtp_encryption import SmtpEncryption +from ..enums.method_id import MethodId +from ..enums.provider_id import ProviderId +from ..enums.policy_id import PolicyId from ..enums.protocol_id import ProtocolId from ..enums.service_id import ServiceId +from ..enums.secure import Secure +from ..enums.email_template_type import EmailTemplateType +from ..enums.email_template_locale import EmailTemplateLocale +from ..enums.status_code import StatusCode +from ..enums.proxy_resource_type import ProxyResourceType from ..enums.framework import Framework from ..enums.build_runtime import BuildRuntime from ..enums.adapter import Adapter @@ -44,6 +52,8 @@ from ..enums.platform_type import PlatformType from ..enums.health_antivirus_status import HealthAntivirusStatus from ..enums.health_check_status import HealthCheckStatus +from ..enums.proxy_rule_deployment_resource_type import ProxyRuleDeploymentResourceType +from ..enums.proxy_rule_status import ProxyRuleStatus from ..enums.message_status import MessageStatus class ValueClassEncoder(json.JSONEncoder): @@ -123,12 +133,36 @@ def default(self, o): if isinstance(o, SmtpEncryption): return o.value + if isinstance(o, MethodId): + return o.value + + if isinstance(o, ProviderId): + return o.value + + if isinstance(o, PolicyId): + return o.value + if isinstance(o, ProtocolId): return o.value if isinstance(o, ServiceId): return o.value + if isinstance(o, Secure): + return o.value + + if isinstance(o, EmailTemplateType): + return o.value + + if isinstance(o, EmailTemplateLocale): + return o.value + + if isinstance(o, StatusCode): + return o.value + + if isinstance(o, ProxyResourceType): + return o.value + if isinstance(o, Framework): return o.value @@ -183,6 +217,12 @@ def default(self, o): if isinstance(o, HealthCheckStatus): return o.value + if isinstance(o, ProxyRuleDeploymentResourceType): + return o.value + + if isinstance(o, ProxyRuleStatus): + return o.value + if isinstance(o, MessageStatus): return o.value diff --git a/appwrite/enums/build_runtime.py b/appwrite/enums/build_runtime.py index eaa3216b..427d6c28 100644 --- a/appwrite/enums/build_runtime.py +++ b/appwrite/enums/build_runtime.py @@ -81,6 +81,7 @@ class BuildRuntime(Enum): GO_1_24 = "go-1.24" GO_1_25 = "go-1.25" GO_1_26 = "go-1.26" + RUST_1_83 = "rust-1.83" STATIC_1 = "static-1" FLUTTER_3_24 = "flutter-3.24" FLUTTER_3_27 = "flutter-3.27" diff --git a/appwrite/enums/email_template_locale.py b/appwrite/enums/email_template_locale.py new file mode 100644 index 00000000..668169cf --- /dev/null +++ b/appwrite/enums/email_template_locale.py @@ -0,0 +1,134 @@ +from enum import Enum + +class EmailTemplateLocale(Enum): + AF = "af" + AR_AE = "ar-ae" + AR_BH = "ar-bh" + AR_DZ = "ar-dz" + AR_EG = "ar-eg" + AR_IQ = "ar-iq" + AR_JO = "ar-jo" + AR_KW = "ar-kw" + AR_LB = "ar-lb" + AR_LY = "ar-ly" + AR_MA = "ar-ma" + AR_OM = "ar-om" + AR_QA = "ar-qa" + AR_SA = "ar-sa" + AR_SY = "ar-sy" + AR_TN = "ar-tn" + AR_YE = "ar-ye" + AS = "as" + AZ = "az" + BE = "be" + BG = "bg" + BH = "bh" + BN = "bn" + BS = "bs" + CA = "ca" + CS = "cs" + CY = "cy" + DA = "da" + DE = "de" + DE_AT = "de-at" + DE_CH = "de-ch" + DE_LI = "de-li" + DE_LU = "de-lu" + EL = "el" + EN = "en" + EN_AU = "en-au" + EN_BZ = "en-bz" + EN_CA = "en-ca" + EN_GB = "en-gb" + EN_IE = "en-ie" + EN_JM = "en-jm" + EN_NZ = "en-nz" + EN_TT = "en-tt" + EN_US = "en-us" + EN_ZA = "en-za" + EO = "eo" + ES = "es" + ES_AR = "es-ar" + ES_BO = "es-bo" + ES_CL = "es-cl" + ES_CO = "es-co" + ES_CR = "es-cr" + ES_DO = "es-do" + ES_EC = "es-ec" + ES_GT = "es-gt" + ES_HN = "es-hn" + ES_MX = "es-mx" + ES_NI = "es-ni" + ES_PA = "es-pa" + ES_PE = "es-pe" + ES_PR = "es-pr" + ES_PY = "es-py" + ES_SV = "es-sv" + ES_UY = "es-uy" + ES_VE = "es-ve" + ET = "et" + EU = "eu" + FA = "fa" + FI = "fi" + FO = "fo" + FR = "fr" + FR_BE = "fr-be" + FR_CA = "fr-ca" + FR_CH = "fr-ch" + FR_LU = "fr-lu" + GA = "ga" + GD = "gd" + HE = "he" + HI = "hi" + HR = "hr" + HU = "hu" + ID = "id" + IS = "is" + IT = "it" + IT_CH = "it-ch" + JA = "ja" + JI = "ji" + KO = "ko" + KU = "ku" + LT = "lt" + LV = "lv" + MK = "mk" + ML = "ml" + MS = "ms" + MT = "mt" + NB = "nb" + NE = "ne" + NL = "nl" + NL_BE = "nl-be" + NN = "nn" + NO = "no" + PA = "pa" + PL = "pl" + PT = "pt" + PT_BR = "pt-br" + RM = "rm" + RO = "ro" + RO_MD = "ro-md" + RU = "ru" + RU_MD = "ru-md" + SB = "sb" + SK = "sk" + SL = "sl" + SQ = "sq" + SR = "sr" + SV = "sv" + SV_FI = "sv-fi" + TH = "th" + TN = "tn" + TR = "tr" + TS = "ts" + UA = "ua" + UR = "ur" + VE = "ve" + VI = "vi" + XH = "xh" + ZH_CN = "zh-cn" + ZH_HK = "zh-hk" + ZH_SG = "zh-sg" + ZH_TW = "zh-tw" + ZU = "zu" diff --git a/appwrite/enums/email_template_type.py b/appwrite/enums/email_template_type.py new file mode 100644 index 00000000..67f6d997 --- /dev/null +++ b/appwrite/enums/email_template_type.py @@ -0,0 +1,10 @@ +from enum import Enum + +class EmailTemplateType(Enum): + VERIFICATION = "verification" + MAGICSESSION = "magicSession" + RECOVERY = "recovery" + INVITATION = "invitation" + MFACHALLENGE = "mfaChallenge" + SESSIONALERT = "sessionAlert" + OTPSESSION = "otpSession" diff --git a/appwrite/enums/method_id.py b/appwrite/enums/method_id.py new file mode 100644 index 00000000..5eb5c47d --- /dev/null +++ b/appwrite/enums/method_id.py @@ -0,0 +1,10 @@ +from enum import Enum + +class MethodId(Enum): + EMAIL_PASSWORD = "email-password" + MAGIC_URL = "magic-url" + EMAIL_OTP = "email-otp" + ANONYMOUS = "anonymous" + INVITES = "invites" + JWT = "jwt" + PHONE = "phone" diff --git a/appwrite/enums/o_auth_provider.py b/appwrite/enums/o_auth_provider.py index 6d2e2171..18b69a49 100644 --- a/appwrite/enums/o_auth_provider.py +++ b/appwrite/enums/o_auth_provider.py @@ -16,9 +16,12 @@ class OAuthProvider(Enum): ETSY = "etsy" FACEBOOK = "facebook" FIGMA = "figma" + FUSIONAUTH = "fusionauth" GITHUB = "github" GITLAB = "gitlab" GOOGLE = "google" + KEYCLOAK = "keycloak" + KICK = "kick" LINKEDIN = "linkedin" MICROSOFT = "microsoft" NOTION = "notion" diff --git a/appwrite/enums/policy_id.py b/appwrite/enums/policy_id.py new file mode 100644 index 00000000..ef5afb8b --- /dev/null +++ b/appwrite/enums/policy_id.py @@ -0,0 +1,12 @@ +from enum import Enum + +class PolicyId(Enum): + PASSWORD_DICTIONARY = "password-dictionary" + PASSWORD_HISTORY = "password-history" + PASSWORD_PERSONAL_DATA = "password-personal-data" + SESSION_ALERT = "session-alert" + SESSION_DURATION = "session-duration" + SESSION_INVALIDATION = "session-invalidation" + SESSION_LIMIT = "session-limit" + USER_LIMIT = "user-limit" + MEMBERSHIP_PRIVACY = "membership-privacy" diff --git a/appwrite/enums/provider_id.py b/appwrite/enums/provider_id.py new file mode 100644 index 00000000..8e59f891 --- /dev/null +++ b/appwrite/enums/provider_id.py @@ -0,0 +1,50 @@ +from enum import Enum + +class ProviderId(Enum): + AMAZON = "amazon" + APPLE = "apple" + AUTH0 = "auth0" + AUTHENTIK = "authentik" + AUTODESK = "autodesk" + BITBUCKET = "bitbucket" + BITLY = "bitly" + BOX = "box" + DAILYMOTION = "dailymotion" + DISCORD = "discord" + DISQUS = "disqus" + DROPBOX = "dropbox" + ETSY = "etsy" + FACEBOOK = "facebook" + FIGMA = "figma" + FUSIONAUTH = "fusionauth" + GITHUB = "github" + GITLAB = "gitlab" + GOOGLE = "google" + KEYCLOAK = "keycloak" + KICK = "kick" + LINKEDIN = "linkedin" + MICROSOFT = "microsoft" + NOTION = "notion" + OIDC = "oidc" + OKTA = "okta" + PAYPAL = "paypal" + PAYPALSANDBOX = "paypalSandbox" + PODIO = "podio" + SALESFORCE = "salesforce" + SLACK = "slack" + SPOTIFY = "spotify" + STRIPE = "stripe" + TRADESHIFT = "tradeshift" + TRADESHIFTBOX = "tradeshiftBox" + TWITCH = "twitch" + WORDPRESS = "wordpress" + X = "x" + YAHOO = "yahoo" + YAMMER = "yammer" + YANDEX = "yandex" + ZOHO = "zoho" + ZOOM = "zoom" + MOCK = "mock" + MOCK_UNVERIFIED = "mock-unverified" + GITHUBIMAGINE = "githubImagine" + GOOGLEIMAGINE = "googleImagine" diff --git a/appwrite/enums/proxy_resource_type.py b/appwrite/enums/proxy_resource_type.py new file mode 100644 index 00000000..8b9378da --- /dev/null +++ b/appwrite/enums/proxy_resource_type.py @@ -0,0 +1,5 @@ +from enum import Enum + +class ProxyResourceType(Enum): + SITE = "site" + FUNCTION = "function" diff --git a/appwrite/enums/proxy_rule_deployment_resource_type.py b/appwrite/enums/proxy_rule_deployment_resource_type.py new file mode 100644 index 00000000..9013ed02 --- /dev/null +++ b/appwrite/enums/proxy_rule_deployment_resource_type.py @@ -0,0 +1,5 @@ +from enum import Enum + +class ProxyRuleDeploymentResourceType(Enum): + FUNCTION = "function" + SITE = "site" diff --git a/appwrite/enums/proxy_rule_status.py b/appwrite/enums/proxy_rule_status.py new file mode 100644 index 00000000..29ab0713 --- /dev/null +++ b/appwrite/enums/proxy_rule_status.py @@ -0,0 +1,6 @@ +from enum import Enum + +class ProxyRuleStatus(Enum): + UNVERIFIED = "unverified" + VERIFYING = "verifying" + VERIFIED = "verified" diff --git a/appwrite/enums/runtime.py b/appwrite/enums/runtime.py index 4e18383e..2572cb01 100644 --- a/appwrite/enums/runtime.py +++ b/appwrite/enums/runtime.py @@ -81,6 +81,7 @@ class Runtime(Enum): GO_1_24 = "go-1.24" GO_1_25 = "go-1.25" GO_1_26 = "go-1.26" + RUST_1_83 = "rust-1.83" STATIC_1 = "static-1" FLUTTER_3_24 = "flutter-3.24" FLUTTER_3_27 = "flutter-3.27" diff --git a/appwrite/enums/scopes.py b/appwrite/enums/scopes.py index 390fe6b5..a8422293 100644 --- a/appwrite/enums/scopes.py +++ b/appwrite/enums/scopes.py @@ -1,73 +1,88 @@ from enum import Enum class Scopes(Enum): - SESSIONS_WRITE = "sessions.write" + PROJECT_READ = "project.read" + PROJECT_WRITE = "project.write" + KEYS_READ = "keys.read" + KEYS_WRITE = "keys.write" + PLATFORMS_READ = "platforms.read" + PLATFORMS_WRITE = "platforms.write" + MOCKS_READ = "mocks.read" + MOCKS_WRITE = "mocks.write" + POLICIES_READ = "policies.read" + POLICIES_WRITE = "policies.write" + PROJECT_POLICIES_READ = "project.policies.read" + PROJECT_POLICIES_WRITE = "project.policies.write" + TEMPLATES_READ = "templates.read" + TEMPLATES_WRITE = "templates.write" + OAUTH2_READ = "oauth2.read" + OAUTH2_WRITE = "oauth2.write" USERS_READ = "users.read" USERS_WRITE = "users.write" + SESSIONS_READ = "sessions.read" + SESSIONS_WRITE = "sessions.write" TEAMS_READ = "teams.read" TEAMS_WRITE = "teams.write" DATABASES_READ = "databases.read" DATABASES_WRITE = "databases.write" - COLLECTIONS_READ = "collections.read" - COLLECTIONS_WRITE = "collections.write" TABLES_READ = "tables.read" TABLES_WRITE = "tables.write" - ATTRIBUTES_READ = "attributes.read" - ATTRIBUTES_WRITE = "attributes.write" COLUMNS_READ = "columns.read" COLUMNS_WRITE = "columns.write" INDEXES_READ = "indexes.read" INDEXES_WRITE = "indexes.write" - DOCUMENTS_READ = "documents.read" - DOCUMENTS_WRITE = "documents.write" ROWS_READ = "rows.read" ROWS_WRITE = "rows.write" - FILES_READ = "files.read" - FILES_WRITE = "files.write" + COLLECTIONS_READ = "collections.read" + COLLECTIONS_WRITE = "collections.write" + ATTRIBUTES_READ = "attributes.read" + ATTRIBUTES_WRITE = "attributes.write" + DOCUMENTS_READ = "documents.read" + DOCUMENTS_WRITE = "documents.write" BUCKETS_READ = "buckets.read" BUCKETS_WRITE = "buckets.write" + FILES_READ = "files.read" + FILES_WRITE = "files.write" + TOKENS_READ = "tokens.read" + TOKENS_WRITE = "tokens.write" FUNCTIONS_READ = "functions.read" FUNCTIONS_WRITE = "functions.write" + EXECUTIONS_READ = "executions.read" + EXECUTIONS_WRITE = "executions.write" + EXECUTION_READ = "execution.read" + EXECUTION_WRITE = "execution.write" SITES_READ = "sites.read" SITES_WRITE = "sites.write" LOG_READ = "log.read" LOG_WRITE = "log.write" - EXECUTION_READ = "execution.read" - EXECUTION_WRITE = "execution.write" - LOCALE_READ = "locale.read" - AVATARS_READ = "avatars.read" - HEALTH_READ = "health.read" PROVIDERS_READ = "providers.read" PROVIDERS_WRITE = "providers.write" - MESSAGES_READ = "messages.read" - MESSAGES_WRITE = "messages.write" TOPICS_READ = "topics.read" TOPICS_WRITE = "topics.write" SUBSCRIBERS_READ = "subscribers.read" SUBSCRIBERS_WRITE = "subscribers.write" TARGETS_READ = "targets.read" TARGETS_WRITE = "targets.write" + MESSAGES_READ = "messages.read" + MESSAGES_WRITE = "messages.write" RULES_READ = "rules.read" RULES_WRITE = "rules.write" - SCHEDULES_READ = "schedules.read" - SCHEDULES_WRITE = "schedules.write" + WEBHOOKS_READ = "webhooks.read" + WEBHOOKS_WRITE = "webhooks.write" + LOCALE_READ = "locale.read" + AVATARS_READ = "avatars.read" + HEALTH_READ = "health.read" + ASSISTANT_READ = "assistant.read" MIGRATIONS_READ = "migrations.read" MIGRATIONS_WRITE = "migrations.write" + SCHEDULES_READ = "schedules.read" + SCHEDULES_WRITE = "schedules.write" VCS_READ = "vcs.read" VCS_WRITE = "vcs.write" - ASSISTANT_READ = "assistant.read" - TOKENS_READ = "tokens.read" - TOKENS_WRITE = "tokens.write" - WEBHOOKS_READ = "webhooks.read" - WEBHOOKS_WRITE = "webhooks.write" - PROJECT_READ = "project.read" - PROJECT_WRITE = "project.write" - KEYS_READ = "keys.read" - KEYS_WRITE = "keys.write" - PLATFORMS_READ = "platforms.read" - PLATFORMS_WRITE = "platforms.write" - POLICIES_WRITE = "policies.write" - POLICIES_READ = "policies.read" + PRESENCES_READ = "presences.read" + PRESENCES_WRITE = "presences.write" + BACKUPS_POLICIES_READ = "backups.policies.read" + BACKUPS_POLICIES_WRITE = "backups.policies.write" ARCHIVES_READ = "archives.read" ARCHIVES_WRITE = "archives.write" RESTORATIONS_READ = "restorations.read" diff --git a/appwrite/enums/secure.py b/appwrite/enums/secure.py new file mode 100644 index 00000000..41a04f36 --- /dev/null +++ b/appwrite/enums/secure.py @@ -0,0 +1,5 @@ +from enum import Enum + +class Secure(Enum): + TLS = "tls" + SSL = "ssl" diff --git a/appwrite/enums/status_code.py b/appwrite/enums/status_code.py new file mode 100644 index 00000000..4eb00ec0 --- /dev/null +++ b/appwrite/enums/status_code.py @@ -0,0 +1,7 @@ +from enum import Enum + +class StatusCode(Enum): + MOVED_PERMANENTLY_301 = "301" + FOUND_302 = "302" + TEMPORARY_REDIRECT_307 = "307" + PERMANENT_REDIRECT_308 = "308" diff --git a/appwrite/models/__init__.py b/appwrite/models/__init__.py index a9352e44..6e42b85b 100644 --- a/appwrite/models/__init__.py +++ b/appwrite/models/__init__.py @@ -1,6 +1,7 @@ from .base_model import AppwriteModel from .row_list import RowList from .document_list import DocumentList +from .presence_list import PresenceList from .table_list import TableList from .collection_list import CollectionList from .database_list import DatabaseList @@ -29,7 +30,11 @@ from .currency_list import CurrencyList from .phone_list import PhoneList from .variable_list import VariableList +from .mock_number_list import MockNumberList +from .policy_list import PolicyList +from .email_template_list import EmailTemplateList from .health_status_list import HealthStatusList +from .proxy_rule_list import ProxyRuleList from .locale_code_list import LocaleCodeList from .provider_list import ProviderList from .message_list import MessageList @@ -43,6 +48,7 @@ from .attribute_list import AttributeList from .attribute_string import AttributeString from .attribute_integer import AttributeInteger +from .attribute_bigint import AttributeBigint from .attribute_float import AttributeFloat from .attribute_boolean import AttributeBoolean from .attribute_email import AttributeEmail @@ -62,6 +68,7 @@ from .column_list import ColumnList from .column_string import ColumnString from .column_integer import ColumnInteger +from .column_bigint import ColumnBigint from .column_float import ColumnFloat from .column_boolean import ColumnBoolean from .column_email import ColumnEmail @@ -81,6 +88,7 @@ from .column_index import ColumnIndex from .row import Row from .document import Document +from .presence import Presence from .log import Log from .user import User from .algo_md5 import AlgoMd5 @@ -112,8 +120,59 @@ from .project import Project from .webhook import Webhook from .key import Key +from .ephemeral_key import EphemeralKey from .dev_key import DevKey from .mock_number import MockNumber +from .o_auth2_github import OAuth2Github +from .o_auth2_discord import OAuth2Discord +from .o_auth2_figma import OAuth2Figma +from .o_auth2_dropbox import OAuth2Dropbox +from .o_auth2_dailymotion import OAuth2Dailymotion +from .o_auth2_bitbucket import OAuth2Bitbucket +from .o_auth2_bitly import OAuth2Bitly +from .o_auth2_box import OAuth2Box +from .o_auth2_autodesk import OAuth2Autodesk +from .o_auth2_google import OAuth2Google +from .o_auth2_zoom import OAuth2Zoom +from .o_auth2_zoho import OAuth2Zoho +from .o_auth2_yandex import OAuth2Yandex +from .o_auth2_x import OAuth2X +from .o_auth2_word_press import OAuth2WordPress +from .o_auth2_twitch import OAuth2Twitch +from .o_auth2_stripe import OAuth2Stripe +from .o_auth2_spotify import OAuth2Spotify +from .o_auth2_slack import OAuth2Slack +from .o_auth2_podio import OAuth2Podio +from .o_auth2_notion import OAuth2Notion +from .o_auth2_salesforce import OAuth2Salesforce +from .o_auth2_yahoo import OAuth2Yahoo +from .o_auth2_linkedin import OAuth2Linkedin +from .o_auth2_disqus import OAuth2Disqus +from .o_auth2_amazon import OAuth2Amazon +from .o_auth2_etsy import OAuth2Etsy +from .o_auth2_facebook import OAuth2Facebook +from .o_auth2_tradeshift import OAuth2Tradeshift +from .o_auth2_paypal import OAuth2Paypal +from .o_auth2_gitlab import OAuth2Gitlab +from .o_auth2_authentik import OAuth2Authentik +from .o_auth2_auth0 import OAuth2Auth0 +from .o_auth2_fusion_auth import OAuth2FusionAuth +from .o_auth2_keycloak import OAuth2Keycloak +from .o_auth2_oidc import OAuth2Oidc +from .o_auth2_okta import OAuth2Okta +from .o_auth2_kick import OAuth2Kick +from .o_auth2_apple import OAuth2Apple +from .o_auth2_microsoft import OAuth2Microsoft +from .o_auth2_provider_list import OAuth2ProviderList +from .policy_password_dictionary import PolicyPasswordDictionary +from .policy_password_history import PolicyPasswordHistory +from .policy_password_personal_data import PolicyPasswordPersonalData +from .policy_session_alert import PolicySessionAlert +from .policy_session_duration import PolicySessionDuration +from .policy_session_invalidation import PolicySessionInvalidation +from .policy_session_limit import PolicySessionLimit +from .policy_user_limit import PolicyUserLimit +from .policy_membership_privacy import PolicyMembershipPrivacy from .auth_provider import AuthProvider from .platform_web import PlatformWeb from .platform_apple import PlatformApple @@ -134,6 +193,8 @@ from .health_time import HealthTime from .headers import Headers from .specification import Specification +from .proxy_rule import ProxyRule +from .email_template import EmailTemplate from .mfa_challenge import MfaChallenge from .mfa_recovery_codes import MfaRecoveryCodes from .mfa_type import MfaType @@ -159,6 +220,7 @@ 'AppwriteModel', 'RowList', 'DocumentList', + 'PresenceList', 'TableList', 'CollectionList', 'DatabaseList', @@ -187,7 +249,11 @@ 'CurrencyList', 'PhoneList', 'VariableList', + 'MockNumberList', + 'PolicyList', + 'EmailTemplateList', 'HealthStatusList', + 'ProxyRuleList', 'LocaleCodeList', 'ProviderList', 'MessageList', @@ -201,6 +267,7 @@ 'AttributeList', 'AttributeString', 'AttributeInteger', + 'AttributeBigint', 'AttributeFloat', 'AttributeBoolean', 'AttributeEmail', @@ -220,6 +287,7 @@ 'ColumnList', 'ColumnString', 'ColumnInteger', + 'ColumnBigint', 'ColumnFloat', 'ColumnBoolean', 'ColumnEmail', @@ -239,6 +307,7 @@ 'ColumnIndex', 'Row', 'Document', + 'Presence', 'Log', 'User', 'AlgoMd5', @@ -270,8 +339,59 @@ 'Project', 'Webhook', 'Key', + 'EphemeralKey', 'DevKey', 'MockNumber', + 'OAuth2Github', + 'OAuth2Discord', + 'OAuth2Figma', + 'OAuth2Dropbox', + 'OAuth2Dailymotion', + 'OAuth2Bitbucket', + 'OAuth2Bitly', + 'OAuth2Box', + 'OAuth2Autodesk', + 'OAuth2Google', + 'OAuth2Zoom', + 'OAuth2Zoho', + 'OAuth2Yandex', + 'OAuth2X', + 'OAuth2WordPress', + 'OAuth2Twitch', + 'OAuth2Stripe', + 'OAuth2Spotify', + 'OAuth2Slack', + 'OAuth2Podio', + 'OAuth2Notion', + 'OAuth2Salesforce', + 'OAuth2Yahoo', + 'OAuth2Linkedin', + 'OAuth2Disqus', + 'OAuth2Amazon', + 'OAuth2Etsy', + 'OAuth2Facebook', + 'OAuth2Tradeshift', + 'OAuth2Paypal', + 'OAuth2Gitlab', + 'OAuth2Authentik', + 'OAuth2Auth0', + 'OAuth2FusionAuth', + 'OAuth2Keycloak', + 'OAuth2Oidc', + 'OAuth2Okta', + 'OAuth2Kick', + 'OAuth2Apple', + 'OAuth2Microsoft', + 'OAuth2ProviderList', + 'PolicyPasswordDictionary', + 'PolicyPasswordHistory', + 'PolicyPasswordPersonalData', + 'PolicySessionAlert', + 'PolicySessionDuration', + 'PolicySessionInvalidation', + 'PolicySessionLimit', + 'PolicyUserLimit', + 'PolicyMembershipPrivacy', 'AuthProvider', 'PlatformWeb', 'PlatformApple', @@ -292,6 +412,8 @@ 'HealthTime', 'Headers', 'Specification', + 'ProxyRule', + 'EmailTemplate', 'MfaChallenge', 'MfaRecoveryCodes', 'MfaType', diff --git a/appwrite/models/attribute_bigint.py b/appwrite/models/attribute_bigint.py new file mode 100644 index 00000000..aae6fd2d --- /dev/null +++ b/appwrite/models/attribute_bigint.py @@ -0,0 +1,46 @@ +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 + +class AttributeBigint(AppwriteModel): + """ + AttributeBigInt + + 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_list.py b/appwrite/models/attribute_list.py index ae9101c4..0c98c95d 100644 --- a/appwrite/models/attribute_list.py +++ b/appwrite/models/attribute_list.py @@ -3,6 +3,7 @@ from .base_model import AppwriteModel from .attribute_boolean import AttributeBoolean +from .attribute_bigint import AttributeBigint from .attribute_integer import AttributeInteger from .attribute_float import AttributeFloat from .attribute_email import AttributeEmail @@ -28,8 +29,8 @@ class AttributeList(AppwriteModel): ---------- 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]] + attributes : List[Union[AttributeBoolean, AttributeBigint, 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') + attributes: List[Union[AttributeBoolean, AttributeBigint, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString]] = Field(..., alias='attributes') diff --git a/appwrite/models/auth_provider.py b/appwrite/models/auth_provider.py index 4df14542..88b0f249 100644 --- a/appwrite/models/auth_provider.py +++ b/appwrite/models/auth_provider.py @@ -16,7 +16,7 @@ class AuthProvider(AppwriteModel): appid : str OAuth 2.0 application ID. secret : str - OAuth 2.0 application secret. Might be JSON string if provider requires extra configuration. + OAuth 2.0 application secret. Might be JSON string if provider requires extra configuration. This property is write-only and always returned empty. enabled : bool Auth Provider is active and can be used to create session. """ diff --git a/appwrite/models/backup_archive.py b/appwrite/models/backup_archive.py index a3459c0b..d9d43356 100644 --- a/appwrite/models/backup_archive.py +++ b/appwrite/models/backup_archive.py @@ -20,7 +20,7 @@ class BackupArchive(AppwriteModel): size : float Archive size in bytes. status : str - The status of the archive creation. Possible values: pending, processing, uploading, completed, failed. + The status of the archive creation. Possible values: pending, processing, uploading, completed, failed, skipped. startedat : str The backup start time. migrationid : str diff --git a/appwrite/models/block.py b/appwrite/models/block.py index 6e5ebb05..4e11336d 100644 --- a/appwrite/models/block.py +++ b/appwrite/models/block.py @@ -19,9 +19,24 @@ class Block(AppwriteModel): Reason for the block. Can be null if no reason was provided. expiredat : Optional[str] Block expiration date in ISO 8601 format. Can be null if the block does not expire. + projectname : str + Name of the project this block applies to. + region : str + Region of the project this block applies to. + organizationname : str + Name of the organization that owns the project. + organizationid : str + ID of the organization that owns the project. + billingplan : str + Billing plan of the organization that owns the project. """ createdat: str = Field(..., alias='$createdAt') resourcetype: str = Field(..., alias='resourceType') resourceid: str = Field(..., alias='resourceId') reason: Optional[str] = Field(default=None, alias='reason') expiredat: Optional[str] = Field(default=None, alias='expiredAt') + projectname: str = Field(..., alias='projectName') + region: str = Field(..., alias='region') + organizationname: str = Field(..., alias='organizationName') + organizationid: str = Field(..., alias='organizationId') + billingplan: str = Field(..., alias='billingPlan') diff --git a/appwrite/models/collection.py b/appwrite/models/collection.py index db1d054e..d55dbe82 100644 --- a/appwrite/models/collection.py +++ b/appwrite/models/collection.py @@ -3,6 +3,7 @@ from .base_model import AppwriteModel from .attribute_boolean import AttributeBoolean +from .attribute_bigint import AttributeBigint from .attribute_integer import AttributeInteger from .attribute_float import AttributeFloat from .attribute_email import AttributeEmail @@ -43,7 +44,7 @@ class Collection(AppwriteModel): 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]] + attributes : List[Union[AttributeBoolean, AttributeBigint, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString]] Collection attributes. indexes : List[Index] Collection indexes. @@ -60,7 +61,7 @@ class Collection(AppwriteModel): 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') + attributes: List[Union[AttributeBoolean, AttributeBigint, 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/column_bigint.py b/appwrite/models/column_bigint.py new file mode 100644 index 00000000..2839a842 --- /dev/null +++ b/appwrite/models/column_bigint.py @@ -0,0 +1,46 @@ +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 + +class ColumnBigint(AppwriteModel): + """ + ColumnBigInt + + 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_list.py b/appwrite/models/column_list.py index d6f05bd6..7a9635e4 100644 --- a/appwrite/models/column_list.py +++ b/appwrite/models/column_list.py @@ -3,6 +3,7 @@ from .base_model import AppwriteModel from .column_boolean import ColumnBoolean +from .column_bigint import ColumnBigint from .column_integer import ColumnInteger from .column_float import ColumnFloat from .column_email import ColumnEmail @@ -28,8 +29,8 @@ class ColumnList(AppwriteModel): ---------- 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]] + columns : List[Union[ColumnBoolean, ColumnBigint, 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') + columns: List[Union[ColumnBoolean, ColumnBigint, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString]] = Field(..., alias='columns') diff --git a/appwrite/models/email_template.py b/appwrite/models/email_template.py new file mode 100644 index 00000000..87af0a74 --- /dev/null +++ b/appwrite/models/email_template.py @@ -0,0 +1,36 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class EmailTemplate(AppwriteModel): + """ + EmailTemplate + + Attributes + ---------- + templateid : str + Template type + locale : str + Template locale + message : str + Template message + sendername : str + Name of the sender + senderemail : str + Email of the sender + replytoemail : str + Reply to email address + replytoname : str + Reply to name + subject : str + Email subject + """ + templateid: str = Field(..., alias='templateId') + locale: str = Field(..., alias='locale') + message: str = Field(..., alias='message') + sendername: str = Field(..., alias='senderName') + senderemail: str = Field(..., alias='senderEmail') + replytoemail: str = Field(..., alias='replyToEmail') + replytoname: str = Field(..., alias='replyToName') + subject: str = Field(..., alias='subject') diff --git a/appwrite/models/email_template_list.py b/appwrite/models/email_template_list.py new file mode 100644 index 00000000..8bca9063 --- /dev/null +++ b/appwrite/models/email_template_list.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .email_template import EmailTemplate + +class EmailTemplateList(AppwriteModel): + """ + Email Templates List + + Attributes + ---------- + total : float + Total number of templates that matched your query. + templates : List[EmailTemplate] + List of templates. + """ + total: float = Field(..., alias='total') + templates: List[EmailTemplate] = Field(..., alias='templates') diff --git a/appwrite/models/ephemeral_key.py b/appwrite/models/ephemeral_key.py new file mode 100644 index 00000000..eeb976e3 --- /dev/null +++ b/appwrite/models/ephemeral_key.py @@ -0,0 +1,39 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class EphemeralKey(AppwriteModel): + """ + Ephemeral Key + + Attributes + ---------- + id : str + Key ID. + createdat : str + Key creation date in ISO 8601 format. + updatedat : str + Key update date in ISO 8601 format. + name : str + Key name. + expire : str + Key expiration date in ISO 8601 format. + scopes : List[Any] + Allowed permission scopes. + secret : str + Secret key. + accessedat : str + Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + sdks : List[Any] + List of SDK user agents that used this key. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + expire: str = Field(..., alias='expire') + scopes: List[Any] = Field(..., alias='scopes') + secret: str = Field(..., alias='secret') + accessedat: str = Field(..., alias='accessedAt') + sdks: List[Any] = Field(..., alias='sdks') diff --git a/appwrite/models/membership.py b/appwrite/models/membership.py index b309efdf..822c8a6a 100644 --- a/appwrite/models/membership.py +++ b/appwrite/models/membership.py @@ -21,6 +21,8 @@ class Membership(AppwriteModel): 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. + userphone : str + User phone number. Hide this attribute by toggling membership privacy in the Console. teamid : str Team ID. teamname : str @@ -42,6 +44,7 @@ class Membership(AppwriteModel): userid: str = Field(..., alias='userId') username: str = Field(..., alias='userName') useremail: str = Field(..., alias='userEmail') + userphone: str = Field(..., alias='userPhone') teamid: str = Field(..., alias='teamId') teamname: str = Field(..., alias='teamName') invited: str = Field(..., alias='invited') diff --git a/appwrite/models/mock_number.py b/appwrite/models/mock_number.py index 5798dc75..30348833 100644 --- a/appwrite/models/mock_number.py +++ b/appwrite/models/mock_number.py @@ -9,10 +9,16 @@ class MockNumber(AppwriteModel): Attributes ---------- - phone : str + number : str Mock phone number for testing phone authentication. Useful for testing phone authentication without sending an SMS. otp : str Mock OTP for the number. + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. """ - phone: str = Field(..., alias='phone') + number: str = Field(..., alias='number') otp: str = Field(..., alias='otp') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') diff --git a/appwrite/models/mock_number_list.py b/appwrite/models/mock_number_list.py new file mode 100644 index 00000000..6f11a81b --- /dev/null +++ b/appwrite/models/mock_number_list.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .mock_number import MockNumber + +class MockNumberList(AppwriteModel): + """ + Mock Numbers List + + Attributes + ---------- + total : float + Total number of mockNumbers that matched your query. + mocknumbers : List[MockNumber] + List of mockNumbers. + """ + total: float = Field(..., alias='total') + mocknumbers: List[MockNumber] = Field(..., alias='mockNumbers') diff --git a/appwrite/models/o_auth2_amazon.py b/appwrite/models/o_auth2_amazon.py new file mode 100644 index 00000000..6d0e2977 --- /dev/null +++ b/appwrite/models/o_auth2_amazon.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Amazon(AppwriteModel): + """ + OAuth2Amazon + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Amazon OAuth2 client ID. + clientsecret : str + Amazon OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_apple.py b/appwrite/models/o_auth2_apple.py new file mode 100644 index 00000000..85096a79 --- /dev/null +++ b/appwrite/models/o_auth2_apple.py @@ -0,0 +1,30 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Apple(AppwriteModel): + """ + OAuth2Apple + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + serviceid : str + Apple OAuth2 service ID. + keyid : str + Apple OAuth2 key ID. + teamid : str + Apple OAuth2 team ID. + p8file : str + Apple OAuth2 .p8 private key file contents. The secret key wrapped by the PEM markers is 200 characters long. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + serviceid: str = Field(..., alias='serviceId') + keyid: str = Field(..., alias='keyId') + teamid: str = Field(..., alias='teamId') + p8file: str = Field(..., alias='p8File') diff --git a/appwrite/models/o_auth2_auth0.py b/appwrite/models/o_auth2_auth0.py new file mode 100644 index 00000000..5c5b3ae2 --- /dev/null +++ b/appwrite/models/o_auth2_auth0.py @@ -0,0 +1,27 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Auth0(AppwriteModel): + """ + OAuth2Auth0 + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Auth0 OAuth2 client ID. + clientsecret : str + Auth0 OAuth2 client secret. + endpoint : str + Auth0 OAuth2 endpoint domain. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') + endpoint: str = Field(..., alias='endpoint') diff --git a/appwrite/models/o_auth2_authentik.py b/appwrite/models/o_auth2_authentik.py new file mode 100644 index 00000000..b5d73c06 --- /dev/null +++ b/appwrite/models/o_auth2_authentik.py @@ -0,0 +1,27 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Authentik(AppwriteModel): + """ + OAuth2Authentik + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Authentik OAuth2 client ID. + clientsecret : str + Authentik OAuth2 client secret. + endpoint : str + Authentik OAuth2 endpoint domain. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') + endpoint: str = Field(..., alias='endpoint') diff --git a/appwrite/models/o_auth2_autodesk.py b/appwrite/models/o_auth2_autodesk.py new file mode 100644 index 00000000..b5b879d8 --- /dev/null +++ b/appwrite/models/o_auth2_autodesk.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Autodesk(AppwriteModel): + """ + OAuth2Autodesk + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Autodesk OAuth2 client ID. + clientsecret : str + Autodesk OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_bitbucket.py b/appwrite/models/o_auth2_bitbucket.py new file mode 100644 index 00000000..d2028fba --- /dev/null +++ b/appwrite/models/o_auth2_bitbucket.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Bitbucket(AppwriteModel): + """ + OAuth2Bitbucket + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + key : str + Bitbucket OAuth2 key. + secret : str + Bitbucket OAuth2 secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + key: str = Field(..., alias='key') + secret: str = Field(..., alias='secret') diff --git a/appwrite/models/o_auth2_bitly.py b/appwrite/models/o_auth2_bitly.py new file mode 100644 index 00000000..39a250c3 --- /dev/null +++ b/appwrite/models/o_auth2_bitly.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Bitly(AppwriteModel): + """ + OAuth2Bitly + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Bitly OAuth2 client ID. + clientsecret : str + Bitly OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_box.py b/appwrite/models/o_auth2_box.py new file mode 100644 index 00000000..03538b4a --- /dev/null +++ b/appwrite/models/o_auth2_box.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Box(AppwriteModel): + """ + OAuth2Box + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Box OAuth2 client ID. + clientsecret : str + Box OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_dailymotion.py b/appwrite/models/o_auth2_dailymotion.py new file mode 100644 index 00000000..a6ce3665 --- /dev/null +++ b/appwrite/models/o_auth2_dailymotion.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Dailymotion(AppwriteModel): + """ + OAuth2Dailymotion + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + apikey : str + Dailymotion OAuth2 API key. + apisecret : str + Dailymotion OAuth2 API secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + apikey: str = Field(..., alias='apiKey') + apisecret: str = Field(..., alias='apiSecret') diff --git a/appwrite/models/o_auth2_discord.py b/appwrite/models/o_auth2_discord.py new file mode 100644 index 00000000..eb55fbca --- /dev/null +++ b/appwrite/models/o_auth2_discord.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Discord(AppwriteModel): + """ + OAuth2Discord + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Discord OAuth2 client ID. + clientsecret : str + Discord OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_disqus.py b/appwrite/models/o_auth2_disqus.py new file mode 100644 index 00000000..446e2e64 --- /dev/null +++ b/appwrite/models/o_auth2_disqus.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Disqus(AppwriteModel): + """ + OAuth2Disqus + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + publickey : str + Disqus OAuth2 public key. + secretkey : str + Disqus OAuth2 secret key. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + publickey: str = Field(..., alias='publicKey') + secretkey: str = Field(..., alias='secretKey') diff --git a/appwrite/models/o_auth2_dropbox.py b/appwrite/models/o_auth2_dropbox.py new file mode 100644 index 00000000..ff0b3368 --- /dev/null +++ b/appwrite/models/o_auth2_dropbox.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Dropbox(AppwriteModel): + """ + OAuth2Dropbox + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + appkey : str + Dropbox OAuth2 app key. + appsecret : str + Dropbox OAuth2 app secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + appkey: str = Field(..., alias='appKey') + appsecret: str = Field(..., alias='appSecret') diff --git a/appwrite/models/o_auth2_etsy.py b/appwrite/models/o_auth2_etsy.py new file mode 100644 index 00000000..fb405633 --- /dev/null +++ b/appwrite/models/o_auth2_etsy.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Etsy(AppwriteModel): + """ + OAuth2Etsy + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + keystring : str + Etsy OAuth2 keystring. + sharedsecret : str + Etsy OAuth2 shared secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + keystring: str = Field(..., alias='keyString') + sharedsecret: str = Field(..., alias='sharedSecret') diff --git a/appwrite/models/o_auth2_facebook.py b/appwrite/models/o_auth2_facebook.py new file mode 100644 index 00000000..c07100d1 --- /dev/null +++ b/appwrite/models/o_auth2_facebook.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Facebook(AppwriteModel): + """ + OAuth2Facebook + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + appid : str + Facebook OAuth2 app ID. + appsecret : str + Facebook OAuth2 app secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + appid: str = Field(..., alias='appId') + appsecret: str = Field(..., alias='appSecret') diff --git a/appwrite/models/o_auth2_figma.py b/appwrite/models/o_auth2_figma.py new file mode 100644 index 00000000..8fa88a11 --- /dev/null +++ b/appwrite/models/o_auth2_figma.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Figma(AppwriteModel): + """ + OAuth2Figma + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Figma OAuth2 client ID. + clientsecret : str + Figma OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_fusion_auth.py b/appwrite/models/o_auth2_fusion_auth.py new file mode 100644 index 00000000..d0c325d4 --- /dev/null +++ b/appwrite/models/o_auth2_fusion_auth.py @@ -0,0 +1,27 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2FusionAuth(AppwriteModel): + """ + OAuth2FusionAuth + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + FusionAuth OAuth2 client ID. + clientsecret : str + FusionAuth OAuth2 client secret. + endpoint : str + FusionAuth OAuth2 endpoint domain. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') + endpoint: str = Field(..., alias='endpoint') diff --git a/appwrite/models/o_auth2_github.py b/appwrite/models/o_auth2_github.py new file mode 100644 index 00000000..dd7ba070 --- /dev/null +++ b/appwrite/models/o_auth2_github.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Github(AppwriteModel): + """ + OAuth2GitHub + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + GitHub OAuth2 client ID. For GitHub Apps, use the "App ID" when both an App ID and client ID are available. + clientsecret : str + GitHub OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_gitlab.py b/appwrite/models/o_auth2_gitlab.py new file mode 100644 index 00000000..a1967792 --- /dev/null +++ b/appwrite/models/o_auth2_gitlab.py @@ -0,0 +1,27 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Gitlab(AppwriteModel): + """ + OAuth2Gitlab + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + applicationid : str + GitLab OAuth2 application ID. + secret : str + GitLab OAuth2 secret. + endpoint : str + GitLab OAuth2 endpoint URL. Defaults to https://gitlab.com for self-hosted instances. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + applicationid: str = Field(..., alias='applicationId') + secret: str = Field(..., alias='secret') + endpoint: str = Field(..., alias='endpoint') diff --git a/appwrite/models/o_auth2_google.py b/appwrite/models/o_auth2_google.py new file mode 100644 index 00000000..cc130d36 --- /dev/null +++ b/appwrite/models/o_auth2_google.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Google(AppwriteModel): + """ + OAuth2Google + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Google OAuth2 client ID. + clientsecret : str + Google OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_keycloak.py b/appwrite/models/o_auth2_keycloak.py new file mode 100644 index 00000000..fb9f709c --- /dev/null +++ b/appwrite/models/o_auth2_keycloak.py @@ -0,0 +1,30 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Keycloak(AppwriteModel): + """ + OAuth2Keycloak + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Keycloak OAuth2 client ID. + clientsecret : str + Keycloak OAuth2 client secret. + endpoint : str + Keycloak OAuth2 endpoint domain. + realmname : str + Keycloak OAuth2 realm name. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') + endpoint: str = Field(..., alias='endpoint') + realmname: str = Field(..., alias='realmName') diff --git a/appwrite/models/o_auth2_kick.py b/appwrite/models/o_auth2_kick.py new file mode 100644 index 00000000..4e798a26 --- /dev/null +++ b/appwrite/models/o_auth2_kick.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Kick(AppwriteModel): + """ + OAuth2Kick + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Kick OAuth2 client ID. + clientsecret : str + Kick OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_linkedin.py b/appwrite/models/o_auth2_linkedin.py new file mode 100644 index 00000000..ed41f13e --- /dev/null +++ b/appwrite/models/o_auth2_linkedin.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Linkedin(AppwriteModel): + """ + OAuth2Linkedin + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + LinkedIn OAuth2 client ID. + primaryclientsecret : str + LinkedIn OAuth2 primary client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + primaryclientsecret: str = Field(..., alias='primaryClientSecret') diff --git a/appwrite/models/o_auth2_microsoft.py b/appwrite/models/o_auth2_microsoft.py new file mode 100644 index 00000000..07ce5c64 --- /dev/null +++ b/appwrite/models/o_auth2_microsoft.py @@ -0,0 +1,27 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Microsoft(AppwriteModel): + """ + OAuth2Microsoft + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + applicationid : str + Microsoft OAuth2 application ID. + applicationsecret : str + Microsoft OAuth2 application secret. + tenant : str + Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + applicationid: str = Field(..., alias='applicationId') + applicationsecret: str = Field(..., alias='applicationSecret') + tenant: str = Field(..., alias='tenant') diff --git a/appwrite/models/o_auth2_notion.py b/appwrite/models/o_auth2_notion.py new file mode 100644 index 00000000..55a36d5f --- /dev/null +++ b/appwrite/models/o_auth2_notion.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Notion(AppwriteModel): + """ + OAuth2Notion + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + oauthclientid : str + Notion OAuth2 client ID. + oauthclientsecret : str + Notion OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + oauthclientid: str = Field(..., alias='oauthClientId') + oauthclientsecret: str = Field(..., alias='oauthClientSecret') diff --git a/appwrite/models/o_auth2_oidc.py b/appwrite/models/o_auth2_oidc.py new file mode 100644 index 00000000..6b896196 --- /dev/null +++ b/appwrite/models/o_auth2_oidc.py @@ -0,0 +1,36 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Oidc(AppwriteModel): + """ + OAuth2Oidc + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + OpenID Connect OAuth2 client ID. + clientsecret : str + OpenID Connect OAuth2 client secret. + wellknownurl : str + OpenID Connect well-known configuration URL. When set, authorization, token, and user info endpoints can be discovered automatically. + authorizationurl : str + OpenID Connect authorization endpoint URL. + tokenurl : str + OpenID Connect token endpoint URL. + userinfourl : str + OpenID Connect user info endpoint URL. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') + wellknownurl: str = Field(..., alias='wellKnownURL') + authorizationurl: str = Field(..., alias='authorizationURL') + tokenurl: str = Field(..., alias='tokenURL') + userinfourl: str = Field(..., alias='userInfoURL') diff --git a/appwrite/models/o_auth2_okta.py b/appwrite/models/o_auth2_okta.py new file mode 100644 index 00000000..192e56ea --- /dev/null +++ b/appwrite/models/o_auth2_okta.py @@ -0,0 +1,30 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Okta(AppwriteModel): + """ + OAuth2Okta + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Okta OAuth2 client ID. + clientsecret : str + Okta OAuth2 client secret. + domain : str + Okta OAuth2 domain. + authorizationserverid : str + Okta OAuth2 authorization server ID. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') + domain: str = Field(..., alias='domain') + authorizationserverid: str = Field(..., alias='authorizationServerId') diff --git a/appwrite/models/o_auth2_paypal.py b/appwrite/models/o_auth2_paypal.py new file mode 100644 index 00000000..44b6f13e --- /dev/null +++ b/appwrite/models/o_auth2_paypal.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Paypal(AppwriteModel): + """ + OAuth2Paypal + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + PayPal OAuth2 client ID. + secretkey : str + PayPal OAuth2 secret key. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + secretkey: str = Field(..., alias='secretKey') diff --git a/appwrite/models/o_auth2_podio.py b/appwrite/models/o_auth2_podio.py new file mode 100644 index 00000000..ff9d9bad --- /dev/null +++ b/appwrite/models/o_auth2_podio.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Podio(AppwriteModel): + """ + OAuth2Podio + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Podio OAuth2 client ID. + clientsecret : str + Podio OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_provider_list.py b/appwrite/models/o_auth2_provider_list.py new file mode 100644 index 00000000..b07ce754 --- /dev/null +++ b/appwrite/models/o_auth2_provider_list.py @@ -0,0 +1,58 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .o_auth2_github import OAuth2Github +from .o_auth2_discord import OAuth2Discord +from .o_auth2_figma import OAuth2Figma +from .o_auth2_dropbox import OAuth2Dropbox +from .o_auth2_dailymotion import OAuth2Dailymotion +from .o_auth2_bitbucket import OAuth2Bitbucket +from .o_auth2_bitly import OAuth2Bitly +from .o_auth2_box import OAuth2Box +from .o_auth2_autodesk import OAuth2Autodesk +from .o_auth2_google import OAuth2Google +from .o_auth2_zoom import OAuth2Zoom +from .o_auth2_zoho import OAuth2Zoho +from .o_auth2_yandex import OAuth2Yandex +from .o_auth2_x import OAuth2X +from .o_auth2_word_press import OAuth2WordPress +from .o_auth2_twitch import OAuth2Twitch +from .o_auth2_stripe import OAuth2Stripe +from .o_auth2_spotify import OAuth2Spotify +from .o_auth2_slack import OAuth2Slack +from .o_auth2_podio import OAuth2Podio +from .o_auth2_notion import OAuth2Notion +from .o_auth2_salesforce import OAuth2Salesforce +from .o_auth2_yahoo import OAuth2Yahoo +from .o_auth2_linkedin import OAuth2Linkedin +from .o_auth2_disqus import OAuth2Disqus +from .o_auth2_amazon import OAuth2Amazon +from .o_auth2_etsy import OAuth2Etsy +from .o_auth2_facebook import OAuth2Facebook +from .o_auth2_tradeshift import OAuth2Tradeshift +from .o_auth2_paypal import OAuth2Paypal +from .o_auth2_gitlab import OAuth2Gitlab +from .o_auth2_authentik import OAuth2Authentik +from .o_auth2_auth0 import OAuth2Auth0 +from .o_auth2_fusion_auth import OAuth2FusionAuth +from .o_auth2_keycloak import OAuth2Keycloak +from .o_auth2_oidc import OAuth2Oidc +from .o_auth2_apple import OAuth2Apple +from .o_auth2_okta import OAuth2Okta +from .o_auth2_kick import OAuth2Kick +from .o_auth2_microsoft import OAuth2Microsoft + +class OAuth2ProviderList(AppwriteModel): + """ + OAuth2 Providers List + + Attributes + ---------- + total : float + Total number of OAuth2 providers in the given project. + providers : List[Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft]] + List of OAuth2 providers. + """ + total: float = Field(..., alias='total') + providers: List[Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft]] = Field(..., alias='providers') diff --git a/appwrite/models/o_auth2_salesforce.py b/appwrite/models/o_auth2_salesforce.py new file mode 100644 index 00000000..a72f7dec --- /dev/null +++ b/appwrite/models/o_auth2_salesforce.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Salesforce(AppwriteModel): + """ + OAuth2Salesforce + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + customerkey : str + Salesforce OAuth2 consumer key. + customersecret : str + Salesforce OAuth2 consumer secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + customerkey: str = Field(..., alias='customerKey') + customersecret: str = Field(..., alias='customerSecret') diff --git a/appwrite/models/o_auth2_slack.py b/appwrite/models/o_auth2_slack.py new file mode 100644 index 00000000..074934f0 --- /dev/null +++ b/appwrite/models/o_auth2_slack.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Slack(AppwriteModel): + """ + OAuth2Slack + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Slack OAuth2 client ID. + clientsecret : str + Slack OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_spotify.py b/appwrite/models/o_auth2_spotify.py new file mode 100644 index 00000000..90169546 --- /dev/null +++ b/appwrite/models/o_auth2_spotify.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Spotify(AppwriteModel): + """ + OAuth2Spotify + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Spotify OAuth2 client ID. + clientsecret : str + Spotify OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_stripe.py b/appwrite/models/o_auth2_stripe.py new file mode 100644 index 00000000..47e3e696 --- /dev/null +++ b/appwrite/models/o_auth2_stripe.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Stripe(AppwriteModel): + """ + OAuth2Stripe + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Stripe OAuth2 client ID. + apisecretkey : str + Stripe OAuth2 API secret key. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + apisecretkey: str = Field(..., alias='apiSecretKey') diff --git a/appwrite/models/o_auth2_tradeshift.py b/appwrite/models/o_auth2_tradeshift.py new file mode 100644 index 00000000..084424ed --- /dev/null +++ b/appwrite/models/o_auth2_tradeshift.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Tradeshift(AppwriteModel): + """ + OAuth2Tradeshift + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + oauth2clientid : str + Tradeshift OAuth2 client ID. + oauth2clientsecret : str + Tradeshift OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + oauth2clientid: str = Field(..., alias='oauth2ClientId') + oauth2clientsecret: str = Field(..., alias='oauth2ClientSecret') diff --git a/appwrite/models/o_auth2_twitch.py b/appwrite/models/o_auth2_twitch.py new file mode 100644 index 00000000..2df093f3 --- /dev/null +++ b/appwrite/models/o_auth2_twitch.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Twitch(AppwriteModel): + """ + OAuth2Twitch + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Twitch OAuth2 client ID. + clientsecret : str + Twitch OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_word_press.py b/appwrite/models/o_auth2_word_press.py new file mode 100644 index 00000000..8c75dd23 --- /dev/null +++ b/appwrite/models/o_auth2_word_press.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2WordPress(AppwriteModel): + """ + OAuth2WordPress + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + WordPress OAuth2 client ID. + clientsecret : str + WordPress OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_x.py b/appwrite/models/o_auth2_x.py new file mode 100644 index 00000000..1cd5ea8d --- /dev/null +++ b/appwrite/models/o_auth2_x.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2X(AppwriteModel): + """ + OAuth2X + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + customerkey : str + X OAuth2 customer key. + secretkey : str + X OAuth2 secret key. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + customerkey: str = Field(..., alias='customerKey') + secretkey: str = Field(..., alias='secretKey') diff --git a/appwrite/models/o_auth2_yahoo.py b/appwrite/models/o_auth2_yahoo.py new file mode 100644 index 00000000..fbf734ca --- /dev/null +++ b/appwrite/models/o_auth2_yahoo.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Yahoo(AppwriteModel): + """ + OAuth2Yahoo + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Yahoo OAuth2 client ID. + clientsecret : str + Yahoo OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_yandex.py b/appwrite/models/o_auth2_yandex.py new file mode 100644 index 00000000..3945f62c --- /dev/null +++ b/appwrite/models/o_auth2_yandex.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Yandex(AppwriteModel): + """ + OAuth2Yandex + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Yandex OAuth2 client ID. + clientsecret : str + Yandex OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_zoho.py b/appwrite/models/o_auth2_zoho.py new file mode 100644 index 00000000..2e9119b5 --- /dev/null +++ b/appwrite/models/o_auth2_zoho.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Zoho(AppwriteModel): + """ + OAuth2Zoho + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Zoho OAuth2 client ID. + clientsecret : str + Zoho OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/o_auth2_zoom.py b/appwrite/models/o_auth2_zoom.py new file mode 100644 index 00000000..00f66594 --- /dev/null +++ b/appwrite/models/o_auth2_zoom.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class OAuth2Zoom(AppwriteModel): + """ + OAuth2Zoom + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Zoom OAuth2 client ID. + clientsecret : str + Zoom OAuth2 client secret. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret') diff --git a/appwrite/models/policy_list.py b/appwrite/models/policy_list.py new file mode 100644 index 00000000..bed74bcb --- /dev/null +++ b/appwrite/models/policy_list.py @@ -0,0 +1,27 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .policy_password_dictionary import PolicyPasswordDictionary +from .policy_password_history import PolicyPasswordHistory +from .policy_password_personal_data import PolicyPasswordPersonalData +from .policy_session_alert import PolicySessionAlert +from .policy_session_duration import PolicySessionDuration +from .policy_session_invalidation import PolicySessionInvalidation +from .policy_session_limit import PolicySessionLimit +from .policy_user_limit import PolicyUserLimit +from .policy_membership_privacy import PolicyMembershipPrivacy + +class PolicyList(AppwriteModel): + """ + Policies List + + Attributes + ---------- + total : float + Total number of policies in the given project. + policies : List[Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy]] + List of policies. + """ + total: float = Field(..., alias='total') + policies: List[Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy]] = Field(..., alias='policies') diff --git a/appwrite/models/policy_membership_privacy.py b/appwrite/models/policy_membership_privacy.py new file mode 100644 index 00000000..ca73ec98 --- /dev/null +++ b/appwrite/models/policy_membership_privacy.py @@ -0,0 +1,30 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class PolicyMembershipPrivacy(AppwriteModel): + """ + Policy Membership Privacy + + Attributes + ---------- + id : str + Policy ID. + userid : bool + Whether user ID is visible in memberships. + useremail : bool + Whether user email is visible in memberships. + userphone : bool + Whether user phone is visible in memberships. + username : bool + Whether user name is visible in memberships. + usermfa : bool + Whether user MFA status is visible in memberships. + """ + id: str = Field(..., alias='$id') + userid: bool = Field(..., alias='userId') + useremail: bool = Field(..., alias='userEmail') + userphone: bool = Field(..., alias='userPhone') + username: bool = Field(..., alias='userName') + usermfa: bool = Field(..., alias='userMFA') diff --git a/appwrite/models/policy_password_dictionary.py b/appwrite/models/policy_password_dictionary.py new file mode 100644 index 00000000..8a544cfd --- /dev/null +++ b/appwrite/models/policy_password_dictionary.py @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class PolicyPasswordDictionary(AppwriteModel): + """ + Policy Password Dictionary + + Attributes + ---------- + id : str + Policy ID. + enabled : bool + Whether password dictionary policy is enabled. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') diff --git a/appwrite/models/policy_password_history.py b/appwrite/models/policy_password_history.py new file mode 100644 index 00000000..76e0f182 --- /dev/null +++ b/appwrite/models/policy_password_history.py @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class PolicyPasswordHistory(AppwriteModel): + """ + Policy Password History + + Attributes + ---------- + id : str + Policy ID. + total : float + Password history length. A value of 0 means the policy is disabled. + """ + id: str = Field(..., alias='$id') + total: float = Field(..., alias='total') diff --git a/appwrite/models/policy_password_personal_data.py b/appwrite/models/policy_password_personal_data.py new file mode 100644 index 00000000..f3c6ee6c --- /dev/null +++ b/appwrite/models/policy_password_personal_data.py @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class PolicyPasswordPersonalData(AppwriteModel): + """ + Policy Password Personal Data + + Attributes + ---------- + id : str + Policy ID. + enabled : bool + Whether password personal data policy is enabled. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') diff --git a/appwrite/models/policy_session_alert.py b/appwrite/models/policy_session_alert.py new file mode 100644 index 00000000..368b8ed5 --- /dev/null +++ b/appwrite/models/policy_session_alert.py @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class PolicySessionAlert(AppwriteModel): + """ + Policy Session Alert + + Attributes + ---------- + id : str + Policy ID. + enabled : bool + Whether session alert policy is enabled. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') diff --git a/appwrite/models/policy_session_duration.py b/appwrite/models/policy_session_duration.py new file mode 100644 index 00000000..cc1adc0c --- /dev/null +++ b/appwrite/models/policy_session_duration.py @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class PolicySessionDuration(AppwriteModel): + """ + Policy Session Duration + + Attributes + ---------- + id : str + Policy ID. + duration : float + Session duration in seconds. + """ + id: str = Field(..., alias='$id') + duration: float = Field(..., alias='duration') diff --git a/appwrite/models/policy_session_invalidation.py b/appwrite/models/policy_session_invalidation.py new file mode 100644 index 00000000..0b5251bf --- /dev/null +++ b/appwrite/models/policy_session_invalidation.py @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class PolicySessionInvalidation(AppwriteModel): + """ + Policy Session Invalidation + + Attributes + ---------- + id : str + Policy ID. + enabled : bool + Whether session invalidation policy is enabled. + """ + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') diff --git a/appwrite/models/policy_session_limit.py b/appwrite/models/policy_session_limit.py new file mode 100644 index 00000000..b1d4b77b --- /dev/null +++ b/appwrite/models/policy_session_limit.py @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class PolicySessionLimit(AppwriteModel): + """ + Policy Session Limit + + Attributes + ---------- + id : str + Policy ID. + total : float + Maximum number of sessions allowed per user. A value of 0 means the policy is disabled. + """ + id: str = Field(..., alias='$id') + total: float = Field(..., alias='total') diff --git a/appwrite/models/policy_user_limit.py b/appwrite/models/policy_user_limit.py new file mode 100644 index 00000000..3a6df697 --- /dev/null +++ b/appwrite/models/policy_user_limit.py @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class PolicyUserLimit(AppwriteModel): + """ + Policy User Limit + + Attributes + ---------- + id : str + Policy ID. + total : float + Maximum number of users allowed in the project. A value of 0 means the policy is disabled. + """ + id: str = Field(..., alias='$id') + total: float = Field(..., alias='total') diff --git a/appwrite/models/presence.py b/appwrite/models/presence.py new file mode 100644 index 00000000..b0d42d72 --- /dev/null +++ b/appwrite/models/presence.py @@ -0,0 +1,74 @@ +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +T = TypeVar('T') + +class Presence(AppwriteModel, Generic[T]): + """ + Presence + + Attributes + ---------- + id : str + Presence ID. + sequence : str + Presence sequence ID. + createdat : str + Presence creation date in ISO 8601 format. + updatedat : str + Presence update date in ISO 8601 format. + permissions : List[Any] + Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + userinternalid : str + User internal ID. + userid : str + User ID. + status : Optional[str] + Presence status. + source : str + Presence source. + expiresat : Optional[str] + Presence expiry date in ISO 8601 format. + """ + id: str = Field(..., alias='$id') + sequence: str = Field(..., alias='$sequence') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + permissions: List[Any] = Field(..., alias='$permissions') + userinternalid: str = Field(..., alias='userInternalId') + userid: str = Field(..., alias='userId') + status: Optional[str] = Field(default=None, alias='status') + source: str = Field(..., alias='source') + expiresat: Optional[str] = Field(default=None, alias='expiresAt') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'Presence[T]': + """Create Presence 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/presence_list.py b/appwrite/models/presence_list.py new file mode 100644 index 00000000..516db718 --- /dev/null +++ b/appwrite/models/presence_list.py @@ -0,0 +1,32 @@ +from typing import Any, Dict, List, Optional, Union, cast, Generic, TypeVar, Type +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .presence import Presence + +T = TypeVar('T') + +class PresenceList(AppwriteModel, Generic[T]): + """ + Presences List + + Attributes + ---------- + total : float + Total number of presences that matched your query. + presences : List[Presence[T]] + List of presences. + """ + total: float = Field(..., alias='total') + presences: List[Presence[T]] = Field(..., alias='presences') + + @classmethod + def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'PresenceList[T]': + """Create PresenceList instance with typed data.""" + instance = cls.model_validate(data) + if 'presences' in data and data['presences'] is not None: + instance.presences = [ + Presence.with_data(row, model_type) + for row in data['presences'] + ] + return instance diff --git a/appwrite/models/project.py b/appwrite/models/project.py index 1228e6e9..c593ebdf 100644 --- a/appwrite/models/project.py +++ b/appwrite/models/project.py @@ -77,6 +77,10 @@ class Project(AppwriteModel): Whether or not to show user emails in the teams membership response. authmembershipsmfa : bool Whether or not to show user MFA status in the teams membership response. + authmembershipsuserid : bool + Whether or not to show user IDs in the teams membership response. + authmembershipsuserphone : bool + Whether or not to show user phone numbers in the teams membership response. authinvalidatesessions : bool Whether or not all existing sessions should be invalidated on password change oauthproviders : List[AuthProvider] @@ -95,7 +99,9 @@ class Project(AppwriteModel): SMTP sender name smtpsenderemail : str SMTP sender email - smtpreplyto : str + smtpreplytoname : str + SMTP reply to name + smtpreplytoemail : str SMTP reply to email smtphost : str SMTP server host name @@ -104,7 +110,7 @@ class Project(AppwriteModel): smtpusername : str SMTP server username smtppassword : str - SMTP server password + SMTP server password. This property is write-only and always returned empty. smtpsecure : str SMTP server secure protocol pingcount : float @@ -206,6 +212,8 @@ class Project(AppwriteModel): authmembershipsusername: bool = Field(..., alias='authMembershipsUserName') authmembershipsuseremail: bool = Field(..., alias='authMembershipsUserEmail') authmembershipsmfa: bool = Field(..., alias='authMembershipsMfa') + authmembershipsuserid: bool = Field(..., alias='authMembershipsUserId') + authmembershipsuserphone: bool = Field(..., alias='authMembershipsUserPhone') authinvalidatesessions: bool = Field(..., alias='authInvalidateSessions') oauthproviders: List[AuthProvider] = Field(..., alias='oAuthProviders') platforms: List[Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux]] = Field(..., alias='platforms') @@ -215,7 +223,8 @@ class Project(AppwriteModel): smtpenabled: bool = Field(..., alias='smtpEnabled') smtpsendername: str = Field(..., alias='smtpSenderName') smtpsenderemail: str = Field(..., alias='smtpSenderEmail') - smtpreplyto: str = Field(..., alias='smtpReplyTo') + smtpreplytoname: str = Field(..., alias='smtpReplyToName') + smtpreplytoemail: str = Field(..., alias='smtpReplyToEmail') smtphost: str = Field(..., alias='smtpHost') smtpport: float = Field(..., alias='smtpPort') smtpusername: str = Field(..., alias='smtpUsername') diff --git a/appwrite/models/proxy_rule.py b/appwrite/models/proxy_rule.py new file mode 100644 index 00000000..2154f849 --- /dev/null +++ b/appwrite/models/proxy_rule.py @@ -0,0 +1,59 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from ..enums.proxy_rule_deployment_resource_type import ProxyRuleDeploymentResourceType +from ..enums.proxy_rule_status import ProxyRuleStatus + +class ProxyRule(AppwriteModel): + """ + Rule + + Attributes + ---------- + id : str + Rule ID. + createdat : str + Rule creation date in ISO 8601 format. + updatedat : str + Rule update date in ISO 8601 format. + domain : str + Domain name. + type : str + Action definition for the rule. Possible values are "api", "deployment", or "redirect" + trigger : str + Defines how the rule was created. Possible values are "manual" or "deployment" + redirecturl : str + URL to redirect to. Used if type is "redirect" + redirectstatuscode : float + Status code to apply during redirect. Used if type is "redirect" + deploymentid : str + ID of deployment. Used if type is "deployment" + deploymentresourcetype : Optional[ProxyRuleDeploymentResourceType] + Type of deployment. Possible values are "function", "site". Used if rule's type is "deployment". + deploymentresourceid : str + ID of deployment's resource (site or function ID). Used if type is "deployment" + deploymentvcsproviderbranch : str + Name of Git branch that updates rule. Used if type is "deployment" + status : ProxyRuleStatus + Domain verification status. Possible values are "unverified", "verifying", "verified" + logs : str + Logs from rule verification or certificate generation. Certificate generation logs are prioritized if both are available. + renewat : str + Certificate auto-renewal date in ISO 8601 format. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + domain: str = Field(..., alias='domain') + type: str = Field(..., alias='type') + trigger: str = Field(..., alias='trigger') + redirecturl: str = Field(..., alias='redirectUrl') + redirectstatuscode: float = Field(..., alias='redirectStatusCode') + deploymentid: str = Field(..., alias='deploymentId') + deploymentresourcetype: Optional[ProxyRuleDeploymentResourceType] = Field(default=None, alias='deploymentResourceType') + deploymentresourceid: str = Field(..., alias='deploymentResourceId') + deploymentvcsproviderbranch: str = Field(..., alias='deploymentVcsProviderBranch') + status: ProxyRuleStatus = Field(..., alias='status') + logs: str = Field(..., alias='logs') + renewat: str = Field(..., alias='renewAt') diff --git a/appwrite/models/proxy_rule_list.py b/appwrite/models/proxy_rule_list.py new file mode 100644 index 00000000..ce500c2a --- /dev/null +++ b/appwrite/models/proxy_rule_list.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .proxy_rule import ProxyRule + +class ProxyRuleList(AppwriteModel): + """ + Rule List + + Attributes + ---------- + total : float + Total number of rules that matched your query. + rules : List[ProxyRule] + List of rules. + """ + total: float = Field(..., alias='total') + rules: List[ProxyRule] = Field(..., alias='rules') diff --git a/appwrite/models/table.py b/appwrite/models/table.py index 50759f99..de5f21e0 100644 --- a/appwrite/models/table.py +++ b/appwrite/models/table.py @@ -3,6 +3,7 @@ from .base_model import AppwriteModel from .column_boolean import ColumnBoolean +from .column_bigint import ColumnBigint from .column_integer import ColumnInteger from .column_float import ColumnFloat from .column_email import ColumnEmail @@ -43,7 +44,7 @@ class Table(AppwriteModel): 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]] + columns : List[Union[ColumnBoolean, ColumnBigint, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString]] Table columns. indexes : List[ColumnIndex] Table indexes. @@ -60,7 +61,7 @@ class Table(AppwriteModel): 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') + columns: List[Union[ColumnBoolean, ColumnBigint, 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/services/account.py b/appwrite/services/account.py index 4499c0dc..0e80be8e 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -1535,7 +1535,7 @@ def create_o_auth2_token( Parameters ---------- provider : OAuthProvider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. success : Optional[str] URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. failure : Optional[str] diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 22769df1..a1a458d3 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -9,6 +9,7 @@ from ..models.collection_list import CollectionList; from ..models.collection import Collection; from ..models.attribute_list import AttributeList; +from ..models.attribute_bigint import AttributeBigint; from ..models.attribute_boolean import AttributeBoolean; from ..models.attribute_datetime import AttributeDatetime; from ..models.attribute_email import AttributeEmail; @@ -871,6 +872,165 @@ def list_attributes( return self._parse_response(response, model=AttributeList) + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_big_int_column` instead.") + def create_big_int_attribute( + 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 + ) -> AttributeBigint: + """ + Create a bigint attribute. Optionally, minimum and maximum values can be provided. + + + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.create_big_int_column` instead. + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + key : str + Attribute Key. + required : bool + Is attribute required? + min : Optional[float] + Minimum value + max : Optional[float] + Maximum value + default : Optional[float] + Default value. Cannot be set when attribute is required. + array : Optional[bool] + Is attribute an array? + + Returns + ------- + AttributeBigint + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + 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'] = 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'] = self._normalize_value(array) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=AttributeBigint) + + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_big_int_column` instead.") + def update_big_int_attribute( + 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 + ) -> AttributeBigint: + """ + Update a bigint attribute. Changing the `default` value will not update already existing documents. + + + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.update_big_int_column` instead. + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + key : str + Attribute Key. + required : bool + Is attribute required? + default : Optional[float] + Default value. Cannot be set when attribute is required. + min : Optional[float] + Minimum value + max : Optional[float] + Maximum value + new_key : Optional[str] + New Attribute Key. + + Returns + ------- + AttributeBigint + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + 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'] = 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) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=AttributeBigint) + + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_boolean_column` instead.") def create_boolean_attribute( self, diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index 5023a180..34f7efee 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -1216,7 +1216,9 @@ def delete_execution( def list_variables( self, - function_id: str + function_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> VariableList: """ Get a list of all variables of a specific function. @@ -1225,6 +1227,10 @@ def list_variables( ---------- function_id : str Function unique ID. + 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. You may filter on the following attributes: key, resourceType, resourceId, secret + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. Returns ------- @@ -1244,6 +1250,10 @@ def list_variables( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) response = self.client.call('get', api_path, { }, api_params) @@ -1254,6 +1264,7 @@ def list_variables( def create_variable( self, function_id: str, + variable_id: str, key: str, value: str, secret: Optional[bool] = None @@ -1265,6 +1276,8 @@ def create_variable( ---------- function_id : str Function unique ID. + variable_id : str + Variable 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. key : str Variable key. Max length: 255 chars. value : str @@ -1288,6 +1301,9 @@ def create_variable( if function_id is None: raise AppwriteException('Missing required parameter: "function_id"') + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + if key is None: raise AppwriteException('Missing required parameter: "key"') @@ -1296,6 +1312,7 @@ def create_variable( api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) + api_params['variableId'] = self._normalize_value(variable_id) api_params['key'] = self._normalize_value(key) api_params['value'] = self._normalize_value(value) if secret is not None: @@ -1356,7 +1373,7 @@ def update_variable( self, function_id: str, variable_id: str, - key: str, + key: Optional[str] = None, value: Optional[str] = None, secret: Optional[bool] = None ) -> Variable: @@ -1369,7 +1386,7 @@ def update_variable( Function unique ID. variable_id : str Variable unique ID. - key : str + key : Optional[str] Variable key. Max length: 255 chars. value : Optional[str] Variable value. Max length: 8192 chars. @@ -1395,9 +1412,6 @@ def update_variable( if variable_id is None: raise AppwriteException('Missing required parameter: "variable_id"') - if key is None: - raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{functionId}', str(self._normalize_value(function_id))) api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) diff --git a/appwrite/services/presences.py b/appwrite/services/presences.py new file mode 100644 index 00000000..aafc347d --- /dev/null +++ b/appwrite/services/presences.py @@ -0,0 +1,274 @@ +from ..service import Service +from typing import Any, Dict, List, Optional, Union, Type, TypeVar +from ..exception import AppwriteException +from appwrite.utils.deprecated import deprecated +from ..models.presence_list import PresenceList; +from ..models.presence import Presence; + +T = TypeVar('T') + +class Presences(Service): + + def __init__(self, client) -> None: + super(Presences, self).__init__(client) + + def list( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None, + ttl: Optional[float] = None, + model_type: Type[T] = dict + ) -> PresenceList[T]: + """ + List presence logs. + + Parameters + ---------- + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + ttl : Optional[float] + TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. 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 + ------- + PresenceList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/presences' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + if ttl is not None: + api_params['ttl'] = self._normalize_value(ttl) + + response = self.client.call('get', api_path, { + }, api_params) + + return PresenceList.with_data(response, model_type) + + + def get( + self, + presence_id: str, + model_type: Type[T] = dict + ) -> Presence[T]: + """ + Get a presence log by its unique ID. + + Parameters + ---------- + presence_id : str + Presence unique ID. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Presence[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/presences/{presenceId}' + api_params = {} + if presence_id is None: + raise AppwriteException('Missing required parameter: "presence_id"') + + api_path = api_path.replace('{presenceId}', str(self._normalize_value(presence_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return Presence.with_data(response, model_type) + + + def upsert( + self, + presence_id: str, + user_id: Optional[str], + status: str, + permissions: Optional[List[str]] = None, + expires_at: Optional[str] = None, + metadata: Optional[Dict[str, Any]] = None, + model_type: Type[T] = dict + ) -> Presence[T]: + """ + Create or update a presence log by its unique ID. + + Parameters + ---------- + presence_id : str + Presence unique ID. + user_id : Optional[str] + User ID. + status : str + Presence status. + 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). + expires_at : Optional[str] + Presence expiry datetime. + metadata : Optional[Dict[str, Any]] + Presence metadata object. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Presence[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/presences/{presenceId}' + api_params = {} + if presence_id is None: + raise AppwriteException('Missing required parameter: "presence_id"') + + if status is None: + raise AppwriteException('Missing required parameter: "status"') + + api_path = api_path.replace('{presenceId}', str(self._normalize_value(presence_id))) + + api_params['userId'] = self._normalize_value(user_id) + api_params['status'] = self._normalize_value(status) + api_params['permissions'] = self._normalize_value(permissions) + api_params['expiresAt'] = self._normalize_value(expires_at) + if metadata is not None: + api_params['metadata'] = self._normalize_value(metadata) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Presence.with_data(response, model_type) + + + def update_presence( + self, + presence_id: str, + user_id: Optional[str], + status: Optional[str] = None, + expires_at: Optional[str] = None, + metadata: Optional[Dict[str, Any]] = None, + permissions: Optional[List[str]] = None, + purge: Optional[bool] = None, + model_type: Type[T] = dict + ) -> Presence[T]: + """ + Update a presence log by its unique ID. + + Parameters + ---------- + presence_id : str + Presence unique ID. + user_id : Optional[str] + User ID. + status : Optional[str] + Presence status. + expires_at : Optional[str] + Presence expiry datetime. + metadata : Optional[Dict[str, Any]] + Presence metadata 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). + purge : Optional[bool] + When true, purge cached responses used by list presences endpoint. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Presence[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/presences/{presenceId}' + api_params = {} + if presence_id is None: + raise AppwriteException('Missing required parameter: "presence_id"') + + api_path = api_path.replace('{presenceId}', str(self._normalize_value(presence_id))) + + api_params['userId'] = self._normalize_value(user_id) + api_params['status'] = self._normalize_value(status) + api_params['expiresAt'] = self._normalize_value(expires_at) + api_params['metadata'] = self._normalize_value(metadata) + api_params['permissions'] = self._normalize_value(permissions) + if purge is not None: + api_params['purge'] = self._normalize_value(purge) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Presence.with_data(response, model_type) + + + def delete( + self, + presence_id: str + ) -> Dict[str, Any]: + """ + Delete a presence log by its unique ID. + + Parameters + ---------- + presence_id : str + Presence unique ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/presences/{presenceId}' + api_params = {} + if presence_id is None: + raise AppwriteException('Missing required parameter: "presence_id"') + + api_path = api_path.replace('{presenceId}', str(self._normalize_value(presence_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + diff --git a/appwrite/services/project.py b/appwrite/services/project.py index 822ad15a..5b3da51a 100644 --- a/appwrite/services/project.py +++ b/appwrite/services/project.py @@ -2,18 +2,80 @@ from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..enums.method_id import MethodId; +from ..models.project import Project as ProjectModel; from ..models.key_list import KeyList; from ..enums.scopes import Scopes; from ..models.key import Key; -from ..models.project import Project as ProjectModel; +from ..models.ephemeral_key import EphemeralKey; +from ..models.mock_number_list import MockNumberList; +from ..models.mock_number import MockNumber; +from ..models.o_auth2_provider_list import OAuth2ProviderList; +from ..enums.provider_id import ProviderId; +from ..models.o_auth2_github import OAuth2Github; +from ..models.o_auth2_discord import OAuth2Discord; +from ..models.o_auth2_figma import OAuth2Figma; +from ..models.o_auth2_dropbox import OAuth2Dropbox; +from ..models.o_auth2_dailymotion import OAuth2Dailymotion; +from ..models.o_auth2_bitbucket import OAuth2Bitbucket; +from ..models.o_auth2_bitly import OAuth2Bitly; +from ..models.o_auth2_box import OAuth2Box; +from ..models.o_auth2_autodesk import OAuth2Autodesk; +from ..models.o_auth2_google import OAuth2Google; +from ..models.o_auth2_zoom import OAuth2Zoom; +from ..models.o_auth2_zoho import OAuth2Zoho; +from ..models.o_auth2_yandex import OAuth2Yandex; +from ..models.o_auth2_x import OAuth2X; +from ..models.o_auth2_word_press import OAuth2WordPress; +from ..models.o_auth2_twitch import OAuth2Twitch; +from ..models.o_auth2_stripe import OAuth2Stripe; +from ..models.o_auth2_spotify import OAuth2Spotify; +from ..models.o_auth2_slack import OAuth2Slack; +from ..models.o_auth2_podio import OAuth2Podio; +from ..models.o_auth2_notion import OAuth2Notion; +from ..models.o_auth2_salesforce import OAuth2Salesforce; +from ..models.o_auth2_yahoo import OAuth2Yahoo; +from ..models.o_auth2_linkedin import OAuth2Linkedin; +from ..models.o_auth2_disqus import OAuth2Disqus; +from ..models.o_auth2_amazon import OAuth2Amazon; +from ..models.o_auth2_etsy import OAuth2Etsy; +from ..models.o_auth2_facebook import OAuth2Facebook; +from ..models.o_auth2_tradeshift import OAuth2Tradeshift; +from ..models.o_auth2_paypal import OAuth2Paypal; +from ..models.o_auth2_gitlab import OAuth2Gitlab; +from ..models.o_auth2_authentik import OAuth2Authentik; +from ..models.o_auth2_auth0 import OAuth2Auth0; +from ..models.o_auth2_fusion_auth import OAuth2FusionAuth; +from ..models.o_auth2_keycloak import OAuth2Keycloak; +from ..models.o_auth2_oidc import OAuth2Oidc; +from ..models.o_auth2_apple import OAuth2Apple; +from ..models.o_auth2_okta import OAuth2Okta; +from ..models.o_auth2_kick import OAuth2Kick; +from ..models.o_auth2_microsoft import OAuth2Microsoft; from ..models.platform_list import PlatformList; from ..models.platform_android import PlatformAndroid; from ..models.platform_apple import PlatformApple; from ..models.platform_linux import PlatformLinux; from ..models.platform_web import PlatformWeb; from ..models.platform_windows import PlatformWindows; +from ..models.policy_list import PolicyList; +from ..enums.policy_id import PolicyId; +from ..models.policy_password_dictionary import PolicyPasswordDictionary; +from ..models.policy_password_history import PolicyPasswordHistory; +from ..models.policy_password_personal_data import PolicyPasswordPersonalData; +from ..models.policy_session_alert import PolicySessionAlert; +from ..models.policy_session_duration import PolicySessionDuration; +from ..models.policy_session_invalidation import PolicySessionInvalidation; +from ..models.policy_session_limit import PolicySessionLimit; +from ..models.policy_user_limit import PolicyUserLimit; +from ..models.policy_membership_privacy import PolicyMembershipPrivacy; from ..enums.protocol_id import ProtocolId; from ..enums.service_id import ServiceId; +from ..enums.secure import Secure; +from ..models.email_template_list import EmailTemplateList; +from ..enums.email_template_type import EmailTemplateType; +from ..enums.email_template_locale import EmailTemplateLocale; +from ..models.email_template import EmailTemplate; from ..models.variable_list import VariableList; from ..models.variable import Variable; @@ -22,6 +84,78 @@ class Project(Service): def __init__(self, client) -> None: super(Project, self).__init__(client) + def delete( + self + ) -> Dict[str, Any]: + """ + Delete a project. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project' + api_params = {} + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def update_auth_method( + self, + method_id: MethodId, + enabled: bool + ) -> ProjectModel: + """ + Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. + + Parameters + ---------- + method_id : MethodId + Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + enabled : bool + Auth method status. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/auth-methods/{methodId}' + api_params = {} + if method_id is None: + raise AppwriteException('Missing required parameter: "method_id"') + + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') + + api_path = api_path.replace('{methodId}', str(self._normalize_value(method_id))) + + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + def list_keys( self, queries: Optional[List[str]] = None, @@ -71,6 +205,8 @@ def create_key( ) -> Key: """ Create a new API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + + You can also create an ephemeral API key if you need a short-lived key instead. Parameters ---------- @@ -118,6 +254,53 @@ def create_key( return self._parse_response(response, model=Key) + def create_ephemeral_key( + self, + scopes: List[Scopes], + duration: float + ) -> EphemeralKey: + """ + Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + + You can also create a standard API key if you need a longer-lived key instead. + + Parameters + ---------- + scopes : List[Scopes] + Key scopes list. Maximum of 100 scopes are allowed. + duration : float + Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + + Returns + ------- + EphemeralKey + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/keys/ephemeral' + api_params = {} + if scopes is None: + raise AppwriteException('Missing required parameter: "scopes"') + + if duration is None: + raise AppwriteException('Missing required parameter: "duration"') + + + api_params['scopes'] = self._normalize_value(scopes) + api_params['duration'] = self._normalize_value(duration) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=EphemeralKey) + + def get_key( self, key_id: str @@ -287,24 +470,24 @@ def update_labels( return self._parse_response(response, model=ProjectModel) - def list_platforms( + def list_mock_phones( self, queries: Optional[List[str]] = None, total: Optional[bool] = None - ) -> PlatformList: + ) -> MockNumberList: """ - Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. + Get a list of all mock phones in the project. This endpoint returns an array of all mock phones and their OTPs. Parameters ---------- 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. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset total : Optional[bool] When set to false, the total count returned will be 0 and will not be calculated. Returns ------- - PlatformList + MockNumberList API response as a typed Pydantic model Raises @@ -313,7 +496,7 @@ def list_platforms( If API request fails """ - api_path = '/project/platforms' + api_path = '/project/mock-phones' api_params = {} if queries is not None: @@ -324,30 +507,27 @@ def list_platforms( response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=PlatformList) + return self._parse_response(response, model=MockNumberList) - def create_android_platform( + def create_mock_phone( self, - platform_id: str, - name: str, - application_id: str - ) -> PlatformAndroid: + number: str, + otp: str + ) -> MockNumber: """ - Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. + Create a new mock phone for your project. Use this endpoint to register a mock phone number and its sign-in OTP for your testers. Parameters ---------- - platform_id : str - Platform 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 - Platform name. Max length: 128 chars. - application_id : str - Android application ID. Max length: 256 chars. + number : str + Phone number to associate with the mock phone. Must be a valid E.164 formatted phone number. + otp : str + One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. Returns ------- - PlatformAndroid + MockNumber API response as a typed Pydantic model Raises @@ -356,50 +536,40 @@ def create_android_platform( If API request fails """ - api_path = '/project/platforms/android' + api_path = '/project/mock-phones' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') + if number is None: + raise AppwriteException('Missing required parameter: "number"') - if application_id is None: - raise AppwriteException('Missing required parameter: "application_id"') + if otp is None: + raise AppwriteException('Missing required parameter: "otp"') - api_params['platformId'] = self._normalize_value(platform_id) - api_params['name'] = self._normalize_value(name) - api_params['applicationId'] = self._normalize_value(application_id) + api_params['number'] = self._normalize_value(number) + api_params['otp'] = self._normalize_value(otp) response = self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=PlatformAndroid) + return self._parse_response(response, model=MockNumber) - def update_android_platform( + def get_mock_phone( self, - platform_id: str, - name: str, - application_id: str - ) -> PlatformAndroid: + number: str + ) -> MockNumber: """ - Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + Get a mock phone by its unique number. This endpoint returns the mock phone's OTP. Parameters ---------- - platform_id : str - Platform ID. - name : str - Platform name. Max length: 128 chars. - application_id : str - Android application ID. Max length: 256 chars. + number : str + Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. Returns ------- - PlatformAndroid + MockNumber API response as a typed Pydantic model Raises @@ -408,50 +578,38 @@ def update_android_platform( If API request fails """ - api_path = '/project/platforms/android/{platformId}' + api_path = '/project/mock-phones/{number}' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') - - if application_id is None: - raise AppwriteException('Missing required parameter: "application_id"') + if number is None: + raise AppwriteException('Missing required parameter: "number"') - api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + api_path = api_path.replace('{number}', str(self._normalize_value(number))) - api_params['name'] = self._normalize_value(name) - api_params['applicationId'] = self._normalize_value(application_id) - response = self.client.call('put', api_path, { - 'content-type': 'application/json', + response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=PlatformAndroid) + return self._parse_response(response, model=MockNumber) - def create_apple_platform( + def update_mock_phone( self, - platform_id: str, - name: str, - bundle_identifier: str - ) -> PlatformApple: + number: str, + otp: str + ) -> MockNumber: """ - Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. + Update a mock phone by its unique number. Use this endpoint to update the mock phone's OTP. Parameters ---------- - platform_id : str - Platform 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 - Platform name. Max length: 128 chars. - bundle_identifier : str - Apple bundle identifier. Max length: 256 chars. + number : str + Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. + otp : str + One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. Returns ------- - PlatformApple + MockNumber API response as a typed Pydantic model Raises @@ -460,51 +618,41 @@ def create_apple_platform( If API request fails """ - api_path = '/project/platforms/apple' + api_path = '/project/mock-phones/{number}' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') + if number is None: + raise AppwriteException('Missing required parameter: "number"') - if name is None: - raise AppwriteException('Missing required parameter: "name"') - - if bundle_identifier is None: - raise AppwriteException('Missing required parameter: "bundle_identifier"') + if otp is None: + raise AppwriteException('Missing required parameter: "otp"') + api_path = api_path.replace('{number}', str(self._normalize_value(number))) - api_params['platformId'] = self._normalize_value(platform_id) - api_params['name'] = self._normalize_value(name) - api_params['bundleIdentifier'] = self._normalize_value(bundle_identifier) + api_params['otp'] = self._normalize_value(otp) - response = self.client.call('post', api_path, { + response = self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=PlatformApple) + return self._parse_response(response, model=MockNumber) - def update_apple_platform( + def delete_mock_phone( self, - platform_id: str, - name: str, - bundle_identifier: str - ) -> PlatformApple: + number: str + ) -> Dict[str, Any]: """ - Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. + Delete a mock phone by its unique number. This endpoint removes the mock phone and its OTP configuration from the project. Parameters ---------- - platform_id : str - Platform ID. - name : str - Platform name. Max length: 128 chars. - bundle_identifier : str - Apple bundle identifier. Max length: 256 chars. + number : str + Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. Returns ------- - PlatformApple - API response as a typed Pydantic model + Dict[str, Any] + API response as a dictionary Raises ------ @@ -512,50 +660,39 @@ def update_apple_platform( If API request fails """ - api_path = '/project/platforms/apple/{platformId}' + api_path = '/project/mock-phones/{number}' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') - - if bundle_identifier is None: - raise AppwriteException('Missing required parameter: "bundle_identifier"') + if number is None: + raise AppwriteException('Missing required parameter: "number"') - api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + api_path = api_path.replace('{number}', str(self._normalize_value(number))) - api_params['name'] = self._normalize_value(name) - api_params['bundleIdentifier'] = self._normalize_value(bundle_identifier) - response = self.client.call('put', api_path, { + response = self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=PlatformApple) + return response - def create_linux_platform( + def list_o_auth2_providers( self, - platform_id: str, - name: str, - package_name: str - ) -> PlatformLinux: + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> OAuth2ProviderList: """ - Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. + Get a list of all OAuth2 providers supported by the server, along with the project's configuration for each. Credential fields are write-only and always returned empty. Parameters ---------- - platform_id : str - Platform 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 - Platform name. Max length: 128 chars. - package_name : str - Linux package name. Max length: 256 chars. + 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). Only supported methods are limit and offset + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. Returns ------- - PlatformLinux + OAuth2ProviderList API response as a typed Pydantic model Raises @@ -564,50 +701,2808 @@ def create_linux_platform( If API request fails """ - api_path = '/project/platforms/linux' + api_path = '/project/oauth2' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') - if package_name is None: - raise AppwriteException('Missing required parameter: "package_name"') - - - api_params['platformId'] = self._normalize_value(platform_id) - api_params['name'] = self._normalize_value(name) - api_params['packageName'] = self._normalize_value(package_name) + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) - response = self.client.call('post', api_path, { - 'content-type': 'application/json', + response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=PlatformLinux) + return self._parse_response(response, model=OAuth2ProviderList) - def update_linux_platform( + def get_o_auth2_provider( + self, + provider_id: ProviderId + ) -> Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft]: + """ + Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. + + Parameters + ---------- + provider_id : ProviderId + OAuth2 provider key. For example: github, google, apple. + + Returns + ------- + Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft] + API response as one of the typed response models + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/:provider' + api_params = {} + if provider_id is None: + raise AppwriteException('Missing required parameter: "provider_id"') + + + api_params['providerId'] = self._normalize_value(provider_id) + + response = self.client.call('get', api_path, { + }, api_params) + if not isinstance(response, dict): + raise AppwriteException('Expected object response when hydrating a response model') + + if response.get('$id') == 'github': + return self._parse_response(response, model=OAuth2Github) + + if response.get('$id') == 'discord': + return self._parse_response(response, model=OAuth2Discord) + + if response.get('$id') == 'figma': + return self._parse_response(response, model=OAuth2Figma) + + if response.get('$id') == 'dropbox': + return self._parse_response(response, model=OAuth2Dropbox) + + if response.get('$id') == 'dailymotion': + return self._parse_response(response, model=OAuth2Dailymotion) + + if response.get('$id') == 'bitbucket': + return self._parse_response(response, model=OAuth2Bitbucket) + + if response.get('$id') == 'bitly': + return self._parse_response(response, model=OAuth2Bitly) + + if response.get('$id') == 'box': + return self._parse_response(response, model=OAuth2Box) + + if response.get('$id') == 'autodesk': + return self._parse_response(response, model=OAuth2Autodesk) + + if response.get('$id') == 'google': + return self._parse_response(response, model=OAuth2Google) + + if response.get('$id') == 'zoom': + return self._parse_response(response, model=OAuth2Zoom) + + if response.get('$id') == 'zoho': + return self._parse_response(response, model=OAuth2Zoho) + + if response.get('$id') == 'yandex': + return self._parse_response(response, model=OAuth2Yandex) + + if response.get('$id') == 'x': + return self._parse_response(response, model=OAuth2X) + + if response.get('$id') == 'wordpress': + return self._parse_response(response, model=OAuth2WordPress) + + if response.get('$id') == 'twitch': + return self._parse_response(response, model=OAuth2Twitch) + + if response.get('$id') == 'stripe': + return self._parse_response(response, model=OAuth2Stripe) + + if response.get('$id') == 'spotify': + return self._parse_response(response, model=OAuth2Spotify) + + if response.get('$id') == 'slack': + return self._parse_response(response, model=OAuth2Slack) + + if response.get('$id') == 'podio': + return self._parse_response(response, model=OAuth2Podio) + + if response.get('$id') == 'notion': + return self._parse_response(response, model=OAuth2Notion) + + if response.get('$id') == 'salesforce': + return self._parse_response(response, model=OAuth2Salesforce) + + if response.get('$id') == 'yahoo': + return self._parse_response(response, model=OAuth2Yahoo) + + if response.get('$id') == 'linkedin': + return self._parse_response(response, model=OAuth2Linkedin) + + if response.get('$id') == 'disqus': + return self._parse_response(response, model=OAuth2Disqus) + + if response.get('$id') == 'amazon': + return self._parse_response(response, model=OAuth2Amazon) + + if response.get('$id') == 'etsy': + return self._parse_response(response, model=OAuth2Etsy) + + if response.get('$id') == 'facebook': + return self._parse_response(response, model=OAuth2Facebook) + + if response.get('$id') == 'tradeshiftBox': + return self._parse_response(response, model=OAuth2Tradeshift) + + if response.get('$id') == 'paypalSandbox': + return self._parse_response(response, model=OAuth2Paypal) + + if response.get('$id') == 'gitlab': + return self._parse_response(response, model=OAuth2Gitlab) + + if response.get('$id') == 'authentik': + return self._parse_response(response, model=OAuth2Authentik) + + if response.get('$id') == 'auth0': + return self._parse_response(response, model=OAuth2Auth0) + + if response.get('$id') == 'fusionauth': + return self._parse_response(response, model=OAuth2FusionAuth) + + if response.get('$id') == 'keycloak': + return self._parse_response(response, model=OAuth2Keycloak) + + if response.get('$id') == 'oidc': + return self._parse_response(response, model=OAuth2Oidc) + + if response.get('$id') == 'apple': + return self._parse_response(response, model=OAuth2Apple) + + if response.get('$id') == 'okta': + return self._parse_response(response, model=OAuth2Okta) + + if response.get('$id') == 'kick': + return self._parse_response(response, model=OAuth2Kick) + + if response.get('$id') == 'microsoft': + return self._parse_response(response, model=OAuth2Microsoft) + + raise AppwriteException('Unable to match response to any known model') + + + def update_o_auth2_amazon( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Amazon: + """ + Update the project OAuth2 Amazon configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + client_secret : Optional[str] + 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Amazon + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/amazon' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Amazon) + + + def update_o_auth2_apple( + self, + service_id: Optional[str] = None, + key_id: Optional[str] = None, + team_id: Optional[str] = None, + p8_file: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Apple: + """ + Update the project OAuth2 Apple configuration. + + Parameters + ---------- + service_id : Optional[str] + 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + key_id : Optional[str] + 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + team_id : Optional[str] + 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + p8_file : Optional[str] + Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Apple + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/apple' + api_params = {} + + api_params['serviceId'] = self._normalize_value(service_id) + api_params['keyId'] = self._normalize_value(key_id) + api_params['teamId'] = self._normalize_value(team_id) + api_params['p8File'] = self._normalize_value(p8_file) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Apple) + + + def update_o_auth2_auth0( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + endpoint: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Auth0: + """ + Update the project OAuth2 Auth0 configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + client_secret : Optional[str] + 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + endpoint : Optional[str] + Domain of Auth0 instance. For example: example.us.auth0.com + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Auth0 + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/auth0' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['endpoint'] = self._normalize_value(endpoint) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Auth0) + + + def update_o_auth2_authentik( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + endpoint: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Authentik: + """ + Update the project OAuth2 Authentik configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + client_secret : Optional[str] + 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + endpoint : Optional[str] + Domain of Authentik instance. For example: example.authentik.com + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Authentik + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/authentik' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['endpoint'] = self._normalize_value(endpoint) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Authentik) + + + def update_o_auth2_autodesk( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Autodesk: + """ + Update the project OAuth2 Autodesk configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + client_secret : Optional[str] + 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Autodesk + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/autodesk' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Autodesk) + + + def update_o_auth2_bitbucket( + self, + key: Optional[str] = None, + secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Bitbucket: + """ + Update the project OAuth2 Bitbucket configuration. + + Parameters + ---------- + key : Optional[str] + 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + secret : Optional[str] + 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Bitbucket + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/bitbucket' + api_params = {} + + api_params['key'] = self._normalize_value(key) + api_params['secret'] = self._normalize_value(secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Bitbucket) + + + def update_o_auth2_bitly( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Bitly: + """ + Update the project OAuth2 Bitly configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + client_secret : Optional[str] + 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Bitly + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/bitly' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Bitly) + + + def update_o_auth2_box( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Box: + """ + Update the project OAuth2 Box configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + client_secret : Optional[str] + 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Box + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/box' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Box) + + + def update_o_auth2_dailymotion( + self, + api_key: Optional[str] = None, + api_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Dailymotion: + """ + Update the project OAuth2 Dailymotion configuration. + + Parameters + ---------- + api_key : Optional[str] + 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + api_secret : Optional[str] + 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Dailymotion + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/dailymotion' + api_params = {} + + api_params['apiKey'] = self._normalize_value(api_key) + api_params['apiSecret'] = self._normalize_value(api_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Dailymotion) + + + def update_o_auth2_discord( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Discord: + """ + Update the project OAuth2 Discord configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + client_secret : Optional[str] + 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Discord + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/discord' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Discord) + + + def update_o_auth2_disqus( + self, + public_key: Optional[str] = None, + secret_key: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Disqus: + """ + Update the project OAuth2 Disqus configuration. + + Parameters + ---------- + public_key : Optional[str] + 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + secret_key : Optional[str] + 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Disqus + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/disqus' + api_params = {} + + api_params['publicKey'] = self._normalize_value(public_key) + api_params['secretKey'] = self._normalize_value(secret_key) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Disqus) + + + def update_o_auth2_dropbox( + self, + app_key: Optional[str] = None, + app_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Dropbox: + """ + Update the project OAuth2 Dropbox configuration. + + Parameters + ---------- + app_key : Optional[str] + 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + app_secret : Optional[str] + 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Dropbox + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/dropbox' + api_params = {} + + api_params['appKey'] = self._normalize_value(app_key) + api_params['appSecret'] = self._normalize_value(app_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Dropbox) + + + def update_o_auth2_etsy( + self, + key_string: Optional[str] = None, + shared_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Etsy: + """ + Update the project OAuth2 Etsy configuration. + + Parameters + ---------- + key_string : Optional[str] + 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + shared_secret : Optional[str] + 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Etsy + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/etsy' + api_params = {} + + api_params['keyString'] = self._normalize_value(key_string) + api_params['sharedSecret'] = self._normalize_value(shared_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Etsy) + + + def update_o_auth2_facebook( + self, + app_id: Optional[str] = None, + app_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Facebook: + """ + Update the project OAuth2 Facebook configuration. + + Parameters + ---------- + app_id : Optional[str] + 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + app_secret : Optional[str] + 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Facebook + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/facebook' + api_params = {} + + api_params['appId'] = self._normalize_value(app_id) + api_params['appSecret'] = self._normalize_value(app_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Facebook) + + + def update_o_auth2_figma( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Figma: + """ + Update the project OAuth2 Figma configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + client_secret : Optional[str] + 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Figma + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/figma' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Figma) + + + def update_o_auth2_fusion_auth( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + endpoint: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2FusionAuth: + """ + Update the project OAuth2 FusionAuth configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + client_secret : Optional[str] + 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + endpoint : Optional[str] + Domain of FusionAuth instance. For example: example.fusionauth.io + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2FusionAuth + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/fusionauth' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['endpoint'] = self._normalize_value(endpoint) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2FusionAuth) + + + def update_o_auth2_git_hub( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Github: + """ + Update the project OAuth2 GitHub configuration. + + Parameters + ---------- + client_id : Optional[str] + 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + client_secret : Optional[str] + 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Github + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/github' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Github) + + + def update_o_auth2_gitlab( + self, + application_id: Optional[str] = None, + secret: Optional[str] = None, + endpoint: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Gitlab: + """ + Update the project OAuth2 Gitlab configuration. + + Parameters + ---------- + application_id : Optional[str] + 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + secret : Optional[str] + 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + endpoint : Optional[str] + Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Gitlab + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/gitlab' + api_params = {} + + api_params['applicationId'] = self._normalize_value(application_id) + api_params['secret'] = self._normalize_value(secret) + api_params['endpoint'] = self._normalize_value(endpoint) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Gitlab) + + + def update_o_auth2_google( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Google: + """ + Update the project OAuth2 Google configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Google OAuth2 app. For example: your-google-client-id.apps.googleusercontent.com + client_secret : Optional[str] + 'Client Secret' of Google OAuth2 app. For example: your-google-client-secret + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Google + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/google' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Google) + + + def update_o_auth2_keycloak( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + endpoint: Optional[str] = None, + realm_name: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Keycloak: + """ + Update the project OAuth2 Keycloak configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + client_secret : Optional[str] + 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + endpoint : Optional[str] + Domain of Keycloak instance. For example: keycloak.example.com + realm_name : Optional[str] + Keycloak realm name. For example: appwrite-realm + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Keycloak + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/keycloak' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['endpoint'] = self._normalize_value(endpoint) + api_params['realmName'] = self._normalize_value(realm_name) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Keycloak) + + + def update_o_auth2_kick( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Kick: + """ + Update the project OAuth2 Kick configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + client_secret : Optional[str] + 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Kick + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/kick' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Kick) + + + def update_o_auth2_linkedin( + self, + client_id: Optional[str] = None, + primary_client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Linkedin: + """ + Update the project OAuth2 Linkedin configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + primary_client_secret : Optional[str] + 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: your-linkedin-client-secret + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Linkedin + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/linkedin' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['primaryClientSecret'] = self._normalize_value(primary_client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Linkedin) + + + def update_o_auth2_microsoft( + self, + application_id: Optional[str] = None, + application_secret: Optional[str] = None, + tenant: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Microsoft: + """ + Update the project OAuth2 Microsoft configuration. + + Parameters + ---------- + application_id : Optional[str] + 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + application_secret : Optional[str] + 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + tenant : Optional[str] + Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Microsoft + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/microsoft' + api_params = {} + + api_params['applicationId'] = self._normalize_value(application_id) + api_params['applicationSecret'] = self._normalize_value(application_secret) + api_params['tenant'] = self._normalize_value(tenant) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Microsoft) + + + def update_o_auth2_notion( + self, + oauth_client_id: Optional[str] = None, + oauth_client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Notion: + """ + Update the project OAuth2 Notion configuration. + + Parameters + ---------- + oauth_client_id : Optional[str] + 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + oauth_client_secret : Optional[str] + 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Notion + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/notion' + api_params = {} + + api_params['oauthClientId'] = self._normalize_value(oauth_client_id) + api_params['oauthClientSecret'] = self._normalize_value(oauth_client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Notion) + + + def update_o_auth2_oidc( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + well_known_url: Optional[str] = None, + authorization_url: Optional[str] = None, + token_url: Optional[str] = None, + user_info_url: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Oidc: + """ + Update the project OAuth2 Oidc configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + client_secret : Optional[str] + 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + well_known_url : Optional[str] + OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + authorization_url : Optional[str] + OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + token_url : Optional[str] + OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + user_info_url : Optional[str] + OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Oidc + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/oidc' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['wellKnownURL'] = self._normalize_value(well_known_url) + api_params['authorizationURL'] = self._normalize_value(authorization_url) + api_params['tokenURL'] = self._normalize_value(token_url) + api_params['userInfoURL'] = self._normalize_value(user_info_url) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Oidc) + + + def update_o_auth2_okta( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + domain: Optional[str] = None, + authorization_server_id: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Okta: + """ + Update the project OAuth2 Okta configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + client_secret : Optional[str] + 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + domain : Optional[str] + Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + authorization_server_id : Optional[str] + Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Okta + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/okta' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['domain'] = self._normalize_value(domain) + api_params['authorizationServerId'] = self._normalize_value(authorization_server_id) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Okta) + + + def update_o_auth2_paypal( + self, + client_id: Optional[str] = None, + secret_key: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Paypal: + """ + Update the project OAuth2 Paypal configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + secret_key : Optional[str] + 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Paypal + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/paypal' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['secretKey'] = self._normalize_value(secret_key) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Paypal) + + + def update_o_auth2_paypal_sandbox( + self, + client_id: Optional[str] = None, + secret_key: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Paypal: + """ + Update the project OAuth2 PaypalSandbox configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + secret_key : Optional[str] + 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Paypal + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/paypalSandbox' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['secretKey'] = self._normalize_value(secret_key) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Paypal) + + + def update_o_auth2_podio( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Podio: + """ + Update the project OAuth2 Podio configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + client_secret : Optional[str] + 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Podio + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/podio' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Podio) + + + def update_o_auth2_salesforce( + self, + customer_key: Optional[str] = None, + customer_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Salesforce: + """ + Update the project OAuth2 Salesforce configuration. + + Parameters + ---------- + customer_key : Optional[str] + 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + customer_secret : Optional[str] + 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Salesforce + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/salesforce' + api_params = {} + + api_params['customerKey'] = self._normalize_value(customer_key) + api_params['customerSecret'] = self._normalize_value(customer_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Salesforce) + + + def update_o_auth2_slack( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Slack: + """ + Update the project OAuth2 Slack configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + client_secret : Optional[str] + 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Slack + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/slack' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Slack) + + + def update_o_auth2_spotify( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Spotify: + """ + Update the project OAuth2 Spotify configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + client_secret : Optional[str] + 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Spotify + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/spotify' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Spotify) + + + def update_o_auth2_stripe( + self, + client_id: Optional[str] = None, + api_secret_key: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Stripe: + """ + Update the project OAuth2 Stripe configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + api_secret_key : Optional[str] + 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Stripe + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/stripe' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['apiSecretKey'] = self._normalize_value(api_secret_key) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Stripe) + + + def update_o_auth2_tradeshift( + self, + oauth2_client_id: Optional[str] = None, + oauth2_client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Tradeshift: + """ + Update the project OAuth2 Tradeshift configuration. + + Parameters + ---------- + oauth2_client_id : Optional[str] + 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + oauth2_client_secret : Optional[str] + 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Tradeshift + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/tradeshift' + api_params = {} + + api_params['oauth2ClientId'] = self._normalize_value(oauth2_client_id) + api_params['oauth2ClientSecret'] = self._normalize_value(oauth2_client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Tradeshift) + + + def update_o_auth2_tradeshift_sandbox( + self, + oauth2_client_id: Optional[str] = None, + oauth2_client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Tradeshift: + """ + Update the project OAuth2 Tradeshift Sandbox configuration. + + Parameters + ---------- + oauth2_client_id : Optional[str] + 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + oauth2_client_secret : Optional[str] + 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Tradeshift + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/tradeshiftBox' + api_params = {} + + api_params['oauth2ClientId'] = self._normalize_value(oauth2_client_id) + api_params['oauth2ClientSecret'] = self._normalize_value(oauth2_client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Tradeshift) + + + def update_o_auth2_twitch( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Twitch: + """ + Update the project OAuth2 Twitch configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + client_secret : Optional[str] + 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Twitch + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/twitch' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Twitch) + + + def update_o_auth2_word_press( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2WordPress: + """ + Update the project OAuth2 WordPress configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of WordPress OAuth2 app. For example: 130005 + client_secret : Optional[str] + 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2WordPress + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/wordpress' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2WordPress) + + + def update_o_auth2_x( + self, + customer_key: Optional[str] = None, + secret_key: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2X: + """ + Update the project OAuth2 X configuration. + + Parameters + ---------- + customer_key : Optional[str] + 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + secret_key : Optional[str] + 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2X + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/x' + api_params = {} + + api_params['customerKey'] = self._normalize_value(customer_key) + api_params['secretKey'] = self._normalize_value(secret_key) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2X) + + + def update_o_auth2_yahoo( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Yahoo: + """ + Update the project OAuth2 Yahoo configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + client_secret : Optional[str] + 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Yahoo + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/yahoo' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Yahoo) + + + def update_o_auth2_yandex( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Yandex: + """ + Update the project OAuth2 Yandex configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + client_secret : Optional[str] + 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Yandex + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/yandex' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Yandex) + + + def update_o_auth2_zoho( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Zoho: + """ + Update the project OAuth2 Zoho configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + client_secret : Optional[str] + 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Zoho + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/zoho' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Zoho) + + + def update_o_auth2_zoom( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None + ) -> OAuth2Zoom: + """ + Update the project OAuth2 Zoom configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + client_secret : Optional[str] + 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + + Returns + ------- + OAuth2Zoom + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/zoom' + api_params = {} + + api_params['clientId'] = self._normalize_value(client_id) + api_params['clientSecret'] = self._normalize_value(client_secret) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=OAuth2Zoom) + + + def list_platforms( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> PlatformList: + """ + Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. + + Parameters + ---------- + 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. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + PlatformList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=PlatformList) + + + def create_android_platform( + self, + platform_id: str, + name: str, + application_id: str + ) -> PlatformAndroid: + """ + Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform 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 + Platform name. Max length: 128 chars. + application_id : str + Android application ID. Max length: 256 chars. + + Returns + ------- + PlatformAndroid + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/android' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if application_id is None: + raise AppwriteException('Missing required parameter: "application_id"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['applicationId'] = self._normalize_value(application_id) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformAndroid) + + + def update_android_platform( + self, + platform_id: str, + name: str, + application_id: str + ) -> PlatformAndroid: + """ + Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + application_id : str + Android application ID. Max length: 256 chars. + + Returns + ------- + PlatformAndroid + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/android/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if application_id is None: + raise AppwriteException('Missing required parameter: "application_id"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['applicationId'] = self._normalize_value(application_id) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformAndroid) + + + def create_apple_platform( + self, + platform_id: str, + name: str, + bundle_identifier: str + ) -> PlatformApple: + """ + Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform 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 + Platform name. Max length: 128 chars. + bundle_identifier : str + Apple bundle identifier. Max length: 256 chars. + + Returns + ------- + PlatformApple + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/apple' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if bundle_identifier is None: + raise AppwriteException('Missing required parameter: "bundle_identifier"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['bundleIdentifier'] = self._normalize_value(bundle_identifier) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformApple) + + + def update_apple_platform( + self, + platform_id: str, + name: str, + bundle_identifier: str + ) -> PlatformApple: + """ + Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + bundle_identifier : str + Apple bundle identifier. Max length: 256 chars. + + Returns + ------- + PlatformApple + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/apple/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if bundle_identifier is None: + raise AppwriteException('Missing required parameter: "bundle_identifier"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['bundleIdentifier'] = self._normalize_value(bundle_identifier) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformApple) + + + def create_linux_platform( + self, + platform_id: str, + name: str, + package_name: str + ) -> PlatformLinux: + """ + Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform 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 + Platform name. Max length: 128 chars. + package_name : str + Linux package name. Max length: 256 chars. + + Returns + ------- + PlatformLinux + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/linux' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if package_name is None: + raise AppwriteException('Missing required parameter: "package_name"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['packageName'] = self._normalize_value(package_name) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformLinux) + + + def update_linux_platform( + self, + platform_id: str, + name: str, + package_name: str + ) -> PlatformLinux: + """ + Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + package_name : str + Linux package name. Max length: 256 chars. + + Returns + ------- + PlatformLinux + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/linux/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if package_name is None: + raise AppwriteException('Missing required parameter: "package_name"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['packageName'] = self._normalize_value(package_name) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformLinux) + + + def create_web_platform( + self, + platform_id: str, + name: str, + hostname: str + ) -> PlatformWeb: + """ + Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform 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 + Platform name. Max length: 128 chars. + hostname : str + Platform web hostname. Max length: 256 chars. + + Returns + ------- + PlatformWeb + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/web' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if hostname is None: + raise AppwriteException('Missing required parameter: "hostname"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['hostname'] = self._normalize_value(hostname) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformWeb) + + + def update_web_platform( + self, + platform_id: str, + name: str, + hostname: str + ) -> PlatformWeb: + """ + Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + hostname : str + Platform web hostname. Max length: 256 chars. + + Returns + ------- + PlatformWeb + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/web/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if hostname is None: + raise AppwriteException('Missing required parameter: "hostname"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['hostname'] = self._normalize_value(hostname) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformWeb) + + + def create_windows_platform( self, platform_id: str, name: str, - package_name: str - ) -> PlatformLinux: + package_identifier_name: str + ) -> PlatformWindows: + """ + Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform 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 + Platform name. Max length: 128 chars. + package_identifier_name : str + Windows package identifier name. Max length: 256 chars. + + Returns + ------- + PlatformWindows + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/windows' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if package_identifier_name is None: + raise AppwriteException('Missing required parameter: "package_identifier_name"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['packageIdentifierName'] = self._normalize_value(package_identifier_name) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformWindows) + + + def update_windows_platform( + self, + platform_id: str, + name: str, + package_identifier_name: str + ) -> PlatformWindows: + """ + Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + package_identifier_name : str + Windows package identifier name. Max length: 256 chars. + + Returns + ------- + PlatformWindows + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/windows/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if package_identifier_name is None: + raise AppwriteException('Missing required parameter: "package_identifier_name"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['packageIdentifierName'] = self._normalize_value(package_identifier_name) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformWindows) + + + def get_platform( + self, + platform_id: str + ) -> Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux]: + """ + Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. + + Parameters + ---------- + platform_id : str + Platform ID. + + Returns + ------- + Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux] + API response as one of the typed response models + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + if not isinstance(response, dict): + raise AppwriteException('Expected object response when hydrating a response model') + + if response.get('type') == 'web': + return self._parse_response(response, model=PlatformWeb) + + if response.get('type') == 'apple': + return self._parse_response(response, model=PlatformApple) + + if response.get('type') == 'android': + return self._parse_response(response, model=PlatformAndroid) + + if response.get('type') == 'windows': + return self._parse_response(response, model=PlatformWindows) + + if response.get('type') == 'linux': + return self._parse_response(response, model=PlatformLinux) + + raise AppwriteException('Unable to match response to any known model') + + + def delete_platform( + self, + platform_id: str + ) -> Dict[str, Any]: + """ + Delete a platform by its unique ID. This endpoint removes the platform and all its configurations from the project. + + Parameters + ---------- + platform_id : str + Platform ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def list_policies( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> PolicyList: + """ + Get a list of all project policies and their current configuration. + + Parameters + ---------- + 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). Only supported methods are limit and offset + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + PolicyList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/policies' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=PolicyList) + + + def update_membership_privacy_policy( + self, + user_id: Optional[bool] = None, + user_email: Optional[bool] = None, + user_phone: Optional[bool] = None, + user_name: Optional[bool] = None, + user_mfa: Optional[bool] = None + ) -> ProjectModel: + """ + Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. + + Parameters + ---------- + user_id : Optional[bool] + Set to true if you want make user ID visible to all team members, or false to hide it. + user_email : Optional[bool] + Set to true if you want make user email visible to all team members, or false to hide it. + user_phone : Optional[bool] + Set to true if you want make user phone number visible to all team members, or false to hide it. + user_name : Optional[bool] + Set to true if you want make user name visible to all team members, or false to hide it. + user_mfa : Optional[bool] + Set to true if you want make user MFA status visible to all team members, or false to hide it. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/policies/membership-privacy' + api_params = {} + + if user_id is not None: + api_params['userId'] = self._normalize_value(user_id) + if user_email is not None: + api_params['userEmail'] = self._normalize_value(user_email) + if user_phone is not None: + api_params['userPhone'] = self._normalize_value(user_phone) + if user_name is not None: + api_params['userName'] = self._normalize_value(user_name) + if user_mfa is not None: + api_params['userMFA'] = self._normalize_value(user_mfa) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + + def update_password_dictionary_policy( + self, + enabled: bool + ) -> ProjectModel: """ - Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. + Updating this policy allows you to control if new passwords are checked against most common passwords dictionary. When enabled, and user changes their password, password must not be contained in the dictionary. Parameters ---------- - platform_id : str - Platform ID. - name : str - Platform name. Max length: 128 chars. - package_name : str - Linux package name. Max length: 256 chars. + enabled : bool + Toggle password dictionary policy. Set to true if you want password change to block passwords in the dictionary, or false to allow them. When changing this policy, existing passwords remain valid. Returns ------- - PlatformLinux + ProjectModel API response as a typed Pydantic model Raises @@ -616,51 +3511,296 @@ def update_linux_platform( If API request fails """ - api_path = '/project/platforms/linux/{platformId}' + api_path = '/project/policies/password-dictionary' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') - if name is None: - raise AppwriteException('Missing required parameter: "name"') - if package_name is None: - raise AppwriteException('Missing required parameter: "package_name"') + api_params['enabled'] = self._normalize_value(enabled) - api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) - api_params['name'] = self._normalize_value(name) - api_params['packageName'] = self._normalize_value(package_name) + return self._parse_response(response, model=ProjectModel) - response = self.client.call('put', api_path, { + + def update_password_history_policy( + self, + total: Optional[float] + ) -> ProjectModel: + """ + Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. + + Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. + + Parameters + ---------- + total : Optional[float] + Set the password history length per user. Value can be between 1 and 5000, or null to disable the limit. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/policies/password-history' + api_params = {} + + api_params['total'] = self._normalize_value(total) + + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=PlatformLinux) + return self._parse_response(response, model=ProjectModel) - def create_web_platform( + def update_password_personal_data_policy( + self, + enabled: bool + ) -> ProjectModel: + """ + Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. + + Parameters + ---------- + enabled : bool + Toggle password personal data policy. Set to true if you want to block passwords including user's personal data, or false to allow it. When changing this policy, existing passwords remain valid. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/policies/password-personal-data' + api_params = {} + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') + + + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + + def update_session_alert_policy( + self, + enabled: bool + ) -> ProjectModel: + """ + Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. + + Parameters + ---------- + enabled : bool + Toggle session alert policy. Set to true if you want users to receive email notifications when a sessions are created for their users, or false to not send email alerts. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/policies/session-alert' + api_params = {} + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') + + + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + + def update_session_duration_policy( + self, + duration: float + ) -> ProjectModel: + """ + Update maximum duration how long sessions created within a project should stay active for. + + Parameters + ---------- + duration : float + Maximum session length in seconds. Minium allowed value is 5 second, and maximum is 1 year, which is 31536000 seconds. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/policies/session-duration' + api_params = {} + if duration is None: + raise AppwriteException('Missing required parameter: "duration"') + + + api_params['duration'] = self._normalize_value(duration) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + + def update_session_invalidation_policy( + self, + enabled: bool + ) -> ProjectModel: + """ + Updating this policy allows you to control if existing sessions should be invalidated when a password of a user is changed. When enabled, and user changes their password, they will be logged out of all their devices. + + Parameters + ---------- + enabled : bool + Toggle session invalidation policy. Set to true if you want password change to invalidate all sessions of an user, or false to keep sessions active. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/policies/session-invalidation' + api_params = {} + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') + + + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + + def update_session_limit_policy( + self, + total: Optional[float] + ) -> ProjectModel: + """ + Update the maximum number of sessions allowed per user. When the limit is hit, the oldest session will be deleted to make room for new one. + + Parameters + ---------- + total : Optional[float] + Set the maximum number of sessions allowed per user. Value can be between 1 and 5000, or null to disable the limit. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/policies/session-limit' + api_params = {} + + api_params['total'] = self._normalize_value(total) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + + def update_user_limit_policy( + self, + total: Optional[float] + ) -> ProjectModel: + """ + Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. + + Parameters + ---------- + total : Optional[float] + Set the maximum number of users allowed in the project. Value can be between 1 and 5000, or null to disable the limit. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/policies/user-limit' + api_params = {} + + api_params['total'] = self._normalize_value(total) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + + def get_policy( self, - platform_id: str, - name: str, - hostname: str - ) -> PlatformWeb: + policy_id: PolicyId + ) -> Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy]: """ - Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. + Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. Parameters ---------- - platform_id : str - Platform 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 - Platform name. Max length: 128 chars. - hostname : str - Platform web hostname. Max length: 256 chars. + policy_id : PolicyId + Policy ID. Can be one of: password-dictionary, password-history, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy. Returns ------- - PlatformWeb - API response as a typed Pydantic model + Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy] + API response as one of the typed response models Raises ------ @@ -668,50 +3808,67 @@ def create_web_platform( If API request fails """ - api_path = '/project/platforms/web' + api_path = '/project/policies/{policyId}' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') + if policy_id is None: + raise AppwriteException('Missing required parameter: "policy_id"') - if name is None: - raise AppwriteException('Missing required parameter: "name"') + api_path = api_path.replace('{policyId}', str(self._normalize_value(policy_id))) - if hostname is None: - raise AppwriteException('Missing required parameter: "hostname"') + response = self.client.call('get', api_path, { + }, api_params) + if not isinstance(response, dict): + raise AppwriteException('Expected object response when hydrating a response model') - api_params['platformId'] = self._normalize_value(platform_id) - api_params['name'] = self._normalize_value(name) - api_params['hostname'] = self._normalize_value(hostname) + if response.get('$id') == 'password-dictionary': + return self._parse_response(response, model=PolicyPasswordDictionary) - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) + if response.get('$id') == 'password-history': + return self._parse_response(response, model=PolicyPasswordHistory) - return self._parse_response(response, model=PlatformWeb) + if response.get('$id') == 'password-personal-data': + return self._parse_response(response, model=PolicyPasswordPersonalData) + if response.get('$id') == 'session-alert': + return self._parse_response(response, model=PolicySessionAlert) - def update_web_platform( + if response.get('$id') == 'session-duration': + return self._parse_response(response, model=PolicySessionDuration) + + if response.get('$id') == 'session-invalidation': + return self._parse_response(response, model=PolicySessionInvalidation) + + if response.get('$id') == 'session-limit': + return self._parse_response(response, model=PolicySessionLimit) + + if response.get('$id') == 'user-limit': + return self._parse_response(response, model=PolicyUserLimit) + + if response.get('$id') == 'membership-privacy': + return self._parse_response(response, model=PolicyMembershipPrivacy) + + raise AppwriteException('Unable to match response to any known model') + + + def update_protocol( self, - platform_id: str, - name: str, - hostname: str - ) -> PlatformWeb: + protocol_id: ProtocolId, + enabled: bool + ) -> ProjectModel: """ - Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. + Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. Parameters ---------- - platform_id : str - Platform ID. - name : str - Platform name. Max length: 128 chars. - hostname : str - Platform web hostname. Max length: 256 chars. + protocol_id : ProtocolId + Protocol name. Can be one of: rest, graphql, websocket + enabled : bool + Protocol status. Returns ------- - PlatformWeb + ProjectModel API response as a typed Pydantic model Raises @@ -720,50 +3877,43 @@ def update_web_platform( If API request fails """ - api_path = '/project/platforms/web/{platformId}' + api_path = '/project/protocols/{protocolId}' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') + if protocol_id is None: + raise AppwriteException('Missing required parameter: "protocol_id"') - if hostname is None: - raise AppwriteException('Missing required parameter: "hostname"') + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') - api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + api_path = api_path.replace('{protocolId}', str(self._normalize_value(protocol_id))) - api_params['name'] = self._normalize_value(name) - api_params['hostname'] = self._normalize_value(hostname) + api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call('put', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=PlatformWeb) + return self._parse_response(response, model=ProjectModel) - def create_windows_platform( + def update_service( self, - platform_id: str, - name: str, - package_identifier_name: str - ) -> PlatformWindows: + service_id: ServiceId, + enabled: bool + ) -> ProjectModel: """ - Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. + Update properties of a specific service. Use this endpoint to enable or disable a service in your project. Parameters ---------- - platform_id : str - Platform 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 - Platform name. Max length: 128 chars. - package_identifier_name : str - Windows package identifier name. Max length: 256 chars. + service_id : ServiceId + Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging + enabled : bool + Service status. Returns ------- - PlatformWindows + ProjectModel API response as a typed Pydantic model Raises @@ -772,50 +3922,67 @@ def create_windows_platform( If API request fails """ - api_path = '/project/platforms/windows' + api_path = '/project/services/{serviceId}' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') + if service_id is None: + raise AppwriteException('Missing required parameter: "service_id"') - if package_identifier_name is None: - raise AppwriteException('Missing required parameter: "package_identifier_name"') + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') + api_path = api_path.replace('{serviceId}', str(self._normalize_value(service_id))) - api_params['platformId'] = self._normalize_value(platform_id) - api_params['name'] = self._normalize_value(name) - api_params['packageIdentifierName'] = self._normalize_value(package_identifier_name) + api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call('post', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=PlatformWindows) + return self._parse_response(response, model=ProjectModel) - def update_windows_platform( + def update_smtp( self, - platform_id: str, - name: str, - package_identifier_name: str - ) -> PlatformWindows: + host: Optional[str] = None, + port: Optional[float] = None, + username: Optional[str] = None, + password: Optional[str] = None, + sender_email: Optional[str] = None, + sender_name: Optional[str] = None, + reply_to_email: Optional[str] = None, + reply_to_name: Optional[str] = None, + secure: Optional[Secure] = None, + enabled: Optional[bool] = None + ) -> ProjectModel: """ - Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. + Update the SMTP configuration for your project. Use this endpoint to configure your project's SMTP provider with your custom settings for sending transactional emails. Parameters ---------- - platform_id : str - Platform ID. - name : str - Platform name. Max length: 128 chars. - package_identifier_name : str - Windows package identifier name. Max length: 256 chars. + host : Optional[str] + SMTP server hostname (domain) + port : Optional[float] + SMTP server port + username : Optional[str] + SMTP server username. Leave empty for no authorization. + password : Optional[str] + SMTP server password. Leave empty for no authorization. This property is stored securely and cannot be read in future (write-only). + sender_email : Optional[str] + Email address shown in inbox as the sender of the email. + sender_name : Optional[str] + Name shown in inbox as the sender of the email. + reply_to_email : Optional[str] + Email used when user replies to the email. + reply_to_name : Optional[str] + Name used when user replies to the email. + secure : Optional[Secure] + Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + enabled : Optional[bool] + Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. Returns ------- - PlatformWindows + ProjectModel API response as a typed Pydantic model Raises @@ -824,45 +3991,43 @@ def update_windows_platform( If API request fails """ - api_path = '/project/platforms/windows/{platformId}' + api_path = '/project/smtp' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') - - if package_identifier_name is None: - raise AppwriteException('Missing required parameter: "package_identifier_name"') - api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) - - api_params['name'] = self._normalize_value(name) - api_params['packageIdentifierName'] = self._normalize_value(package_identifier_name) + api_params['host'] = self._normalize_value(host) + api_params['port'] = self._normalize_value(port) + api_params['username'] = self._normalize_value(username) + api_params['password'] = self._normalize_value(password) + api_params['senderEmail'] = self._normalize_value(sender_email) + api_params['senderName'] = self._normalize_value(sender_name) + api_params['replyToEmail'] = self._normalize_value(reply_to_email) + api_params['replyToName'] = self._normalize_value(reply_to_name) + api_params['secure'] = self._normalize_value(secure) + api_params['enabled'] = self._normalize_value(enabled) - response = self.client.call('put', api_path, { + response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=PlatformWindows) + return self._parse_response(response, model=ProjectModel) - def get_platform( + def create_smtp_test( self, - platform_id: str - ) -> Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux]: + emails: List[str] + ) -> Dict[str, Any]: """ - Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. + Send a test email to verify SMTP configuration. Parameters ---------- - platform_id : str - Platform ID. + emails : List[str] + Array of emails to send test email to. Maximum of 10 emails are allowed. Returns ------- - Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux] - API response as one of the typed response models + Dict[str, Any] + API response as a dictionary Raises ------ @@ -870,53 +4035,40 @@ def get_platform( If API request fails """ - api_path = '/project/platforms/{platformId}' + api_path = '/project/smtp/tests' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') + if emails is None: + raise AppwriteException('Missing required parameter: "emails"') - api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + api_params['emails'] = self._normalize_value(emails) - response = self.client.call('get', api_path, { + response = self.client.call('post', api_path, { + 'content-type': 'application/json', }, api_params) - if not isinstance(response, dict): - raise AppwriteException('Expected object response when hydrating a response model') - - if response.get('type') == 'web': - return self._parse_response(response, model=PlatformWeb) - - if response.get('type') == 'apple': - return self._parse_response(response, model=PlatformApple) - - if response.get('type') == 'android': - return self._parse_response(response, model=PlatformAndroid) - - if response.get('type') == 'windows': - return self._parse_response(response, model=PlatformWindows) - - if response.get('type') == 'linux': - return self._parse_response(response, model=PlatformLinux) - raise AppwriteException('Unable to match response to any known model') + return response - def delete_platform( + def list_email_templates( self, - platform_id: str - ) -> Dict[str, Any]: + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> EmailTemplateList: """ - Delete a platform by its unique ID. This endpoint removes the platform and all its configurations from the project. + Get a list of all custom email templates configured for the project. This endpoint returns an array of all configured email templates and their locales. Parameters ---------- - platform_id : str - Platform ID. + 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). Only supported methods are limit and offset + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. Returns ------- - Dict[str, Any] - API response as a dictionary + EmailTemplateList + API response as a typed Pydantic model Raises ------ @@ -924,39 +4076,56 @@ def delete_platform( If API request fails """ - api_path = '/project/platforms/{platformId}' + api_path = '/project/templates/email' api_params = {} - if platform_id is None: - raise AppwriteException('Missing required parameter: "platform_id"') - - api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', + response = self.client.call('get', api_path, { }, api_params) - return response + return self._parse_response(response, model=EmailTemplateList) - def update_protocol_status( + def update_email_template( self, - protocol_id: ProtocolId, - enabled: bool - ) -> ProjectModel: + template_id: EmailTemplateType, + locale: Optional[EmailTemplateLocale] = None, + subject: Optional[str] = None, + message: Optional[str] = None, + sender_name: Optional[str] = None, + sender_email: Optional[str] = None, + reply_to_email: Optional[str] = None, + reply_to_name: Optional[str] = None + ) -> EmailTemplate: """ - Update the status of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. Parameters ---------- - protocol_id : ProtocolId - Protocol name. Can be one of: rest, graphql, websocket - enabled : bool - Protocol status. + template_id : EmailTemplateType + Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + locale : Optional[EmailTemplateLocale] + Custom email template locale. If left empty, the fallback locale (en) will be used. + subject : Optional[str] + Subject of the email template. Can be up to 255 characters. + message : Optional[str] + Plain or HTML body of the email template message. Can be up to 10MB of content. + sender_name : Optional[str] + Name of the email sender. + sender_email : Optional[str] + Email of the sender. + reply_to_email : Optional[str] + Reply to email. + reply_to_name : Optional[str] + Reply to name. Returns ------- - ProjectModel + EmailTemplate API response as a typed Pydantic model Raises @@ -965,43 +4134,47 @@ def update_protocol_status( If API request fails """ - api_path = '/project/protocols/{protocolId}/status' + api_path = '/project/templates/email' api_params = {} - if protocol_id is None: - raise AppwriteException('Missing required parameter: "protocol_id"') - - if enabled is None: - raise AppwriteException('Missing required parameter: "enabled"') + if template_id is None: + raise AppwriteException('Missing required parameter: "template_id"') - api_path = api_path.replace('{protocolId}', str(self._normalize_value(protocol_id))) - api_params['enabled'] = self._normalize_value(enabled) + api_params['templateId'] = self._normalize_value(template_id) + if locale is not None: + api_params['locale'] = self._normalize_value(locale) + api_params['subject'] = self._normalize_value(subject) + api_params['message'] = self._normalize_value(message) + api_params['senderName'] = self._normalize_value(sender_name) + api_params['senderEmail'] = self._normalize_value(sender_email) + api_params['replyToEmail'] = self._normalize_value(reply_to_email) + api_params['replyToName'] = self._normalize_value(reply_to_name) response = self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - return self._parse_response(response, model=ProjectModel) + return self._parse_response(response, model=EmailTemplate) - def update_service_status( + def get_email_template( self, - service_id: ServiceId, - enabled: bool - ) -> ProjectModel: + template_id: EmailTemplateType, + locale: Optional[EmailTemplateLocale] = None + ) -> EmailTemplate: """ - Update the status of a specific service. Use this endpoint to enable or disable a service in your project. + Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. Parameters ---------- - service_id : ServiceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging - enabled : bool - Service status. + template_id : EmailTemplateType + Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + locale : Optional[EmailTemplateLocale] + Custom email template locale. If left empty, the fallback locale (en) will be used. Returns ------- - ProjectModel + EmailTemplate API response as a typed Pydantic model Raises @@ -1010,23 +4183,20 @@ def update_service_status( If API request fails """ - api_path = '/project/services/{serviceId}/status' + api_path = '/project/templates/email/{templateId}' api_params = {} - if service_id is None: - raise AppwriteException('Missing required parameter: "service_id"') - - if enabled is None: - raise AppwriteException('Missing required parameter: "enabled"') + if template_id is None: + raise AppwriteException('Missing required parameter: "template_id"') - api_path = api_path.replace('{serviceId}', str(self._normalize_value(service_id))) + api_path = api_path.replace('{templateId}', str(self._normalize_value(template_id))) - api_params['enabled'] = self._normalize_value(enabled) + if locale is not None: + api_params['locale'] = self._normalize_value(locale) - response = self.client.call('patch', api_path, { - 'content-type': 'application/json', + response = self.client.call('get', api_path, { }, api_params) - return self._parse_response(response, model=ProjectModel) + return self._parse_response(response, model=EmailTemplate) def list_variables( @@ -1082,7 +4252,7 @@ def create_variable( Parameters ---------- variable_id : str - Variable 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. + Variable unique 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. key : str Variable key. Max length: 255 chars. value : str @@ -1136,7 +4306,7 @@ def get_variable( Parameters ---------- variable_id : str - Variable ID. + Variable unique ID. Returns ------- @@ -1176,7 +4346,7 @@ def update_variable( Parameters ---------- variable_id : str - Variable ID. + Variable unique ID. key : Optional[str] Variable key. Max length: 255 chars. value : Optional[str] @@ -1223,7 +4393,7 @@ def delete_variable( Parameters ---------- variable_id : str - Variable ID. + Variable unique ID. Returns ------- diff --git a/appwrite/services/proxy.py b/appwrite/services/proxy.py new file mode 100644 index 00000000..fdbb869a --- /dev/null +++ b/appwrite/services/proxy.py @@ -0,0 +1,378 @@ +from ..service import Service +from typing import Any, Dict, List, Optional, Union +from ..exception import AppwriteException +from appwrite.utils.deprecated import deprecated +from ..models.proxy_rule_list import ProxyRuleList; +from ..models.proxy_rule import ProxyRule; +from ..enums.status_code import StatusCode; +from ..enums.proxy_resource_type import ProxyResourceType; + +class Proxy(Service): + + def __init__(self, client) -> None: + super(Proxy, self).__init__(client) + + def list_rules( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> ProxyRuleList: + """ + Get a list of all the proxy rules. You can use the query params to filter your results. + + Parameters + ---------- + 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + ProxyRuleList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/proxy/rules' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=ProxyRuleList) + + + def create_api_rule( + self, + domain: str + ) -> ProxyRule: + """ + Create a new proxy rule for serving Appwrite's API on custom domain. + + Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + + Parameters + ---------- + domain : str + Domain name. + + Returns + ------- + ProxyRule + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/proxy/rules/api' + api_params = {} + if domain is None: + raise AppwriteException('Missing required parameter: "domain"') + + + api_params['domain'] = self._normalize_value(domain) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProxyRule) + + + def create_function_rule( + self, + domain: str, + function_id: str, + branch: Optional[str] = None + ) -> ProxyRule: + """ + Create a new proxy rule for executing Appwrite Function on custom domain. + + Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + + Parameters + ---------- + domain : str + Domain name. + function_id : str + ID of function to be executed. + branch : Optional[str] + Name of VCS branch to deploy changes automatically + + Returns + ------- + ProxyRule + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/proxy/rules/function' + api_params = {} + if domain is None: + raise AppwriteException('Missing required parameter: "domain"') + + if function_id is None: + raise AppwriteException('Missing required parameter: "function_id"') + + + api_params['domain'] = self._normalize_value(domain) + api_params['functionId'] = self._normalize_value(function_id) + if branch is not None: + api_params['branch'] = self._normalize_value(branch) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProxyRule) + + + def create_redirect_rule( + self, + domain: str, + url: str, + status_code: StatusCode, + resource_id: str, + resource_type: ProxyResourceType + ) -> ProxyRule: + """ + Create a new proxy rule for to redirect from custom domain to another domain. + + Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + + Parameters + ---------- + domain : str + Domain name. + url : str + Target URL of redirection + status_code : StatusCode + Status code of redirection + resource_id : str + ID of parent resource. + resource_type : ProxyResourceType + Type of parent resource. + + Returns + ------- + ProxyRule + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/proxy/rules/redirect' + api_params = {} + if domain is None: + raise AppwriteException('Missing required parameter: "domain"') + + if url is None: + raise AppwriteException('Missing required parameter: "url"') + + if status_code is None: + raise AppwriteException('Missing required parameter: "status_code"') + + if resource_id is None: + raise AppwriteException('Missing required parameter: "resource_id"') + + if resource_type is None: + raise AppwriteException('Missing required parameter: "resource_type"') + + + api_params['domain'] = self._normalize_value(domain) + api_params['url'] = self._normalize_value(url) + api_params['statusCode'] = self._normalize_value(status_code) + api_params['resourceId'] = self._normalize_value(resource_id) + api_params['resourceType'] = self._normalize_value(resource_type) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProxyRule) + + + def create_site_rule( + self, + domain: str, + site_id: str, + branch: Optional[str] = None + ) -> ProxyRule: + """ + Create a new proxy rule for serving Appwrite Site on custom domain. + + Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + + Parameters + ---------- + domain : str + Domain name. + site_id : str + ID of site to be executed. + branch : Optional[str] + Name of VCS branch to deploy changes automatically + + Returns + ------- + ProxyRule + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/proxy/rules/site' + api_params = {} + if domain is None: + raise AppwriteException('Missing required parameter: "domain"') + + if site_id is None: + raise AppwriteException('Missing required parameter: "site_id"') + + + api_params['domain'] = self._normalize_value(domain) + api_params['siteId'] = self._normalize_value(site_id) + if branch is not None: + api_params['branch'] = self._normalize_value(branch) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProxyRule) + + + def get_rule( + self, + rule_id: str + ) -> ProxyRule: + """ + Get a proxy rule by its unique ID. + + Parameters + ---------- + rule_id : str + Rule ID. + + Returns + ------- + ProxyRule + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/proxy/rules/{ruleId}' + api_params = {} + if rule_id is None: + raise AppwriteException('Missing required parameter: "rule_id"') + + api_path = api_path.replace('{ruleId}', str(self._normalize_value(rule_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=ProxyRule) + + + def delete_rule( + self, + rule_id: str + ) -> Dict[str, Any]: + """ + Delete a proxy rule by its unique ID. + + Parameters + ---------- + rule_id : str + Rule ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/proxy/rules/{ruleId}' + api_params = {} + if rule_id is None: + raise AppwriteException('Missing required parameter: "rule_id"') + + api_path = api_path.replace('{ruleId}', str(self._normalize_value(rule_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def update_rule_status( + self, + rule_id: str + ) -> ProxyRule: + """ + If not succeeded yet, retry verification process of a proxy rule domain. This endpoint triggers domain verification by checking DNS records. If verification is successful, a TLS certificate will be automatically provisioned for the domain asynchronously in the background. + + Parameters + ---------- + rule_id : str + Rule ID. + + Returns + ------- + ProxyRule + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/proxy/rules/{ruleId}/status' + api_params = {} + if rule_id is None: + raise AppwriteException('Missing required parameter: "rule_id"') + + api_path = api_path.replace('{ruleId}', str(self._normalize_value(rule_id))) + + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProxyRule) + diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index 627e4dac..57ea0377 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -1158,7 +1158,9 @@ def delete_log( def list_variables( self, - site_id: str + site_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None ) -> VariableList: """ Get a list of all variables of a specific site. @@ -1167,6 +1169,10 @@ def list_variables( ---------- site_id : str Site unique ID. + 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. You may filter on the following attributes: key, resourceType, resourceId, secret + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. Returns ------- @@ -1186,6 +1192,10 @@ def list_variables( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) response = self.client.call('get', api_path, { }, api_params) @@ -1196,6 +1206,7 @@ def list_variables( def create_variable( self, site_id: str, + variable_id: str, key: str, value: str, secret: Optional[bool] = None @@ -1207,6 +1218,8 @@ def create_variable( ---------- site_id : str Site unique ID. + variable_id : str + Variable 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. key : str Variable key. Max length: 255 chars. value : str @@ -1230,6 +1243,9 @@ def create_variable( if site_id is None: raise AppwriteException('Missing required parameter: "site_id"') + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + if key is None: raise AppwriteException('Missing required parameter: "key"') @@ -1238,6 +1254,7 @@ def create_variable( api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) + api_params['variableId'] = self._normalize_value(variable_id) api_params['key'] = self._normalize_value(key) api_params['value'] = self._normalize_value(value) if secret is not None: @@ -1298,7 +1315,7 @@ def update_variable( self, site_id: str, variable_id: str, - key: str, + key: Optional[str] = None, value: Optional[str] = None, secret: Optional[bool] = None ) -> Variable: @@ -1311,7 +1328,7 @@ def update_variable( Site unique ID. variable_id : str Variable unique ID. - key : str + key : Optional[str] Variable key. Max length: 255 chars. value : Optional[str] Variable value. Max length: 8192 chars. @@ -1337,9 +1354,6 @@ def update_variable( if variable_id is None: raise AppwriteException('Missing required parameter: "variable_id"') - if key is None: - raise AppwriteException('Missing required parameter: "key"') - api_path = api_path.replace('{siteId}', str(self._normalize_value(site_id))) api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index 2f1e3ccd..a2be7601 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -9,6 +9,7 @@ from ..models.table_list import TableList; from ..models.table import Table; from ..models.column_list import ColumnList; +from ..models.column_bigint import ColumnBigint; from ..models.column_boolean import ColumnBoolean; from ..models.column_datetime import ColumnDatetime; from ..models.column_email import ColumnEmail; @@ -838,6 +839,159 @@ def list_columns( return self._parse_response(response, model=ColumnList) + def create_big_int_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 + ) -> ColumnBigint: + """ + Create a bigint column. Optionally, minimum and maximum values can be provided. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. + key : str + Column Key. + required : bool + Is column required? + min : Optional[float] + Minimum value + max : Optional[float] + Maximum value + default : Optional[float] + Default value. Cannot be set when column is required. + array : Optional[bool] + Is column an array? + + Returns + ------- + ColumnBigint + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + 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'] = 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'] = self._normalize_value(array) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ColumnBigint) + + + def update_big_int_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 + ) -> ColumnBigint: + """ + Update a bigint column. Changing the `default` value will not update already existing rows. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. + key : str + Column Key. + required : bool + Is column required? + default : Optional[float] + Default value. Cannot be set when column is required. + min : Optional[float] + Minimum value + max : Optional[float] + Maximum value + new_key : Optional[str] + New Column Key. + + Returns + ------- + ColumnBigint + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + 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'] = 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) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ColumnBigint) + + def create_boolean_column( self, database_id: str, diff --git a/docs/examples/databases/create-big-int-attribute.md b/docs/examples/databases/create-big-int-attribute.md new file mode 100644 index 00000000..8c615d9f --- /dev/null +++ b/docs/examples/databases/create-big-int-attribute.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.databases import Databases +from appwrite.models import AttributeBigint + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result: AttributeBigint = databases.create_big_int_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + min = None, # optional + max = None, # optional + default = None, # optional + array = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/databases/update-big-int-attribute.md b/docs/examples/databases/update-big-int-attribute.md new file mode 100644 index 00000000..35c0c14c --- /dev/null +++ b/docs/examples/databases/update-big-int-attribute.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.databases import Databases +from appwrite.models import AttributeBigint + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result: AttributeBigint = databases.update_big_int_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = None, + min = None, # optional + max = None, # optional + new_key = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index e8f0b90b..da323f97 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -12,6 +12,7 @@ functions = Functions(client) result: Variable = functions.create_variable( function_id = '', + variable_id = '', key = '', value = '', secret = False # optional diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 235df705..fdded0ed 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -24,7 +24,7 @@ result: Function = functions.create( logging = False, # optional entrypoint = '', # optional commands = '', # optional - scopes = [Scopes.SESSIONS_WRITE], # optional + scopes = [Scopes.PROJECT_READ], # optional installation_id = '', # optional provider_repository_id = '', # optional provider_branch = '', # optional diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index ac1b9609..693334b7 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -11,7 +11,9 @@ client.set_key('') # Your secret API key functions = Functions(client) result: VariableList = functions.list_variables( - function_id = '' + function_id = '', + queries = [], # optional + total = False # optional ) print(result.model_dump()) diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index ed20fc59..6aa2f98c 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -13,7 +13,7 @@ functions = Functions(client) result: Variable = functions.update_variable( function_id = '', variable_id = '', - key = '', + key = '', # optional value = '', # optional secret = False # optional ) diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 181626c4..ab634e5e 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -24,7 +24,7 @@ result: Function = functions.update( logging = False, # optional entrypoint = '', # optional commands = '', # optional - scopes = [Scopes.SESSIONS_WRITE], # optional + scopes = [Scopes.PROJECT_READ], # optional installation_id = '', # optional provider_repository_id = '', # optional provider_branch = '', # optional diff --git a/docs/examples/presences/delete.md b/docs/examples/presences/delete.md new file mode 100644 index 00000000..ca4ba660 --- /dev/null +++ b/docs/examples/presences/delete.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.presences import Presences + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +presences = Presences(client) + +result = presences.delete( + presence_id = '' +) +``` diff --git a/docs/examples/presences/get.md b/docs/examples/presences/get.md new file mode 100644 index 00000000..2c57df09 --- /dev/null +++ b/docs/examples/presences/get.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.presences import Presences +from appwrite.models import Presence + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +presences = Presences(client) + +result: Presence = presences.get( + presence_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/presences/list.md b/docs/examples/presences/list.md new file mode 100644 index 00000000..a0349285 --- /dev/null +++ b/docs/examples/presences/list.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.presences import Presences +from appwrite.models import PresenceList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +presences = Presences(client) + +result: PresenceList = presences.list( + queries = [], # optional + total = False, # optional + ttl = 0 # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/presences/update-presence.md b/docs/examples/presences/update-presence.md new file mode 100644 index 00000000..ea7a7c58 --- /dev/null +++ b/docs/examples/presences/update-presence.md @@ -0,0 +1,26 @@ +```python +from appwrite.client import Client +from appwrite.services.presences import Presences +from appwrite.models import Presence +from appwrite.permission import Permission +from appwrite.role import Role + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +presences = Presences(client) + +result: Presence = presences.update_presence( + presence_id = '', + user_id = '', + status = '', # optional + expires_at = '2020-10-15T06:38:00.000+00:00', # optional + metadata = {}, # optional + permissions = [Permission.read(Role.any())], # optional + purge = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/presences/upsert.md b/docs/examples/presences/upsert.md new file mode 100644 index 00000000..2750434c --- /dev/null +++ b/docs/examples/presences/upsert.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.presences import Presences +from appwrite.models import Presence +from appwrite.permission import Permission +from appwrite.role import Role + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +presences = Presences(client) + +result: Presence = presences.upsert( + presence_id = '', + user_id = '', + status = '', + permissions = [Permission.read(Role.any())], # optional + expires_at = '2020-10-15T06:38:00.000+00:00', # optional + metadata = {} # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md new file mode 100644 index 00000000..4b51248c --- /dev/null +++ b/docs/examples/project/create-ephemeral-key.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import EphemeralKey +from appwrite.enums import Scopes + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: EphemeralKey = project.create_ephemeral_key( + scopes = [Scopes.PROJECT_READ], + duration = 600 +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/create-key.md b/docs/examples/project/create-key.md index 17989e50..bca74d67 100644 --- a/docs/examples/project/create-key.md +++ b/docs/examples/project/create-key.md @@ -14,7 +14,7 @@ project = Project(client) result: Key = project.create_key( key_id = '', name = '', - scopes = [Scopes.SESSIONS_WRITE], + scopes = [Scopes.PROJECT_READ], expire = '2020-10-15T06:38:00.000+00:00' # optional ) diff --git a/docs/examples/project/create-mock-phone.md b/docs/examples/project/create-mock-phone.md new file mode 100644 index 00000000..6ad457df --- /dev/null +++ b/docs/examples/project/create-mock-phone.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import MockNumber + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: MockNumber = project.create_mock_phone( + number = '+12065550100', + otp = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md new file mode 100644 index 00000000..3b39979b --- /dev/null +++ b/docs/examples/project/create-smtp-test.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result = project.create_smtp_test( + emails = [] +) +``` diff --git a/docs/examples/project/delete-mock-phone.md b/docs/examples/project/delete-mock-phone.md new file mode 100644 index 00000000..5ce79db5 --- /dev/null +++ b/docs/examples/project/delete-mock-phone.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result = project.delete_mock_phone( + number = '+12065550100' +) +``` diff --git a/docs/examples/project/delete.md b/docs/examples/project/delete.md new file mode 100644 index 00000000..0c74d311 --- /dev/null +++ b/docs/examples/project/delete.md @@ -0,0 +1,13 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result = project.delete() +``` diff --git a/docs/examples/project/get-email-template.md b/docs/examples/project/get-email-template.md new file mode 100644 index 00000000..f695b72d --- /dev/null +++ b/docs/examples/project/get-email-template.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import EmailTemplate +from appwrite.enums import EmailTemplateType +from appwrite.enums import EmailTemplateLocale + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: EmailTemplate = project.get_email_template( + template_id = EmailTemplateType.VERIFICATION, + locale = EmailTemplateLocale.AF # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/get-mock-phone.md b/docs/examples/project/get-mock-phone.md new file mode 100644 index 00000000..e35dffdd --- /dev/null +++ b/docs/examples/project/get-mock-phone.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import MockNumber + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: MockNumber = project.get_mock_phone( + number = '+12065550100' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/get-o-auth-2-provider.md b/docs/examples/project/get-o-auth-2-provider.md new file mode 100644 index 00000000..e7369d02 --- /dev/null +++ b/docs/examples/project/get-o-auth-2-provider.md @@ -0,0 +1,59 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Github +from appwrite.models import OAuth2Discord +from appwrite.models import OAuth2Figma +from appwrite.models import OAuth2Dropbox +from appwrite.models import OAuth2Dailymotion +from appwrite.models import OAuth2Bitbucket +from appwrite.models import OAuth2Bitly +from appwrite.models import OAuth2Box +from appwrite.models import OAuth2Autodesk +from appwrite.models import OAuth2Google +from appwrite.models import OAuth2Zoom +from appwrite.models import OAuth2Zoho +from appwrite.models import OAuth2Yandex +from appwrite.models import OAuth2X +from appwrite.models import OAuth2WordPress +from appwrite.models import OAuth2Twitch +from appwrite.models import OAuth2Stripe +from appwrite.models import OAuth2Spotify +from appwrite.models import OAuth2Slack +from appwrite.models import OAuth2Podio +from appwrite.models import OAuth2Notion +from appwrite.models import OAuth2Salesforce +from appwrite.models import OAuth2Yahoo +from appwrite.models import OAuth2Linkedin +from appwrite.models import OAuth2Disqus +from appwrite.models import OAuth2Amazon +from appwrite.models import OAuth2Etsy +from appwrite.models import OAuth2Facebook +from appwrite.models import OAuth2Tradeshift +from appwrite.models import OAuth2Paypal +from appwrite.models import OAuth2Gitlab +from appwrite.models import OAuth2Authentik +from appwrite.models import OAuth2Auth0 +from appwrite.models import OAuth2FusionAuth +from appwrite.models import OAuth2Keycloak +from appwrite.models import OAuth2Oidc +from appwrite.models import OAuth2Apple +from appwrite.models import OAuth2Okta +from appwrite.models import OAuth2Kick +from appwrite.models import OAuth2Microsoft +from typing import Union +from appwrite.enums import ProviderId + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft] = project.get_o_auth2_provider( + provider_id = ProviderId.AMAZON +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/get-policy.md b/docs/examples/project/get-policy.md new file mode 100644 index 00000000..425724af --- /dev/null +++ b/docs/examples/project/get-policy.md @@ -0,0 +1,28 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PolicyPasswordDictionary +from appwrite.models import PolicyPasswordHistory +from appwrite.models import PolicyPasswordPersonalData +from appwrite.models import PolicySessionAlert +from appwrite.models import PolicySessionDuration +from appwrite.models import PolicySessionInvalidation +from appwrite.models import PolicySessionLimit +from appwrite.models import PolicyUserLimit +from appwrite.models import PolicyMembershipPrivacy +from typing import Union +from appwrite.enums import PolicyId + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy] = project.get_policy( + policy_id = PolicyId.PASSWORD_DICTIONARY +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/list-email-templates.md b/docs/examples/project/list-email-templates.md new file mode 100644 index 00000000..293bae73 --- /dev/null +++ b/docs/examples/project/list-email-templates.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import EmailTemplateList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: EmailTemplateList = project.list_email_templates( + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/list-mock-phones.md b/docs/examples/project/list-mock-phones.md new file mode 100644 index 00000000..6a73776b --- /dev/null +++ b/docs/examples/project/list-mock-phones.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import MockNumberList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: MockNumberList = project.list_mock_phones( + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/list-o-auth-2-providers.md b/docs/examples/project/list-o-auth-2-providers.md new file mode 100644 index 00000000..fbe6791a --- /dev/null +++ b/docs/examples/project/list-o-auth-2-providers.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2ProviderList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2ProviderList = project.list_o_auth2_providers( + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/list-policies.md b/docs/examples/project/list-policies.md new file mode 100644 index 00000000..e150a3f6 --- /dev/null +++ b/docs/examples/project/list-policies.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PolicyList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: PolicyList = project.list_policies( + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-auth-method.md b/docs/examples/project/update-auth-method.md new file mode 100644 index 00000000..535503c7 --- /dev/null +++ b/docs/examples/project/update-auth-method.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel +from appwrite.enums import MethodId + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_auth_method( + method_id = MethodId.EMAIL_PASSWORD, + enabled = False +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-email-template.md b/docs/examples/project/update-email-template.md new file mode 100644 index 00000000..b7e86d0a --- /dev/null +++ b/docs/examples/project/update-email-template.md @@ -0,0 +1,27 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import EmailTemplate +from appwrite.enums import EmailTemplateType +from appwrite.enums import EmailTemplateLocale + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: EmailTemplate = project.update_email_template( + template_id = EmailTemplateType.VERIFICATION, + locale = EmailTemplateLocale.AF, # optional + subject = '', # optional + message = '', # optional + sender_name = '', # optional + sender_email = 'email@example.com', # optional + reply_to_email = 'email@example.com', # optional + reply_to_name = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index 3199fd44..88f6c0a9 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -14,7 +14,7 @@ project = Project(client) result: Key = project.update_key( key_id = '', name = '', - scopes = [Scopes.SESSIONS_WRITE], + scopes = [Scopes.PROJECT_READ], expire = '2020-10-15T06:38:00.000+00:00' # optional ) diff --git a/docs/examples/project/update-membership-privacy-policy.md b/docs/examples/project/update-membership-privacy-policy.md new file mode 100644 index 00000000..733699b1 --- /dev/null +++ b/docs/examples/project/update-membership-privacy-policy.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_membership_privacy_policy( + user_id = False, # optional + user_email = False, # optional + user_phone = False, # optional + user_name = False, # optional + user_mfa = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-mock-phone.md b/docs/examples/project/update-mock-phone.md new file mode 100644 index 00000000..8a9a96c3 --- /dev/null +++ b/docs/examples/project/update-mock-phone.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import MockNumber + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: MockNumber = project.update_mock_phone( + number = '+12065550100', + otp = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-amazon.md b/docs/examples/project/update-o-auth-2-amazon.md new file mode 100644 index 00000000..61459693 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-amazon.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Amazon + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Amazon = project.update_o_auth2_amazon( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md new file mode 100644 index 00000000..2619115e --- /dev/null +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Apple + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Apple = project.update_o_auth2_apple( + service_id = '', # optional + key_id = '', # optional + team_id = '', # optional + p8_file = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md new file mode 100644 index 00000000..568bb9bb --- /dev/null +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Auth0 + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Auth0 = project.update_o_auth2_auth0( + client_id = '', # optional + client_secret = '', # optional + endpoint = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-authentik.md b/docs/examples/project/update-o-auth-2-authentik.md new file mode 100644 index 00000000..2fbc0990 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-authentik.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Authentik + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Authentik = project.update_o_auth2_authentik( + client_id = '', # optional + client_secret = '', # optional + endpoint = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-autodesk.md b/docs/examples/project/update-o-auth-2-autodesk.md new file mode 100644 index 00000000..cff31e1e --- /dev/null +++ b/docs/examples/project/update-o-auth-2-autodesk.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Autodesk + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Autodesk = project.update_o_auth2_autodesk( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-bitbucket.md b/docs/examples/project/update-o-auth-2-bitbucket.md new file mode 100644 index 00000000..a2099d1b --- /dev/null +++ b/docs/examples/project/update-o-auth-2-bitbucket.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Bitbucket + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Bitbucket = project.update_o_auth2_bitbucket( + key = '', # optional + secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-bitly.md b/docs/examples/project/update-o-auth-2-bitly.md new file mode 100644 index 00000000..1f026038 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-bitly.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Bitly + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Bitly = project.update_o_auth2_bitly( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-box.md b/docs/examples/project/update-o-auth-2-box.md new file mode 100644 index 00000000..363cd060 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-box.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Box + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Box = project.update_o_auth2_box( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-dailymotion.md b/docs/examples/project/update-o-auth-2-dailymotion.md new file mode 100644 index 00000000..53449cd1 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-dailymotion.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Dailymotion + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Dailymotion = project.update_o_auth2_dailymotion( + api_key = '', # optional + api_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md new file mode 100644 index 00000000..a95cc496 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Discord + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Discord = project.update_o_auth2_discord( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-disqus.md b/docs/examples/project/update-o-auth-2-disqus.md new file mode 100644 index 00000000..f2af447f --- /dev/null +++ b/docs/examples/project/update-o-auth-2-disqus.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Disqus + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Disqus = project.update_o_auth2_disqus( + public_key = '', # optional + secret_key = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-dropbox.md b/docs/examples/project/update-o-auth-2-dropbox.md new file mode 100644 index 00000000..50e30119 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-dropbox.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Dropbox + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Dropbox = project.update_o_auth2_dropbox( + app_key = '', # optional + app_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-etsy.md b/docs/examples/project/update-o-auth-2-etsy.md new file mode 100644 index 00000000..4a0a20ea --- /dev/null +++ b/docs/examples/project/update-o-auth-2-etsy.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Etsy + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Etsy = project.update_o_auth2_etsy( + key_string = '', # optional + shared_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-facebook.md b/docs/examples/project/update-o-auth-2-facebook.md new file mode 100644 index 00000000..5b536dbb --- /dev/null +++ b/docs/examples/project/update-o-auth-2-facebook.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Facebook + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Facebook = project.update_o_auth2_facebook( + app_id = '', # optional + app_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-figma.md b/docs/examples/project/update-o-auth-2-figma.md new file mode 100644 index 00000000..eb2a2d25 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-figma.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Figma + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Figma = project.update_o_auth2_figma( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-fusion-auth.md b/docs/examples/project/update-o-auth-2-fusion-auth.md new file mode 100644 index 00000000..fb4d25df --- /dev/null +++ b/docs/examples/project/update-o-auth-2-fusion-auth.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2FusionAuth + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2FusionAuth = project.update_o_auth2_fusion_auth( + client_id = '', # optional + client_secret = '', # optional + endpoint = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md new file mode 100644 index 00000000..36664b85 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Github + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Github = project.update_o_auth2_git_hub( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-gitlab.md b/docs/examples/project/update-o-auth-2-gitlab.md new file mode 100644 index 00000000..05905fdc --- /dev/null +++ b/docs/examples/project/update-o-auth-2-gitlab.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Gitlab + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Gitlab = project.update_o_auth2_gitlab( + application_id = '', # optional + secret = '', # optional + endpoint = 'https://example.com', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md new file mode 100644 index 00000000..865e81f5 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-google.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Google + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Google = project.update_o_auth2_google( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-keycloak.md b/docs/examples/project/update-o-auth-2-keycloak.md new file mode 100644 index 00000000..11a0defb --- /dev/null +++ b/docs/examples/project/update-o-auth-2-keycloak.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Keycloak + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Keycloak = project.update_o_auth2_keycloak( + client_id = '', # optional + client_secret = '', # optional + endpoint = '', # optional + realm_name = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-kick.md b/docs/examples/project/update-o-auth-2-kick.md new file mode 100644 index 00000000..bc73e063 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-kick.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Kick + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Kick = project.update_o_auth2_kick( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-linkedin.md b/docs/examples/project/update-o-auth-2-linkedin.md new file mode 100644 index 00000000..4b6eec3b --- /dev/null +++ b/docs/examples/project/update-o-auth-2-linkedin.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Linkedin + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Linkedin = project.update_o_auth2_linkedin( + client_id = '', # optional + primary_client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md new file mode 100644 index 00000000..aeeefa9e --- /dev/null +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Microsoft + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Microsoft = project.update_o_auth2_microsoft( + application_id = '', # optional + application_secret = '', # optional + tenant = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-notion.md b/docs/examples/project/update-o-auth-2-notion.md new file mode 100644 index 00000000..0ba765ea --- /dev/null +++ b/docs/examples/project/update-o-auth-2-notion.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Notion + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Notion = project.update_o_auth2_notion( + oauth_client_id = '', # optional + oauth_client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-oidc.md b/docs/examples/project/update-o-auth-2-oidc.md new file mode 100644 index 00000000..3913262d --- /dev/null +++ b/docs/examples/project/update-o-auth-2-oidc.md @@ -0,0 +1,24 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Oidc + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Oidc = project.update_o_auth2_oidc( + client_id = '', # optional + client_secret = '', # optional + well_known_url = 'https://example.com', # optional + authorization_url = 'https://example.com', # optional + token_url = 'https://example.com', # optional + user_info_url = 'https://example.com', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md new file mode 100644 index 00000000..1bd2e96d --- /dev/null +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Okta + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Okta = project.update_o_auth2_okta( + client_id = '', # optional + client_secret = '', # optional + domain = '', # optional + authorization_server_id = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-paypal-sandbox.md b/docs/examples/project/update-o-auth-2-paypal-sandbox.md new file mode 100644 index 00000000..f31dc285 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-paypal-sandbox.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Paypal + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Paypal = project.update_o_auth2_paypal_sandbox( + client_id = '', # optional + secret_key = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-paypal.md b/docs/examples/project/update-o-auth-2-paypal.md new file mode 100644 index 00000000..450e9592 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-paypal.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Paypal + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Paypal = project.update_o_auth2_paypal( + client_id = '', # optional + secret_key = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-podio.md b/docs/examples/project/update-o-auth-2-podio.md new file mode 100644 index 00000000..992ecdce --- /dev/null +++ b/docs/examples/project/update-o-auth-2-podio.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Podio + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Podio = project.update_o_auth2_podio( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md new file mode 100644 index 00000000..a3cb6377 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Salesforce + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Salesforce = project.update_o_auth2_salesforce( + customer_key = '', # optional + customer_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-slack.md b/docs/examples/project/update-o-auth-2-slack.md new file mode 100644 index 00000000..65cc3099 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-slack.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Slack + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Slack = project.update_o_auth2_slack( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-spotify.md b/docs/examples/project/update-o-auth-2-spotify.md new file mode 100644 index 00000000..257f45d0 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-spotify.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Spotify + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Spotify = project.update_o_auth2_spotify( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-stripe.md b/docs/examples/project/update-o-auth-2-stripe.md new file mode 100644 index 00000000..7207a897 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-stripe.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Stripe + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Stripe = project.update_o_auth2_stripe( + client_id = '', # optional + api_secret_key = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md new file mode 100644 index 00000000..2aaf7e64 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Tradeshift + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Tradeshift = project.update_o_auth2_tradeshift_sandbox( + oauth2_client_id = '', # optional + oauth2_client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift.md b/docs/examples/project/update-o-auth-2-tradeshift.md new file mode 100644 index 00000000..6ed5bacc --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tradeshift.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Tradeshift + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Tradeshift = project.update_o_auth2_tradeshift( + oauth2_client_id = '', # optional + oauth2_client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-twitch.md b/docs/examples/project/update-o-auth-2-twitch.md new file mode 100644 index 00000000..7c402789 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-twitch.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Twitch + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Twitch = project.update_o_auth2_twitch( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-word-press.md b/docs/examples/project/update-o-auth-2-word-press.md new file mode 100644 index 00000000..c7b406b9 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-word-press.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2WordPress + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2WordPress = project.update_o_auth2_word_press( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-yahoo.md b/docs/examples/project/update-o-auth-2-yahoo.md new file mode 100644 index 00000000..6ea825b5 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-yahoo.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Yahoo + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Yahoo = project.update_o_auth2_yahoo( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-yandex.md b/docs/examples/project/update-o-auth-2-yandex.md new file mode 100644 index 00000000..c8604ede --- /dev/null +++ b/docs/examples/project/update-o-auth-2-yandex.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Yandex + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Yandex = project.update_o_auth2_yandex( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md new file mode 100644 index 00000000..069a9645 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Zoho + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Zoho = project.update_o_auth2_zoho( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-zoom.md b/docs/examples/project/update-o-auth-2-zoom.md new file mode 100644 index 00000000..e779a0c0 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-zoom.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Zoom + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Zoom = project.update_o_auth2_zoom( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2x.md b/docs/examples/project/update-o-auth-2x.md new file mode 100644 index 00000000..5637fd6a --- /dev/null +++ b/docs/examples/project/update-o-auth-2x.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2X + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2X = project.update_o_auth2_x( + customer_key = '', # optional + secret_key = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-password-dictionary-policy.md b/docs/examples/project/update-password-dictionary-policy.md new file mode 100644 index 00000000..93e652be --- /dev/null +++ b/docs/examples/project/update-password-dictionary-policy.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_password_dictionary_policy( + enabled = False +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-password-history-policy.md b/docs/examples/project/update-password-history-policy.md new file mode 100644 index 00000000..5e3c1406 --- /dev/null +++ b/docs/examples/project/update-password-history-policy.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_password_history_policy( + total = 1 +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-password-personal-data-policy.md b/docs/examples/project/update-password-personal-data-policy.md new file mode 100644 index 00000000..507bdac4 --- /dev/null +++ b/docs/examples/project/update-password-personal-data-policy.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_password_personal_data_policy( + enabled = False +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-protocol-status.md b/docs/examples/project/update-protocol.md similarity index 90% rename from docs/examples/project/update-protocol-status.md rename to docs/examples/project/update-protocol.md index a9415cdd..a8b555d0 100644 --- a/docs/examples/project/update-protocol-status.md +++ b/docs/examples/project/update-protocol.md @@ -11,7 +11,7 @@ client.set_key('') # Your secret API key project = Project(client) -result: ProjectModel = project.update_protocol_status( +result: ProjectModel = project.update_protocol( protocol_id = ProtocolId.REST, enabled = False ) diff --git a/docs/examples/project/update-service-status.md b/docs/examples/project/update-service.md similarity index 90% rename from docs/examples/project/update-service-status.md rename to docs/examples/project/update-service.md index ba607dbf..66bd6c7d 100644 --- a/docs/examples/project/update-service-status.md +++ b/docs/examples/project/update-service.md @@ -11,7 +11,7 @@ client.set_key('') # Your secret API key project = Project(client) -result: ProjectModel = project.update_service_status( +result: ProjectModel = project.update_service( service_id = ServiceId.ACCOUNT, enabled = False ) diff --git a/docs/examples/project/update-session-alert-policy.md b/docs/examples/project/update-session-alert-policy.md new file mode 100644 index 00000000..382f694d --- /dev/null +++ b/docs/examples/project/update-session-alert-policy.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_session_alert_policy( + enabled = False +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-session-duration-policy.md b/docs/examples/project/update-session-duration-policy.md new file mode 100644 index 00000000..768bd4ff --- /dev/null +++ b/docs/examples/project/update-session-duration-policy.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_session_duration_policy( + duration = 5 +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-session-invalidation-policy.md b/docs/examples/project/update-session-invalidation-policy.md new file mode 100644 index 00000000..6e8417d3 --- /dev/null +++ b/docs/examples/project/update-session-invalidation-policy.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_session_invalidation_policy( + enabled = False +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-session-limit-policy.md b/docs/examples/project/update-session-limit-policy.md new file mode 100644 index 00000000..bcfd671a --- /dev/null +++ b/docs/examples/project/update-session-limit-policy.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_session_limit_policy( + total = 1 +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-smtp.md b/docs/examples/project/update-smtp.md new file mode 100644 index 00000000..481e657d --- /dev/null +++ b/docs/examples/project/update-smtp.md @@ -0,0 +1,28 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel +from appwrite.enums import Secure + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_smtp( + host = '', # optional + port = None, # optional + username = '', # optional + password = '', # optional + sender_email = 'email@example.com', # optional + sender_name = '', # optional + reply_to_email = 'email@example.com', # optional + reply_to_name = '', # optional + secure = Secure.TLS, # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-user-limit-policy.md b/docs/examples/project/update-user-limit-policy.md new file mode 100644 index 00000000..e841acae --- /dev/null +++ b/docs/examples/project/update-user-limit-policy.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_user_limit_policy( + total = 1 +) + +print(result.model_dump()) +``` diff --git a/docs/examples/proxy/create-api-rule.md b/docs/examples/proxy/create-api-rule.md new file mode 100644 index 00000000..5f776309 --- /dev/null +++ b/docs/examples/proxy/create-api-rule.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.proxy import Proxy +from appwrite.models import ProxyRule + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +proxy = Proxy(client) + +result: ProxyRule = proxy.create_api_rule( + domain = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/proxy/create-function-rule.md b/docs/examples/proxy/create-function-rule.md new file mode 100644 index 00000000..b28a529d --- /dev/null +++ b/docs/examples/proxy/create-function-rule.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.proxy import Proxy +from appwrite.models import ProxyRule + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +proxy = Proxy(client) + +result: ProxyRule = proxy.create_function_rule( + domain = '', + function_id = '', + branch = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/proxy/create-redirect-rule.md b/docs/examples/proxy/create-redirect-rule.md new file mode 100644 index 00000000..4da7b6c9 --- /dev/null +++ b/docs/examples/proxy/create-redirect-rule.md @@ -0,0 +1,24 @@ +```python +from appwrite.client import Client +from appwrite.services.proxy import Proxy +from appwrite.models import ProxyRule +from appwrite.enums import StatusCode +from appwrite.enums import ProxyResourceType + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +proxy = Proxy(client) + +result: ProxyRule = proxy.create_redirect_rule( + domain = '', + url = 'https://example.com', + status_code = StatusCode.MOVED_PERMANENTLY_301, + resource_id = '', + resource_type = ProxyResourceType.SITE +) + +print(result.model_dump()) +``` diff --git a/docs/examples/proxy/create-site-rule.md b/docs/examples/proxy/create-site-rule.md new file mode 100644 index 00000000..54cb0c1e --- /dev/null +++ b/docs/examples/proxy/create-site-rule.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.proxy import Proxy +from appwrite.models import ProxyRule + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +proxy = Proxy(client) + +result: ProxyRule = proxy.create_site_rule( + domain = '', + site_id = '', + branch = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/proxy/delete-rule.md b/docs/examples/proxy/delete-rule.md new file mode 100644 index 00000000..c5a76ee5 --- /dev/null +++ b/docs/examples/proxy/delete-rule.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.proxy import Proxy + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +proxy = Proxy(client) + +result = proxy.delete_rule( + rule_id = '' +) +``` diff --git a/docs/examples/proxy/get-rule.md b/docs/examples/proxy/get-rule.md new file mode 100644 index 00000000..becc4c36 --- /dev/null +++ b/docs/examples/proxy/get-rule.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.proxy import Proxy +from appwrite.models import ProxyRule + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +proxy = Proxy(client) + +result: ProxyRule = proxy.get_rule( + rule_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/proxy/list-rules.md b/docs/examples/proxy/list-rules.md new file mode 100644 index 00000000..4cf085f4 --- /dev/null +++ b/docs/examples/proxy/list-rules.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.proxy import Proxy +from appwrite.models import ProxyRuleList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +proxy = Proxy(client) + +result: ProxyRuleList = proxy.list_rules( + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/proxy/update-rule-status.md b/docs/examples/proxy/update-rule-status.md new file mode 100644 index 00000000..f317926d --- /dev/null +++ b/docs/examples/proxy/update-rule-status.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.proxy import Proxy +from appwrite.models import ProxyRule + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +proxy = Proxy(client) + +result: ProxyRule = proxy.update_rule_status( + rule_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md index d9f866b3..ca6d9e57 100644 --- a/docs/examples/sites/create-variable.md +++ b/docs/examples/sites/create-variable.md @@ -12,6 +12,7 @@ sites = Sites(client) result: Variable = sites.create_variable( site_id = '', + variable_id = '', key = '', value = '', secret = False # optional diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md index 5560279d..4a2c2c5a 100644 --- a/docs/examples/sites/list-variables.md +++ b/docs/examples/sites/list-variables.md @@ -11,7 +11,9 @@ client.set_key('') # Your secret API key sites = Sites(client) result: VariableList = sites.list_variables( - site_id = '' + site_id = '', + queries = [], # optional + total = False # optional ) print(result.model_dump()) diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md index 5e165781..637d2220 100644 --- a/docs/examples/sites/update-variable.md +++ b/docs/examples/sites/update-variable.md @@ -13,7 +13,7 @@ sites = Sites(client) result: Variable = sites.update_variable( site_id = '', variable_id = '', - key = '', + key = '', # optional value = '', # optional secret = False # optional ) diff --git a/docs/examples/tablesdb/create-big-int-column.md b/docs/examples/tablesdb/create-big-int-column.md new file mode 100644 index 00000000..7e4a98c3 --- /dev/null +++ b/docs/examples/tablesdb/create-big-int-column.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnBigint + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +tables_db = TablesDB(client) + +result: ColumnBigint = tables_db.create_big_int_column( + database_id = '', + table_id = '', + key = '', + required = False, + min = None, # optional + max = None, # optional + default = None, # optional + array = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/tablesdb/update-big-int-column.md b/docs/examples/tablesdb/update-big-int-column.md new file mode 100644 index 00000000..d395f31a --- /dev/null +++ b/docs/examples/tablesdb/update-big-int-column.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB +from appwrite.models import ColumnBigint + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +tables_db = TablesDB(client) + +result: ColumnBigint = tables_db.update_big_int_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = None, + min = None, # optional + max = None, # optional + new_key = '' # optional +) + +print(result.model_dump()) +``` diff --git a/pyproject.toml b/pyproject.toml index 91b5d2d5..30997979 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "appwrite" -version = "18.0.0" +version = "18.1.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" @@ -32,6 +32,11 @@ classifiers = [ "Programming Language :: Python :: 3.12", ] +[project.optional-dependencies] +test = [ + "requests_mock==1.11.0", +] + [project.urls] Homepage = "https://appwrite.io/support" Repository = "https://github.com/appwrite/sdk-for-python" diff --git a/requirements.txt b/requirements.txt index 71762bc4..43f14202 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ requests>=2.31,<3 +requests_mock==1.11.0 pydantic>=2,<3 diff --git a/setup.py b/setup.py index 12b13230..7cb7b2fc 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name = 'appwrite', packages = setuptools.find_packages(), - version = '18.0.0', + version = '18.1.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/18.0.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/18.1.0.tar.gz', install_requires=[ 'requests', 'pydantic>=2,<3', diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/services/__init__.py b/test/services/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/services/test_account.py b/test/services/test_account.py new file mode 100644 index 00000000..ccf075df --- /dev/null +++ b/test/services/test_account.py @@ -0,0 +1,1250 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.account import Account + +class AccountServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.account = Account(self.client) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.get( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create( + '', + 'email@example.com', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_email(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_email( + 'email@example.com', + 'password', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_identities(self, m): + data = { + "total": 5.0, + "identities": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.list_identities( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_identity(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.delete_identity( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_create_jwt(self, m): + data = { + "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_jwt( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_logs(self, m): + data = { + "total": 5.0, + "logs": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.list_logs( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_mfa( + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mfa_authenticator(self, m): + data = { + "secret": "[SHARED_SECRET]", + "uri": "otpauth:\/\/totp\/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_mfa_authenticator( + 'totp', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mfa_authenticator(self, m): + data = { + "secret": "[SHARED_SECRET]", + "uri": "otpauth:\/\/totp\/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_mfa_authenticator( + 'totp', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa_authenticator(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_mfa_authenticator( + 'totp', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa_authenticator(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_mfa_authenticator( + 'totp', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_mfa_authenticator(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.delete_mfa_authenticator( + 'totp', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_delete_mfa_authenticator(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.delete_mfa_authenticator( + 'totp', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_create_mfa_challenge(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "expire": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_mfa_challenge( + 'email', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mfa_challenge(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "expire": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_mfa_challenge( + 'email', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa_challenge(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_mfa_challenge( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa_challenge(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_mfa_challenge( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_mfa_factors(self, m): + data = { + "totp": True, + "phone": True, + "email": True, + "recoveryCode": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.list_mfa_factors( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_mfa_factors(self, m): + data = { + "totp": True, + "phone": True, + "email": True, + "recoveryCode": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.list_mfa_factors( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.get_mfa_recovery_codes( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.get_mfa_recovery_codes( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_mfa_recovery_codes( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_mfa_recovery_codes( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_mfa_recovery_codes( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_mfa_recovery_codes( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_name(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_name( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_password(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_password( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_phone(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_phone( + '+12065550100', + 'password', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_prefs(self, m): + data = {} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.get_prefs( + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_prefs(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_prefs( + {}, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_recovery(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_recovery( + 'email@example.com', + 'https://example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_recovery(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_recovery( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_sessions(self, m): + data = { + "total": 5.0, + "sessions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.list_sessions( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_sessions(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.delete_sessions( + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_create_anonymous_session(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_anonymous_session( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_email_password_session(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_email_password_session( + 'email@example.com', + 'password', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_magic_url_session(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_magic_url_session( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_phone_session(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_phone_session( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_session(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_session( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_session(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.get_session( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_session(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_session( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_session(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.delete_session( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_status(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_status( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_email_token(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_email_token( + '', + 'email@example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_magic_url_token(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_magic_url_token( + '', + 'email@example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_o_auth2_token(self, m): + data = None + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_o_auth2_token( + 'amazon', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_create_phone_token(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_phone_token( + '', + '+12065550100', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_email_verification(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_email_verification( + 'https://example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_verification(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_verification( + 'https://example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_email_verification(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_email_verification( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_verification(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_verification( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_phone_verification(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.create_phone_verification( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_phone_verification(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.account.update_phone_verification( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + diff --git a/test/services/test_activities.py b/test/services/test_activities.py new file mode 100644 index 00000000..2ab995d7 --- /dev/null +++ b/test/services/test_activities.py @@ -0,0 +1,74 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.activities import Activities + +class ActivitiesServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.activities = Activities(self.client) + + @requests_mock.Mocker() + def test_list_events(self, m): + data = { + "total": 5.0, + "events": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.activities.list_events( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_event(self, m): + data = { + "$id": "5e5ea5c16897e", + "userType": "user", + "userId": "610fc2f985ee0", + "userEmail": "john@appwrite.io", + "userName": "John Doe", + "resourceParent": "database\/ID", + "resourceType": "collection", + "resourceId": "610fc2f985ee0", + "resource": "collections\/610fc2f985ee0", + "event": "account.sessions.create", + "userAgent": "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/86.0.4240.198 Safari\/537.36", + "ip": "127.0.0.1", + "mode": "admin", + "country": "US", + "time": "2020-10-15T06:38:00.000+00:00", + "projectId": "610fc2f985ee0", + "teamId": "610fc2f985ee0", + "hostname": "appwrite.io", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.activities.get_event( + '', + ) + + self.assertEqual(response.to_dict(), data) + diff --git a/test/services/test_avatars.py b/test/services/test_avatars.py new file mode 100644 index 00000000..a37a31e7 --- /dev/null +++ b/test/services/test_avatars.py @@ -0,0 +1,110 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.avatars import Avatars + +class AvatarsServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.avatars = Avatars(self.client) + + @requests_mock.Mocker() + def test_get_browser(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.avatars.get_browser( + 'aa', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_credit_card(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.avatars.get_credit_card( + 'amex', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_favicon(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.avatars.get_favicon( + 'https://example.com', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_flag(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.avatars.get_flag( + 'af', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_image(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.avatars.get_image( + 'https://example.com', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_initials(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.avatars.get_initials( + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_qr(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.avatars.get_qr( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_screenshot(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.avatars.get_screenshot( + 'https://example.com', + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_backups.py b/test/services/test_backups.py new file mode 100644 index 00000000..f9413c2d --- /dev/null +++ b/test/services/test_backups.py @@ -0,0 +1,245 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.backups import Backups + +class BackupsServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.backups = Backups(self.client) + + @requests_mock.Mocker() + def test_list_archives(self, m): + data = { + "total": 5.0, + "archives": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.list_archives( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_archive(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "policyId": "did8jx6ws45jana098ab7", + "size": 100000.0, + "status": "completed", + "startedAt": "2020-10-15T06:38:00.000+00:00", + "migrationId": "did8jx6ws45jana098ab7", + "services": [], + "resources": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.create_archive( + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_archive(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "policyId": "did8jx6ws45jana098ab7", + "size": 100000.0, + "status": "completed", + "startedAt": "2020-10-15T06:38:00.000+00:00", + "migrationId": "did8jx6ws45jana098ab7", + "services": [], + "resources": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.get_archive( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_archive(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.delete_archive( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_policies(self, m): + data = { + "total": 5.0, + "policies": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.list_policies( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "name": "Hourly backups", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "services": [], + "resources": [], + "retention": 7.0, + "schedule": "0 * * * *", + "enabled": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.create_policy( + '', + [], + 1, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "name": "Hourly backups", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "services": [], + "resources": [], + "retention": 7.0, + "schedule": "0 * * * *", + "enabled": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.get_policy( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "name": "Hourly backups", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "services": [], + "resources": [], + "retention": 7.0, + "schedule": "0 * * * *", + "enabled": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.update_policy( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_policy(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.delete_policy( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_create_restoration(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "archiveId": "did8jx6ws45jana098ab7", + "policyId": "did8jx6ws45jana098ab7", + "status": "completed", + "startedAt": "2020-10-15T06:38:00.000+00:00", + "migrationId": "did8jx6ws45jana098ab7", + "services": [], + "resources": [], + "options": "{databases.database[{oldId, newId, newName}]}" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.create_restoration( + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_restorations(self, m): + data = { + "total": 5.0, + "restorations": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.list_restorations( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_restoration(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "archiveId": "did8jx6ws45jana098ab7", + "policyId": "did8jx6ws45jana098ab7", + "status": "completed", + "startedAt": "2020-10-15T06:38:00.000+00:00", + "migrationId": "did8jx6ws45jana098ab7", + "services": [], + "resources": [], + "options": "{databases.database[{oldId, newId, newName}]}" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.backups.get_restoration( + '', + ) + + self.assertEqual(response.to_dict(), data) + diff --git a/test/services/test_databases.py b/test/services/test_databases.py new file mode 100644 index 00000000..f6bc3112 --- /dev/null +++ b/test/services/test_databases.py @@ -0,0 +1,1555 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.databases import Databases + +class DatabasesServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.databases = Databases(self.client) + + @requests_mock.Mocker() + def test_list(self, m): + data = { + "total": 5.0, + "databases": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.list( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create(self, m): + data = { + "$id": "5e5ea5c16897e", + "name": "My Database", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "enabled": True, + "type": "legacy", + "policies": [], + "archives": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_transactions(self, m): + data = { + "total": 5.0, + "transactions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.list_transactions( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_transaction(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "status": "pending", + "operations": 5.0, + "expiresAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_transaction( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_transaction(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "status": "pending", + "operations": 5.0, + "expiresAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.get_transaction( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_transaction(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "status": "pending", + "operations": 5.0, + "expiresAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_transaction( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_transaction(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.delete_transaction( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_create_operations(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "status": "pending", + "operations": 5.0, + "expiresAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_operations( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "5e5ea5c16897e", + "name": "My Database", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "enabled": True, + "type": "legacy", + "policies": [], + "archives": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.get( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update(self, m): + data = { + "$id": "5e5ea5c16897e", + "name": "My Database", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "enabled": True, + "type": "legacy", + "policies": [], + "archives": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.delete( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_collections(self, m): + data = { + "total": 5.0, + "collections": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.list_collections( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_collection(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "databaseId": "5e5ea5c16897e", + "name": "My Collection", + "enabled": True, + "documentSecurity": True, + "attributes": [], + "indexes": [], + "bytesMax": 65535.0, + "bytesUsed": 1500.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_collection( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_collection(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "databaseId": "5e5ea5c16897e", + "name": "My Collection", + "enabled": True, + "documentSecurity": True, + "attributes": [], + "indexes": [], + "bytesMax": 65535.0, + "bytesUsed": 1500.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.get_collection( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_collection(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "databaseId": "5e5ea5c16897e", + "name": "My Collection", + "enabled": True, + "documentSecurity": True, + "attributes": [], + "indexes": [], + "bytesMax": 65535.0, + "bytesUsed": 1500.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_collection( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_collection(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.delete_collection( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_attributes(self, m): + data = { + "total": 5.0, + "attributes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.list_attributes( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_big_int_attribute(self, m): + data = { + "key": "count", + "type": "bigint", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_big_int_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_big_int_attribute(self, m): + data = { + "key": "count", + "type": "bigint", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_big_int_attribute( + '', + '', + '', + True, + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_boolean_attribute(self, m): + data = { + "key": "isEnabled", + "type": "boolean", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_boolean_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_boolean_attribute(self, m): + data = { + "key": "isEnabled", + "type": "boolean", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_boolean_attribute( + '', + '', + '', + True, + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_datetime_attribute(self, m): + data = { + "key": "birthDay", + "type": "datetime", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_datetime_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_datetime_attribute(self, m): + data = { + "key": "birthDay", + "type": "datetime", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_datetime_attribute( + '', + '', + '', + True, + '2020-10-15T06:38:00.000+00:00', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_email_attribute(self, m): + data = { + "key": "userEmail", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "email" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_email_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_email_attribute(self, m): + data = { + "key": "userEmail", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "email" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_email_attribute( + '', + '', + '', + True, + 'email@example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_enum_attribute(self, m): + data = { + "key": "status", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "elements": [], + "format": "enum" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_enum_attribute( + '', + '', + '', + [], + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_enum_attribute(self, m): + data = { + "key": "status", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "elements": [], + "format": "enum" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_enum_attribute( + '', + '', + '', + [], + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_float_attribute(self, m): + data = { + "key": "percentageCompleted", + "type": "double", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_float_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_float_attribute(self, m): + data = { + "key": "percentageCompleted", + "type": "double", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_float_attribute( + '', + '', + '', + True, + 1.0, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_integer_attribute(self, m): + data = { + "key": "count", + "type": "integer", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_integer_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_integer_attribute(self, m): + data = { + "key": "count", + "type": "integer", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_integer_attribute( + '', + '', + '', + True, + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_ip_attribute(self, m): + data = { + "key": "ipAddress", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "ip" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_ip_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_ip_attribute(self, m): + data = { + "key": "ipAddress", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "ip" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_ip_attribute( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_line_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_line_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_line_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_line_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_longtext_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_longtext_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_longtext_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_longtext_attribute( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mediumtext_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_mediumtext_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mediumtext_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_mediumtext_attribute( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_point_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_point_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_point_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_point_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_polygon_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_polygon_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_polygon_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_polygon_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_relationship_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "relatedCollection": "collection", + "relationType": "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay": True, + "twoWayKey": "string", + "onDelete": "restrict|cascade|setNull", + "side": "parent|child" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_relationship_attribute( + '', + '', + '', + 'oneToOne', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_relationship_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "relatedCollection": "collection", + "relationType": "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay": True, + "twoWayKey": "string", + "onDelete": "restrict|cascade|setNull", + "side": "parent|child" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_relationship_attribute( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_string_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "size": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_string_attribute( + '', + '', + '', + 1, + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_string_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "size": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_string_attribute( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_text_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_text_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_text_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_text_attribute( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_url_attribute(self, m): + data = { + "key": "githubUrl", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "url" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_url_attribute( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_url_attribute(self, m): + data = { + "key": "githubUrl", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "url" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_url_attribute( + '', + '', + '', + True, + 'https://example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_varchar_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "size": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_varchar_attribute( + '', + '', + '', + 1, + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_varchar_attribute(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "size": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_varchar_attribute( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_attribute(self, m): + data = { + "key": "isEnabled", + "type": "boolean", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.get_attribute( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_attribute(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.delete_attribute( + '', + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_documents(self, m): + data = { + "total": 5.0, + "documents": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.list_documents( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_document(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$collectionId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_document( + '', + '', + '', + {}, + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_documents(self, m): + data = { + "total": 5.0, + "documents": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_documents( + '', + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_upsert_documents(self, m): + data = { + "total": 5.0, + "documents": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.upsert_documents( + '', + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_documents(self, m): + data = { + "total": 5.0, + "documents": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_documents( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_documents(self, m): + data = { + "total": 5.0, + "documents": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.delete_documents( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_document(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$collectionId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.get_document( + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_upsert_document(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$collectionId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.upsert_document( + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_document(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$collectionId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.update_document( + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_document(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.delete_document( + '', + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_decrement_document_attribute(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$collectionId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.decrement_document_attribute( + '', + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_increment_document_attribute(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$collectionId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.increment_document_attribute( + '', + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_indexes(self, m): + data = { + "total": 5.0, + "indexes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.list_indexes( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_index(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "index1", + "type": "primary", + "status": "available", + "error": "string", + "attributes": [], + "lengths": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.create_index( + '', + '', + '', + 'key', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_index(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "index1", + "type": "primary", + "status": "available", + "error": "string", + "attributes": [], + "lengths": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.get_index( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_index(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.databases.delete_index( + '', + '', + '', + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_functions.py b/test/services/test_functions.py new file mode 100644 index 00000000..04fc26cb --- /dev/null +++ b/test/services/test_functions.py @@ -0,0 +1,723 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.functions import Functions + +class FunctionsServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.functions = Functions(self.client) + + @requests_mock.Mocker() + def test_list(self, m): + data = { + "total": 5.0, + "functions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.list( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "execute": [], + "name": "My Function", + "enabled": True, + "live": True, + "logging": True, + "runtime": "python-3.8", + "deploymentRetention": 7.0, + "deploymentId": "5e5ea5c16897e", + "deploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentId": "5e5ea5c16897e", + "latestDeploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentStatus": "ready", + "scopes": [], + "vars": [], + "events": [], + "schedule": "5 4 * * *", + "timeout": 300.0, + "entrypoint": "index.js", + "commands": "npm install", + "version": "v2", + "installationId": "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId": "appwrite", + "providerBranch": "main", + "providerRootDirectory": "functions\/helloWorld", + "providerSilentMode": True, + "buildSpecification": "s-1vcpu-512mb", + "runtimeSpecification": "s-1vcpu-512mb" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.create( + '', + '', + 'node-14.5', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_runtimes(self, m): + data = { + "total": 5.0, + "runtimes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.list_runtimes( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_specifications(self, m): + data = { + "total": 5.0, + "specifications": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.list_specifications( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "execute": [], + "name": "My Function", + "enabled": True, + "live": True, + "logging": True, + "runtime": "python-3.8", + "deploymentRetention": 7.0, + "deploymentId": "5e5ea5c16897e", + "deploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentId": "5e5ea5c16897e", + "latestDeploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentStatus": "ready", + "scopes": [], + "vars": [], + "events": [], + "schedule": "5 4 * * *", + "timeout": 300.0, + "entrypoint": "index.js", + "commands": "npm install", + "version": "v2", + "installationId": "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId": "appwrite", + "providerBranch": "main", + "providerRootDirectory": "functions\/helloWorld", + "providerSilentMode": True, + "buildSpecification": "s-1vcpu-512mb", + "runtimeSpecification": "s-1vcpu-512mb" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.get( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "execute": [], + "name": "My Function", + "enabled": True, + "live": True, + "logging": True, + "runtime": "python-3.8", + "deploymentRetention": 7.0, + "deploymentId": "5e5ea5c16897e", + "deploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentId": "5e5ea5c16897e", + "latestDeploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentStatus": "ready", + "scopes": [], + "vars": [], + "events": [], + "schedule": "5 4 * * *", + "timeout": 300.0, + "entrypoint": "index.js", + "commands": "npm install", + "version": "v2", + "installationId": "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId": "appwrite", + "providerBranch": "main", + "providerRootDirectory": "functions\/helloWorld", + "providerSilentMode": True, + "buildSpecification": "s-1vcpu-512mb", + "runtimeSpecification": "s-1vcpu-512mb" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.update( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.delete( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_function_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "execute": [], + "name": "My Function", + "enabled": True, + "live": True, + "logging": True, + "runtime": "python-3.8", + "deploymentRetention": 7.0, + "deploymentId": "5e5ea5c16897e", + "deploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentId": "5e5ea5c16897e", + "latestDeploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentStatus": "ready", + "scopes": [], + "vars": [], + "events": [], + "schedule": "5 4 * * *", + "timeout": 300.0, + "entrypoint": "index.js", + "commands": "npm install", + "version": "v2", + "installationId": "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId": "appwrite", + "providerBranch": "main", + "providerRootDirectory": "functions\/helloWorld", + "providerSilentMode": True, + "buildSpecification": "s-1vcpu-512mb", + "runtimeSpecification": "s-1vcpu-512mb" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.update_function_deployment( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_deployments(self, m): + data = { + "total": 5.0, + "deployments": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.list_deployments( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.create_deployment( + '', + InputFile.from_bytes(bytearray(), "example.file"), + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_duplicate_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.create_duplicate_deployment( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_template_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.create_template_deployment( + '', + '', + '', + '', + 'commit', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_vcs_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.create_vcs_deployment( + '', + 'branch', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.get_deployment( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_deployment(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.delete_deployment( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_deployment_download(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.functions.get_deployment_download( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_deployment_status(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.update_deployment_status( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_executions(self, m): + data = { + "total": 5.0, + "executions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.list_executions( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_execution(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "functionId": "5e5ea6g16897e", + "deploymentId": "5e5ea5c16897e", + "trigger": "http", + "status": "processing", + "requestMethod": "GET", + "requestPath": "\/articles?id=5", + "requestHeaders": [], + "responseStatusCode": 200.0, + "responseBody": "", + "responseHeaders": [], + "logs": "", + "errors": "", + "duration": 0.4 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.create_execution( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_execution(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "functionId": "5e5ea6g16897e", + "deploymentId": "5e5ea5c16897e", + "trigger": "http", + "status": "processing", + "requestMethod": "GET", + "requestPath": "\/articles?id=5", + "requestHeaders": [], + "responseStatusCode": 200.0, + "responseBody": "", + "responseHeaders": [], + "logs": "", + "errors": "", + "duration": 0.4 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.get_execution( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_execution(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.delete_execution( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_variables(self, m): + data = { + "total": 5.0, + "variables": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.list_variables( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_variable(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "API_KEY", + "value": "myPa$$word1", + "secret": True, + "resourceType": "function", + "resourceId": "myAwesomeFunction" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.create_variable( + '', + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_variable(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "API_KEY", + "value": "myPa$$word1", + "secret": True, + "resourceType": "function", + "resourceId": "myAwesomeFunction" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.get_variable( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_variable(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "API_KEY", + "value": "myPa$$word1", + "secret": True, + "resourceType": "function", + "resourceId": "myAwesomeFunction" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.update_variable( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_variable(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.functions.delete_variable( + '', + '', + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_graphql.py b/test/services/test_graphql.py new file mode 100644 index 00000000..72a69f46 --- /dev/null +++ b/test/services/test_graphql.py @@ -0,0 +1,39 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.graphql import Graphql + +class GraphqlServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.graphql = Graphql(self.client) + + @requests_mock.Mocker() + def test_query(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.graphql.query( + {}, + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_mutation(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.graphql.mutation( + {}, + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_health.py b/test/services/test_health.py new file mode 100644 index 00000000..1670be8f --- /dev/null +++ b/test/services/test_health.py @@ -0,0 +1,347 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.health import Health + +class HealthServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.health = Health(self.client) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "name": "database", + "ping": 128.0, + "status": "pass" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_antivirus(self, m): + data = { + "version": "1.0.0", + "status": "online" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_antivirus( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_cache(self, m): + data = { + "total": 5.0, + "statuses": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_cache( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_certificate(self, m): + data = { + "name": "\/CN=www.google.com", + "subjectSN": "", + "issuerOrganisation": "", + "validFrom": "1704200998", + "validTo": "1711458597", + "signatureTypeSN": "RSA-SHA256" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_certificate( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_console_pausing(self, m): + data = { + "name": "database", + "ping": 128.0, + "status": "pass" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_console_pausing( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_db(self, m): + data = { + "total": 5.0, + "statuses": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_db( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_pub_sub(self, m): + data = { + "total": 5.0, + "statuses": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_pub_sub( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_audits(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_audits( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_builds(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_builds( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_certificates(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_certificates( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_databases(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_databases( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_deletes(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_deletes( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_failed_jobs(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_failed_jobs( + 'v1-database', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_functions(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_functions( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_logs(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_logs( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_mails(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_mails( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_messaging(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_messaging( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_migrations(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_migrations( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_stats_resources(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_stats_resources( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_usage(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_usage( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_queue_webhooks(self, m): + data = { + "size": 8.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_queue_webhooks( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_storage(self, m): + data = { + "name": "database", + "ping": 128.0, + "status": "pass" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_storage( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_storage_local(self, m): + data = { + "name": "database", + "ping": 128.0, + "status": "pass" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_storage_local( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_time(self, m): + data = { + "remoteTime": 1639490751.0, + "localTime": 1639490844.0, + "diff": 93.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.health.get_time( + ) + + self.assertEqual(response.to_dict(), data) + diff --git a/test/services/test_locale.py b/test/services/test_locale.py new file mode 100644 index 00000000..00c016f1 --- /dev/null +++ b/test/services/test_locale.py @@ -0,0 +1,132 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.locale import Locale + +class LocaleServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.locale = Locale(self.client) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "ip": "127.0.0.1", + "countryCode": "US", + "country": "United States", + "continentCode": "NA", + "continent": "North America", + "eu": True, + "currency": "USD" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.locale.get( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_codes(self, m): + data = { + "total": 5.0, + "localeCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.locale.list_codes( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_continents(self, m): + data = { + "total": 5.0, + "continents": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.locale.list_continents( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_countries(self, m): + data = { + "total": 5.0, + "countries": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.locale.list_countries( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_countries_eu(self, m): + data = { + "total": 5.0, + "countries": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.locale.list_countries_eu( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_countries_phones(self, m): + data = { + "total": 5.0, + "phones": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.locale.list_countries_phones( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_currencies(self, m): + data = { + "total": 5.0, + "currencies": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.locale.list_currencies( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_languages(self, m): + data = { + "total": 5.0, + "languages": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.locale.list_languages( + ) + + self.assertEqual(response.to_dict(), data) + diff --git a/test/services/test_messaging.py b/test/services/test_messaging.py new file mode 100644 index 00000000..329991a3 --- /dev/null +++ b/test/services/test_messaging.py @@ -0,0 +1,1161 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.messaging import Messaging + +class MessagingServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.messaging = Messaging(self.client) + + @requests_mock.Mocker() + def test_list_messages(self, m): + data = { + "total": 5.0, + "messages": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.list_messages( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_email(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "providerType": "email", + "topics": [], + "users": [], + "targets": [], + "deliveredTotal": 1.0, + "data": {}, + "status": "processing" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_email( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_email(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "providerType": "email", + "topics": [], + "users": [], + "targets": [], + "deliveredTotal": 1.0, + "data": {}, + "status": "processing" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_email( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_push(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "providerType": "email", + "topics": [], + "users": [], + "targets": [], + "deliveredTotal": 1.0, + "data": {}, + "status": "processing" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_push( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_push(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "providerType": "email", + "topics": [], + "users": [], + "targets": [], + "deliveredTotal": 1.0, + "data": {}, + "status": "processing" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_push( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_sms(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "providerType": "email", + "topics": [], + "users": [], + "targets": [], + "deliveredTotal": 1.0, + "data": {}, + "status": "processing" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_sms( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_sms(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "providerType": "email", + "topics": [], + "users": [], + "targets": [], + "deliveredTotal": 1.0, + "data": {}, + "status": "processing" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_sms( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_sms(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "providerType": "email", + "topics": [], + "users": [], + "targets": [], + "deliveredTotal": 1.0, + "data": {}, + "status": "processing" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_sms( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_sms(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "providerType": "email", + "topics": [], + "users": [], + "targets": [], + "deliveredTotal": 1.0, + "data": {}, + "status": "processing" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_sms( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_message(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "providerType": "email", + "topics": [], + "users": [], + "targets": [], + "deliveredTotal": 1.0, + "data": {}, + "status": "processing" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.get_message( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.delete( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_message_logs(self, m): + data = { + "total": 5.0, + "logs": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.list_message_logs( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_targets(self, m): + data = { + "total": 5.0, + "targets": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.list_targets( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_providers(self, m): + data = { + "total": 5.0, + "providers": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.list_providers( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_apns_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_apns_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_apns_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_apns_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_apns_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_apns_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_apns_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_apns_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_fcm_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_fcm_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_fcm_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_fcm_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_fcm_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_fcm_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_fcm_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_fcm_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mailgun_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_mailgun_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mailgun_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_mailgun_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_msg91_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_msg91_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_msg91_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_msg91_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_resend_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_resend_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_resend_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_resend_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_sendgrid_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_sendgrid_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_sendgrid_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_sendgrid_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_smtp_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_smtp_provider( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_smtp_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_smtp_provider( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_smtp_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_smtp_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_smtp_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_smtp_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_telesign_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_telesign_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_telesign_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_telesign_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_textmagic_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_textmagic_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_textmagic_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_textmagic_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_twilio_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_twilio_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_twilio_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_twilio_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_vonage_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_vonage_provider( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_vonage_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_vonage_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_provider(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Mailgun", + "provider": "mailgun", + "enabled": True, + "type": "sms", + "credentials": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.get_provider( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_provider(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.delete_provider( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_provider_logs(self, m): + data = { + "total": 5.0, + "logs": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.list_provider_logs( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_subscriber_logs(self, m): + data = { + "total": 5.0, + "logs": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.list_subscriber_logs( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_topics(self, m): + data = { + "total": 5.0, + "topics": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.list_topics( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_topic(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "events", + "emailTotal": 100.0, + "smsTotal": 100.0, + "pushTotal": 100.0, + "subscribe": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_topic( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_topic(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "events", + "emailTotal": 100.0, + "smsTotal": 100.0, + "pushTotal": 100.0, + "subscribe": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.get_topic( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_topic(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "events", + "emailTotal": 100.0, + "smsTotal": 100.0, + "pushTotal": 100.0, + "subscribe": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.update_topic( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_topic(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.delete_topic( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_topic_logs(self, m): + data = { + "total": 5.0, + "logs": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.list_topic_logs( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_subscribers(self, m): + data = { + "total": 5.0, + "subscribers": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.list_subscribers( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_subscriber(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "targetId": "259125845563242502", + "target": { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Apple iPhone 12", + "userId": "259125845563242502", + "providerType": "email", + "identifier": "token", + "expired": True + }, + "userId": "5e5ea5c16897e", + "userName": "Aegon Targaryen", + "topicId": "259125845563242502", + "providerType": "email" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.create_subscriber( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_subscriber(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "targetId": "259125845563242502", + "target": { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Apple iPhone 12", + "userId": "259125845563242502", + "providerType": "email", + "identifier": "token", + "expired": True + }, + "userId": "5e5ea5c16897e", + "userName": "Aegon Targaryen", + "topicId": "259125845563242502", + "providerType": "email" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.get_subscriber( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_subscriber(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.messaging.delete_subscriber( + '', + '', + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_presences.py b/test/services/test_presences.py new file mode 100644 index 00000000..136cf33c --- /dev/null +++ b/test/services/test_presences.py @@ -0,0 +1,107 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.presences import Presences + +class PresencesServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.presences = Presences(self.client) + + @requests_mock.Mocker() + def test_list(self, m): + data = { + "total": 5.0, + "presences": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.presences.list( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "userInternalId": "1", + "userId": "674af8f3e12a5f9ac0be", + "source": "HTTP" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.presences.get( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_upsert(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "userInternalId": "1", + "userId": "674af8f3e12a5f9ac0be", + "source": "HTTP" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.presences.upsert( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_presence(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "userInternalId": "1", + "userId": "674af8f3e12a5f9ac0be", + "source": "HTTP" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.presences.update_presence( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.presences.delete( + '', + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_project.py b/test/services/test_project.py new file mode 100644 index 00000000..1aa82ba1 --- /dev/null +++ b/test/services/test_project.py @@ -0,0 +1,2828 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.project import Project + +class ProjectServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.project = Project(self.client) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.delete( + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_auth_method(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_auth_method( + 'email-password', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_keys(self, m): + data = { + "total": 5.0, + "keys": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.list_keys( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_key(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My API Key", + "expire": "2020-10-15T06:38:00.000+00:00", + "scopes": [], + "secret": "919c2d18fb5d4...a2ae413da83346ad2", + "accessedAt": "2020-10-15T06:38:00.000+00:00", + "sdks": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_key( + '', + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_ephemeral_key(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My API Key", + "expire": "2020-10-15T06:38:00.000+00:00", + "scopes": [], + "secret": "919c2d18fb5d4...a2ae413da83346ad2", + "accessedAt": "2020-10-15T06:38:00.000+00:00", + "sdks": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_ephemeral_key( + [], + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_key(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My API Key", + "expire": "2020-10-15T06:38:00.000+00:00", + "scopes": [], + "secret": "919c2d18fb5d4...a2ae413da83346ad2", + "accessedAt": "2020-10-15T06:38:00.000+00:00", + "sdks": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.get_key( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_key(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My API Key", + "expire": "2020-10-15T06:38:00.000+00:00", + "scopes": [], + "secret": "919c2d18fb5d4...a2ae413da83346ad2", + "accessedAt": "2020-10-15T06:38:00.000+00:00", + "sdks": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_key( + '', + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_key(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.delete_key( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_labels(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_labels( + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_mock_phones(self, m): + data = { + "total": 5.0, + "mockNumbers": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.list_mock_phones( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mock_phone(self, m): + data = { + "number": "+1612842323", + "otp": "123456", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_mock_phone( + '+12065550100', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_mock_phone(self, m): + data = { + "number": "+1612842323", + "otp": "123456", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.get_mock_phone( + '+12065550100', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mock_phone(self, m): + data = { + "number": "+1612842323", + "otp": "123456", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_mock_phone( + '+12065550100', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_mock_phone(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.delete_mock_phone( + '+12065550100', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_o_auth2_providers(self, m): + data = { + "total": 5.0, + "providers": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.list_o_auth2_providers( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_o_auth2_provider(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "e4d87900000000540733", + "clientSecret": "5e07c00000000000000000000000000000198bcc" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.get_o_auth2_provider( + 'amazon', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_amazon(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "amzn1.application-oa2-client.87400c00000000000000000000063d5b2", + "clientSecret": "79ffe4000000000000000000000000000000000000000000000000000002de55" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_amazon( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_apple(self, m): + data = { + "$id": "apple", + "enabled": True, + "serviceId": "ip.appwrite.app.web", + "keyId": "P4000000N8", + "teamId": "D4000000R6", + "p8File": "-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_apple( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_auth0(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "OaOkIA000000000000000000005KLSYq", + "clientSecret": "zXz0000-00000000000000000000000000000-00000000000000000000PJafnF", + "endpoint": "example.us.auth0.com" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_auth0( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_authentik(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "dTKOPa0000000000000000000000000000e7G8hv", + "clientSecret": "ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK", + "endpoint": "example.authentik.com" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_authentik( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_autodesk(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "5zw90v00000000000000000000kVYXN7", + "clientSecret": "7I000000000000MW" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_autodesk( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_bitbucket(self, m): + data = { + "$id": "github", + "enabled": True, + "key": "Knt70000000000ByRc", + "secret": "NMfLZJ00000000000000000000TLQdDx" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_bitbucket( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_bitly(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "d95151000000000000000000000000000067af9b", + "clientSecret": "a13e250000000000000000000000000000d73095" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_bitly( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_box(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "deglcs00000000000000000000x2og6y", + "clientSecret": "OKM1f100000000000000000000eshEif" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_box( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_dailymotion(self, m): + data = { + "$id": "github", + "enabled": True, + "apiKey": "07a9000000000000067f", + "apiSecret": "a399a90000000000000000000000000000d90639" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_dailymotion( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_discord(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "950722000000343754", + "clientSecret": "YmPXnM000000000000000000002zFg5D" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_discord( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_disqus(self, m): + data = { + "$id": "github", + "enabled": True, + "publicKey": "cgegH70000000000000000000000000000000000000000000000000000Hr1nYX", + "secretKey": "W7Bykj00000000000000000000000000000000000000000000000000003o43w9" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_disqus( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_dropbox(self, m): + data = { + "$id": "github", + "enabled": True, + "appKey": "jl000000000009t", + "appSecret": "g200000000000vw" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_dropbox( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_etsy(self, m): + data = { + "$id": "github", + "enabled": True, + "keyString": "nsgzxh0000000000008j85a2", + "sharedSecret": "tp000000ru" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_etsy( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_facebook(self, m): + data = { + "$id": "github", + "enabled": True, + "appId": "260600000007694", + "appSecret": "2d0b2800000000000000000000d38af4" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_facebook( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_figma(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "byay5H0000000000VtiI40", + "clientSecret": "yEpOYn0000000000000000004iIsU5" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_figma( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_fusion_auth(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "b2222c00-0000-0000-0000-000000862097", + "clientSecret": "Jx4s0C0000000000000000000000000000000wGqLsc", + "endpoint": "example.fusionauth.io" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_fusion_auth( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_git_hub(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "e4d87900000000540733", + "clientSecret": "5e07c00000000000000000000000000000198bcc" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_git_hub( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_gitlab(self, m): + data = { + "$id": "github", + "enabled": True, + "applicationId": "d41ffe0000000000000000000000000000000000000000000000000000d5e252", + "secret": "gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38", + "endpoint": "https:\/\/gitlab.com" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_gitlab( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_google(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "your-google-client-id.apps.googleusercontent.com", + "clientSecret": "your-google-client-secret" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_google( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_keycloak(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "appwrite-o0000000st-app", + "clientSecret": "jdjrJd00000000000000000000HUsaZO", + "endpoint": "keycloak.example.com", + "realmName": "appwrite-realm" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_keycloak( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_kick(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "01KQ7C00000000000001MFHS32", + "clientSecret": "34ac5600000000000000000000000000000000000000000000000000e830c8b" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_kick( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_linkedin(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "770000000000dv", + "primaryClientSecret": "your-linkedin-client-secret\/HtlYw==" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_linkedin( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_microsoft(self, m): + data = { + "$id": "github", + "enabled": True, + "applicationId": "00001111-aaaa-2222-bbbb-3333cccc4444", + "applicationSecret": "A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u", + "tenant": "common" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_microsoft( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_notion(self, m): + data = { + "$id": "github", + "enabled": True, + "oauthClientId": "341d8700-0000-0000-0000-000000446ee3", + "oauthClientSecret": "secret_dLUr4b000000000000000000000000000000lFHAa9" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_notion( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_oidc(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "qibI2x0000000000000000000000000006L2YFoG", + "clientSecret": "Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV", + "wellKnownURL": "https:\/\/myoauth.com\/.well-known\/openid-configuration", + "authorizationURL": "https:\/\/myoauth.com\/oauth2\/authorize", + "tokenURL": "https:\/\/myoauth.com\/oauth2\/token", + "userInfoURL": "https:\/\/myoauth.com\/oauth2\/userinfo" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_oidc( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_okta(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "0oa00000000000000698", + "clientSecret": "Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV", + "domain": "trial-6400025.okta.com", + "authorizationServerId": "aus000000000000000h7z" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_okta( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_paypal(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB", + "secretKey": "EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_paypal( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_paypal_sandbox(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB", + "secretKey": "EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_paypal_sandbox( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_podio(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "appwrite-oauth-test-app", + "clientSecret": "Rn247T0000000000000000000000000000000000000000000000000000W2zWTN" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_podio( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_salesforce(self, m): + data = { + "$id": "github", + "enabled": True, + "customerKey": "3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq", + "customerSecret": "3w000000000000e2" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_salesforce( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_slack(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "23000000089.15000000000023", + "clientSecret": "81656000000000000000000000f3d2fd" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_slack( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_spotify(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "6ec271000000000000000000009beace", + "clientSecret": "db068a000000000000000000008b5b9f" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_spotify( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_stripe(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "ca_UKibXX0000000000000000000006byvR", + "apiSecretKey": "sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_stripe( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_tradeshift(self, m): + data = { + "$id": "github", + "enabled": True, + "oauth2ClientId": "appwrite-test-org.appwrite-test-app", + "oauth2ClientSecret": "7cb52700-0000-0000-0000-000000ca5b83" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_tradeshift( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_tradeshift_sandbox(self, m): + data = { + "$id": "github", + "enabled": True, + "oauth2ClientId": "appwrite-test-org.appwrite-test-app", + "oauth2ClientSecret": "7cb52700-0000-0000-0000-000000ca5b83" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_tradeshift_sandbox( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_twitch(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "vvi0in000000000000000000ikmt9p", + "clientSecret": "pmapue000000000000000000zylw3v" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_twitch( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_word_press(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "130005", + "clientSecret": "PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_word_press( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_x(self, m): + data = { + "$id": "github", + "enabled": True, + "customerKey": "slzZV0000000000000NFLaWT", + "secretKey": "tkEPkp00000000000000000000000000000000000000FTxbI9" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_x( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_yahoo(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm", + "clientSecret": "cf978f0000000000000000000000000000c5e2e9" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_yahoo( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_yandex(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "6a8a6a0000000000000000000091483c", + "clientSecret": "bbf98500000000000000000000c75a63" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_yandex( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_zoho(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "1000.83C178000000000000000000RPNX0B", + "clientSecret": "fb5cac000000000000000000000000000000a68f6e" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_zoho( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_o_auth2_zoom(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "QMAC00000000000000w0AQ", + "clientSecret": "GAWsG4000000000000000000007U01ON" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_o_auth2_zoom( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_platforms(self, m): + data = { + "total": 5.0, + "platforms": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.list_platforms( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_android_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "applicationId": "com.company.appname" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_android_platform( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_android_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "applicationId": "com.company.appname" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_android_platform( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_apple_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "bundleIdentifier": "com.company.appname" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_apple_platform( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_apple_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "bundleIdentifier": "com.company.appname" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_apple_platform( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_linux_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "packageName": "com.company.appname" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_linux_platform( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_linux_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "packageName": "com.company.appname" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_linux_platform( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_web_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "hostname": "app.example.com" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_web_platform( + '', + '', + 'app.example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_web_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "hostname": "app.example.com" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_web_platform( + '', + '', + 'app.example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_windows_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "packageIdentifierName": "com.company.appname" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_windows_platform( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_windows_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "packageIdentifierName": "com.company.appname" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_windows_platform( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_platform(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Web App", + "type": "web", + "hostname": "app.example.com" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.get_platform( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_platform(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.delete_platform( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_policies(self, m): + data = { + "total": 9.0, + "policies": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.list_policies( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_membership_privacy_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_membership_privacy_policy( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_password_dictionary_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_password_dictionary_policy( + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_password_history_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_password_history_policy( + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_password_personal_data_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_password_personal_data_policy( + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_session_alert_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_session_alert_policy( + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_session_duration_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_session_duration_policy( + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_session_invalidation_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_session_invalidation_policy( + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_session_limit_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_session_limit_policy( + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_user_limit_policy(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_user_limit_policy( + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_policy(self, m): + data = { + "$id": "password-dictionary", + "enabled": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.get_policy( + 'password-dictionary', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_protocol(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_protocol( + 'rest', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_service(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_service( + 'account', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_smtp(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "description": "This is a new project.", + "teamId": "1592981250", + "logo": "5f5c451b403cb", + "url": "5f5c451b403cb", + "legalName": "Company LTD.", + "legalCountry": "US", + "legalState": "New York", + "legalCity": "New York City.", + "legalAddress": "620 Eighth Avenue, New York, NY 10018", + "legalTaxId": "131102020", + "authDuration": 60.0, + "authLimit": 100.0, + "authSessionsLimit": 10.0, + "authPasswordHistory": 5.0, + "authPasswordDictionary": True, + "authPersonalDataCheck": True, + "authDisposableEmails": True, + "authCanonicalEmails": True, + "authFreeEmails": True, + "authMockNumbers": [], + "authSessionAlerts": True, + "authMembershipsUserName": True, + "authMembershipsUserEmail": True, + "authMembershipsMfa": True, + "authMembershipsUserId": True, + "authMembershipsUserPhone": True, + "authInvalidateSessions": True, + "oAuthProviders": [], + "platforms": [], + "webhooks": [], + "keys": [], + "devKeys": [], + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "", + "smtpSecure": "tls", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "authEmailPassword": True, + "authUsersAuthMagicURL": True, + "authEmailOtp": True, + "authAnonymous": True, + "authInvites": True, + "authJWT": True, + "authPhone": True, + "serviceStatusForAccount": True, + "serviceStatusForAvatars": True, + "serviceStatusForDatabases": True, + "serviceStatusForTablesdb": True, + "serviceStatusForLocale": True, + "serviceStatusForHealth": True, + "serviceStatusForProject": True, + "serviceStatusForStorage": True, + "serviceStatusForTeams": True, + "serviceStatusForUsers": True, + "serviceStatusForVcs": True, + "serviceStatusForSites": True, + "serviceStatusForFunctions": True, + "serviceStatusForProxy": True, + "serviceStatusForGraphql": True, + "serviceStatusForMigrations": True, + "serviceStatusForMessaging": True, + "protocolStatusForRest": True, + "protocolStatusForGraphql": True, + "protocolStatusForWebsocket": True, + "region": "fra", + "billingLimits": { + "bandwidth": 5.0, + "storage": 150.0, + "users": 200000.0, + "executions": 750000.0, + "GBHours": 100.0, + "imageTransformations": 100.0, + "authPhone": 10.0, + "budgetLimit": 100.0 + }, + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_smtp( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_smtp_test(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_smtp_test( + [], + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_email_templates(self, m): + data = { + "total": 5.0, + "templates": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.list_email_templates( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_email_template(self, m): + data = { + "templateId": "verification", + "locale": "en_us", + "message": "Click on the link to verify your account.", + "senderName": "My User", + "senderEmail": "mail@appwrite.io", + "replyToEmail": "emails@appwrite.io", + "replyToName": "Support Team", + "subject": "Please verify your email address" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_email_template( + 'verification', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_email_template(self, m): + data = { + "templateId": "verification", + "locale": "en_us", + "message": "Click on the link to verify your account.", + "senderName": "My User", + "senderEmail": "mail@appwrite.io", + "replyToEmail": "emails@appwrite.io", + "replyToName": "Support Team", + "subject": "Please verify your email address" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.get_email_template( + 'verification', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_variables(self, m): + data = { + "total": 5.0, + "variables": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.list_variables( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_variable(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "API_KEY", + "value": "myPa$$word1", + "secret": True, + "resourceType": "function", + "resourceId": "myAwesomeFunction" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.create_variable( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_variable(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "API_KEY", + "value": "myPa$$word1", + "secret": True, + "resourceType": "function", + "resourceId": "myAwesomeFunction" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.get_variable( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_variable(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "API_KEY", + "value": "myPa$$word1", + "secret": True, + "resourceType": "function", + "resourceId": "myAwesomeFunction" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.update_variable( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_variable(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.project.delete_variable( + '', + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_proxy.py b/test/services/test_proxy.py new file mode 100644 index 00000000..5da8c18c --- /dev/null +++ b/test/services/test_proxy.py @@ -0,0 +1,209 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.proxy import Proxy + +class ProxyServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.proxy = Proxy(self.client) + + @requests_mock.Mocker() + def test_list_rules(self, m): + data = { + "total": 5.0, + "rules": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.proxy.list_rules( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_api_rule(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "domain": "appwrite.company.com", + "type": "deployment", + "trigger": "manual", + "redirectUrl": "https:\/\/appwrite.io\/docs", + "redirectStatusCode": 301.0, + "deploymentId": "n3u9feiwmf", + "deploymentResourceId": "n3u9feiwmf", + "deploymentVcsProviderBranch": "main", + "status": "verified", + "logs": "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", + "renewAt": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.proxy.create_api_rule( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_function_rule(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "domain": "appwrite.company.com", + "type": "deployment", + "trigger": "manual", + "redirectUrl": "https:\/\/appwrite.io\/docs", + "redirectStatusCode": 301.0, + "deploymentId": "n3u9feiwmf", + "deploymentResourceId": "n3u9feiwmf", + "deploymentVcsProviderBranch": "main", + "status": "verified", + "logs": "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", + "renewAt": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.proxy.create_function_rule( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_redirect_rule(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "domain": "appwrite.company.com", + "type": "deployment", + "trigger": "manual", + "redirectUrl": "https:\/\/appwrite.io\/docs", + "redirectStatusCode": 301.0, + "deploymentId": "n3u9feiwmf", + "deploymentResourceId": "n3u9feiwmf", + "deploymentVcsProviderBranch": "main", + "status": "verified", + "logs": "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", + "renewAt": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.proxy.create_redirect_rule( + '', + 'https://example.com', + '301', + '', + 'site', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_site_rule(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "domain": "appwrite.company.com", + "type": "deployment", + "trigger": "manual", + "redirectUrl": "https:\/\/appwrite.io\/docs", + "redirectStatusCode": 301.0, + "deploymentId": "n3u9feiwmf", + "deploymentResourceId": "n3u9feiwmf", + "deploymentVcsProviderBranch": "main", + "status": "verified", + "logs": "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", + "renewAt": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.proxy.create_site_rule( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_rule(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "domain": "appwrite.company.com", + "type": "deployment", + "trigger": "manual", + "redirectUrl": "https:\/\/appwrite.io\/docs", + "redirectStatusCode": 301.0, + "deploymentId": "n3u9feiwmf", + "deploymentResourceId": "n3u9feiwmf", + "deploymentVcsProviderBranch": "main", + "status": "verified", + "logs": "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", + "renewAt": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.proxy.get_rule( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_rule(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.proxy.delete_rule( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_rule_status(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "domain": "appwrite.company.com", + "type": "deployment", + "trigger": "manual", + "redirectUrl": "https:\/\/appwrite.io\/docs", + "redirectStatusCode": 301.0, + "deploymentId": "n3u9feiwmf", + "deploymentResourceId": "n3u9feiwmf", + "deploymentVcsProviderBranch": "main", + "status": "verified", + "logs": "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", + "renewAt": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.proxy.update_rule_status( + '', + ) + + self.assertEqual(response.to_dict(), data) + diff --git a/test/services/test_sites.py b/test/services/test_sites.py new file mode 100644 index 00000000..4f83b6f2 --- /dev/null +++ b/test/services/test_sites.py @@ -0,0 +1,702 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.sites import Sites + +class SitesServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.sites = Sites(self.client) + + @requests_mock.Mocker() + def test_list(self, m): + data = { + "total": 5.0, + "sites": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.list( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Site", + "enabled": True, + "live": True, + "logging": True, + "framework": "react", + "deploymentRetention": 7.0, + "deploymentId": "5e5ea5c16897e", + "deploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "deploymentScreenshotLight": "5e5ea5c16897e", + "deploymentScreenshotDark": "5e5ea5c16897e", + "latestDeploymentId": "5e5ea5c16897e", + "latestDeploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentStatus": "ready", + "vars": [], + "timeout": 300.0, + "installCommand": "npm install", + "buildCommand": "npm run build", + "startCommand": "node custom-server.mjs", + "outputDirectory": "build", + "installationId": "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId": "appwrite", + "providerBranch": "main", + "providerRootDirectory": "sites\/helloWorld", + "providerSilentMode": True, + "buildSpecification": "s-1vcpu-512mb", + "runtimeSpecification": "s-1vcpu-512mb", + "buildRuntime": "node-22", + "adapter": "static", + "fallbackFile": "index.html" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.create( + '', + '', + 'analog', + 'node-14.5', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_frameworks(self, m): + data = { + "total": 5.0, + "frameworks": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.list_frameworks( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_specifications(self, m): + data = { + "total": 5.0, + "specifications": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.list_specifications( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Site", + "enabled": True, + "live": True, + "logging": True, + "framework": "react", + "deploymentRetention": 7.0, + "deploymentId": "5e5ea5c16897e", + "deploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "deploymentScreenshotLight": "5e5ea5c16897e", + "deploymentScreenshotDark": "5e5ea5c16897e", + "latestDeploymentId": "5e5ea5c16897e", + "latestDeploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentStatus": "ready", + "vars": [], + "timeout": 300.0, + "installCommand": "npm install", + "buildCommand": "npm run build", + "startCommand": "node custom-server.mjs", + "outputDirectory": "build", + "installationId": "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId": "appwrite", + "providerBranch": "main", + "providerRootDirectory": "sites\/helloWorld", + "providerSilentMode": True, + "buildSpecification": "s-1vcpu-512mb", + "runtimeSpecification": "s-1vcpu-512mb", + "buildRuntime": "node-22", + "adapter": "static", + "fallbackFile": "index.html" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.get( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Site", + "enabled": True, + "live": True, + "logging": True, + "framework": "react", + "deploymentRetention": 7.0, + "deploymentId": "5e5ea5c16897e", + "deploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "deploymentScreenshotLight": "5e5ea5c16897e", + "deploymentScreenshotDark": "5e5ea5c16897e", + "latestDeploymentId": "5e5ea5c16897e", + "latestDeploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentStatus": "ready", + "vars": [], + "timeout": 300.0, + "installCommand": "npm install", + "buildCommand": "npm run build", + "startCommand": "node custom-server.mjs", + "outputDirectory": "build", + "installationId": "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId": "appwrite", + "providerBranch": "main", + "providerRootDirectory": "sites\/helloWorld", + "providerSilentMode": True, + "buildSpecification": "s-1vcpu-512mb", + "runtimeSpecification": "s-1vcpu-512mb", + "buildRuntime": "node-22", + "adapter": "static", + "fallbackFile": "index.html" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.update( + '', + '', + 'analog', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.delete( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_site_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Site", + "enabled": True, + "live": True, + "logging": True, + "framework": "react", + "deploymentRetention": 7.0, + "deploymentId": "5e5ea5c16897e", + "deploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "deploymentScreenshotLight": "5e5ea5c16897e", + "deploymentScreenshotDark": "5e5ea5c16897e", + "latestDeploymentId": "5e5ea5c16897e", + "latestDeploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentStatus": "ready", + "vars": [], + "timeout": 300.0, + "installCommand": "npm install", + "buildCommand": "npm run build", + "startCommand": "node custom-server.mjs", + "outputDirectory": "build", + "installationId": "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId": "appwrite", + "providerBranch": "main", + "providerRootDirectory": "sites\/helloWorld", + "providerSilentMode": True, + "buildSpecification": "s-1vcpu-512mb", + "runtimeSpecification": "s-1vcpu-512mb", + "buildRuntime": "node-22", + "adapter": "static", + "fallbackFile": "index.html" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.update_site_deployment( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_deployments(self, m): + data = { + "total": 5.0, + "deployments": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.list_deployments( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.create_deployment( + '', + InputFile.from_bytes(bytearray(), "example.file"), + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_duplicate_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.create_duplicate_deployment( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_template_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.create_template_deployment( + '', + '', + '', + '', + 'branch', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_vcs_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.create_vcs_deployment( + '', + 'branch', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_deployment(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.get_deployment( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_deployment(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.delete_deployment( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_deployment_download(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.sites.get_deployment_download( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_deployment_status(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "type": "vcs", + "resourceId": "5e5ea6g16897e", + "resourceType": "functions", + "entrypoint": "index.js", + "sourceSize": 128.0, + "buildSize": 128.0, + "totalSize": 128.0, + "buildId": "5e5ea5c16897e", + "activate": True, + "screenshotLight": "5e5ea5c16897e", + "screenshotDark": "5e5ea5c16897e", + "status": "ready", + "buildLogs": "Compiling source files...", + "buildDuration": 128.0, + "providerRepositoryName": "database", + "providerRepositoryOwner": "utopia", + "providerRepositoryUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function", + "providerCommitHash": "7c3f25d", + "providerCommitAuthorUrl": "https:\/\/github.com\/vermakhushboo", + "providerCommitAuthor": "Khushboo Verma", + "providerCommitMessage": "Update index.js", + "providerCommitUrl": "https:\/\/github.com\/vermakhushboo\/g4-node-function\/commit\/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch": "0.7.x", + "providerBranchUrl": "https:\/\/github.com\/vermakhushboo\/appwrite\/tree\/0.7.x" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.update_deployment_status( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_logs(self, m): + data = { + "total": 5.0, + "executions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.list_logs( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_log(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "functionId": "5e5ea6g16897e", + "deploymentId": "5e5ea5c16897e", + "trigger": "http", + "status": "processing", + "requestMethod": "GET", + "requestPath": "\/articles?id=5", + "requestHeaders": [], + "responseStatusCode": 200.0, + "responseBody": "", + "responseHeaders": [], + "logs": "", + "errors": "", + "duration": 0.4 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.get_log( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_log(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.delete_log( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_variables(self, m): + data = { + "total": 5.0, + "variables": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.list_variables( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_variable(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "API_KEY", + "value": "myPa$$word1", + "secret": True, + "resourceType": "function", + "resourceId": "myAwesomeFunction" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.create_variable( + '', + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_variable(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "API_KEY", + "value": "myPa$$word1", + "secret": True, + "resourceType": "function", + "resourceId": "myAwesomeFunction" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.get_variable( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_variable(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "API_KEY", + "value": "myPa$$word1", + "secret": True, + "resourceType": "function", + "resourceId": "myAwesomeFunction" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.update_variable( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_variable(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.sites.delete_variable( + '', + '', + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_storage.py b/test/services/test_storage.py new file mode 100644 index 00000000..320a9275 --- /dev/null +++ b/test/services/test_storage.py @@ -0,0 +1,273 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.storage import Storage + +class StorageServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.storage = Storage(self.client) + + @requests_mock.Mocker() + def test_list_buckets(self, m): + data = { + "total": 5.0, + "buckets": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.list_buckets( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_bucket(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "fileSecurity": True, + "name": "Documents", + "enabled": True, + "maximumFileSize": 100.0, + "allowedFileExtensions": [], + "compression": "gzip", + "encryption": True, + "antivirus": True, + "transformations": True, + "totalSize": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.create_bucket( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_bucket(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "fileSecurity": True, + "name": "Documents", + "enabled": True, + "maximumFileSize": 100.0, + "allowedFileExtensions": [], + "compression": "gzip", + "encryption": True, + "antivirus": True, + "transformations": True, + "totalSize": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.get_bucket( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_bucket(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "fileSecurity": True, + "name": "Documents", + "enabled": True, + "maximumFileSize": 100.0, + "allowedFileExtensions": [], + "compression": "gzip", + "encryption": True, + "antivirus": True, + "transformations": True, + "totalSize": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.update_bucket( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_bucket(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.delete_bucket( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_files(self, m): + data = { + "total": 5.0, + "files": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.list_files( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_file(self, m): + data = { + "$id": "5e5ea5c16897e", + "bucketId": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "name": "Pink.png", + "signature": "5d529fd02b544198ae075bd57c1762bb", + "mimeType": "image\/png", + "sizeOriginal": 17890.0, + "chunksTotal": 17890.0, + "chunksUploaded": 17890.0, + "encryption": True, + "compression": "gzip" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.create_file( + '', + '', + InputFile.from_bytes(bytearray(), "example.file"), + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_file(self, m): + data = { + "$id": "5e5ea5c16897e", + "bucketId": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "name": "Pink.png", + "signature": "5d529fd02b544198ae075bd57c1762bb", + "mimeType": "image\/png", + "sizeOriginal": 17890.0, + "chunksTotal": 17890.0, + "chunksUploaded": 17890.0, + "encryption": True, + "compression": "gzip" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.get_file( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_file(self, m): + data = { + "$id": "5e5ea5c16897e", + "bucketId": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "name": "Pink.png", + "signature": "5d529fd02b544198ae075bd57c1762bb", + "mimeType": "image\/png", + "sizeOriginal": 17890.0, + "chunksTotal": 17890.0, + "chunksUploaded": 17890.0, + "encryption": True, + "compression": "gzip" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.update_file( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_file(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.storage.delete_file( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_file_download(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.storage.get_file_download( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_file_preview(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.storage.get_file_preview( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_get_file_view(self, m): + data = bytearray() + headers = {'Content-Type': 'application/octet-stream'} + m.request(requests_mock.ANY, requests_mock.ANY, body=data, headers=headers) + + response = self.storage.get_file_view( + '', + '', + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_tables_db.py b/test/services/test_tables_db.py new file mode 100644 index 00000000..7f2ecabf --- /dev/null +++ b/test/services/test_tables_db.py @@ -0,0 +1,1555 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.tables_db import TablesDB + +class TablesDBServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.tables_db = TablesDB(self.client) + + @requests_mock.Mocker() + def test_list(self, m): + data = { + "total": 5.0, + "databases": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.list( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create(self, m): + data = { + "$id": "5e5ea5c16897e", + "name": "My Database", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "enabled": True, + "type": "legacy", + "policies": [], + "archives": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_transactions(self, m): + data = { + "total": 5.0, + "transactions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.list_transactions( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_transaction(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "status": "pending", + "operations": 5.0, + "expiresAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_transaction( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_transaction(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "status": "pending", + "operations": 5.0, + "expiresAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.get_transaction( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_transaction(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "status": "pending", + "operations": 5.0, + "expiresAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_transaction( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_transaction(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.delete_transaction( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_create_operations(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "status": "pending", + "operations": 5.0, + "expiresAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_operations( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "5e5ea5c16897e", + "name": "My Database", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "enabled": True, + "type": "legacy", + "policies": [], + "archives": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.get( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update(self, m): + data = { + "$id": "5e5ea5c16897e", + "name": "My Database", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "enabled": True, + "type": "legacy", + "policies": [], + "archives": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.delete( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_tables(self, m): + data = { + "total": 5.0, + "tables": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.list_tables( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_table(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "databaseId": "5e5ea5c16897e", + "name": "My Table", + "enabled": True, + "rowSecurity": True, + "columns": [], + "indexes": [], + "bytesMax": 65535.0, + "bytesUsed": 1500.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_table( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_table(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "databaseId": "5e5ea5c16897e", + "name": "My Table", + "enabled": True, + "rowSecurity": True, + "columns": [], + "indexes": [], + "bytesMax": 65535.0, + "bytesUsed": 1500.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.get_table( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_table(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [], + "databaseId": "5e5ea5c16897e", + "name": "My Table", + "enabled": True, + "rowSecurity": True, + "columns": [], + "indexes": [], + "bytesMax": 65535.0, + "bytesUsed": 1500.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_table( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_table(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.delete_table( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_columns(self, m): + data = { + "total": 5.0, + "columns": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.list_columns( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_big_int_column(self, m): + data = { + "key": "count", + "type": "bigint", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_big_int_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_big_int_column(self, m): + data = { + "key": "count", + "type": "bigint", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_big_int_column( + '', + '', + '', + True, + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_boolean_column(self, m): + data = { + "key": "isEnabled", + "type": "boolean", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_boolean_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_boolean_column(self, m): + data = { + "key": "isEnabled", + "type": "boolean", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_boolean_column( + '', + '', + '', + True, + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_datetime_column(self, m): + data = { + "key": "birthDay", + "type": "datetime", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_datetime_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_datetime_column(self, m): + data = { + "key": "birthDay", + "type": "datetime", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "datetime" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_datetime_column( + '', + '', + '', + True, + '2020-10-15T06:38:00.000+00:00', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_email_column(self, m): + data = { + "key": "userEmail", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "email" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_email_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_email_column(self, m): + data = { + "key": "userEmail", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "email" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_email_column( + '', + '', + '', + True, + 'email@example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_enum_column(self, m): + data = { + "key": "status", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "elements": [], + "format": "enum" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_enum_column( + '', + '', + '', + [], + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_enum_column(self, m): + data = { + "key": "status", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "elements": [], + "format": "enum" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_enum_column( + '', + '', + '', + [], + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_float_column(self, m): + data = { + "key": "percentageCompleted", + "type": "double", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_float_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_float_column(self, m): + data = { + "key": "percentageCompleted", + "type": "double", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_float_column( + '', + '', + '', + True, + 1.0, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_integer_column(self, m): + data = { + "key": "count", + "type": "integer", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_integer_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_integer_column(self, m): + data = { + "key": "count", + "type": "integer", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_integer_column( + '', + '', + '', + True, + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_ip_column(self, m): + data = { + "key": "ipAddress", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "ip" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_ip_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_ip_column(self, m): + data = { + "key": "ipAddress", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "ip" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_ip_column( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_line_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_line_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_line_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_line_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_longtext_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_longtext_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_longtext_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_longtext_column( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mediumtext_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_mediumtext_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mediumtext_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_mediumtext_column( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_point_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_point_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_point_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_point_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_polygon_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_polygon_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_polygon_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_polygon_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_relationship_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "relatedTable": "table", + "relationType": "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay": True, + "twoWayKey": "string", + "onDelete": "restrict|cascade|setNull", + "side": "parent|child" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_relationship_column( + '', + '', + '', + 'oneToOne', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_string_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "size": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_string_column( + '', + '', + '', + 1, + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_string_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "size": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_string_column( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_text_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_text_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_text_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_text_column( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_url_column(self, m): + data = { + "key": "githubUrl", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "url" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_url_column( + '', + '', + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_url_column(self, m): + data = { + "key": "githubUrl", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "format": "url" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_url_column( + '', + '', + '', + True, + 'https://example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_varchar_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "size": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_varchar_column( + '', + '', + '', + 1, + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_varchar_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "size": 128.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_varchar_column( + '', + '', + '', + True, + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_column(self, m): + data = { + "key": "isEnabled", + "type": "boolean", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.get_column( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_column(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.delete_column( + '', + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_relationship_column(self, m): + data = { + "key": "fullName", + "type": "string", + "status": "available", + "error": "string", + "required": True, + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "relatedTable": "table", + "relationType": "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay": True, + "twoWayKey": "string", + "onDelete": "restrict|cascade|setNull", + "side": "parent|child" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_relationship_column( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_indexes(self, m): + data = { + "total": 5.0, + "indexes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.list_indexes( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_index(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "index1", + "type": "primary", + "status": "available", + "error": "string", + "columns": [], + "lengths": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_index( + '', + '', + '', + 'key', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_index(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "key": "index1", + "type": "primary", + "status": "available", + "error": "string", + "columns": [], + "lengths": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.get_index( + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_index(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.delete_index( + '', + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_rows(self, m): + data = { + "total": 5.0, + "rows": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.list_rows( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_row(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$tableId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_row( + '', + '', + '', + {}, + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_rows(self, m): + data = { + "total": 5.0, + "rows": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.create_rows( + '', + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_upsert_rows(self, m): + data = { + "total": 5.0, + "rows": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.upsert_rows( + '', + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_rows(self, m): + data = { + "total": 5.0, + "rows": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_rows( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_rows(self, m): + data = { + "total": 5.0, + "rows": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.delete_rows( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_row(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$tableId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.get_row( + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_upsert_row(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$tableId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.upsert_row( + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_row(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$tableId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.update_row( + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_row(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.delete_row( + '', + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_decrement_row_column(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$tableId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.decrement_row_column( + '', + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_increment_row_column(self, m): + data = { + "$id": "5e5ea5c16897e", + "$sequence": "1", + "$tableId": "5e5ea5c15117e", + "$databaseId": "5e5ea5c15117e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "$permissions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tables_db.increment_row_column( + '', + '', + '', + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + diff --git a/test/services/test_teams.py b/test/services/test_teams.py new file mode 100644 index 00000000..e83b1046 --- /dev/null +++ b/test/services/test_teams.py @@ -0,0 +1,270 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.teams import Teams + +class TeamsServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.teams = Teams(self.client) + + @requests_mock.Mocker() + def test_list(self, m): + data = { + "total": 5.0, + "teams": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.list( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "VIP", + "total": 7.0, + "prefs": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.create( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "VIP", + "total": 7.0, + "prefs": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.get( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_name(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "VIP", + "total": 7.0, + "prefs": {} +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.update_name( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.delete( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_memberships(self, m): + data = { + "total": 5.0, + "memberships": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.list_memberships( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_membership(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c16897e", + "userName": "John Doe", + "userEmail": "john@appwrite.io", + "userPhone": "+1 555 555 5555", + "teamId": "5e5ea5c16897e", + "teamName": "VIP", + "invited": "2020-10-15T06:38:00.000+00:00", + "joined": "2020-10-15T06:38:00.000+00:00", + "confirm": True, + "mfa": True, + "roles": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.create_membership( + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_membership(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c16897e", + "userName": "John Doe", + "userEmail": "john@appwrite.io", + "userPhone": "+1 555 555 5555", + "teamId": "5e5ea5c16897e", + "teamName": "VIP", + "invited": "2020-10-15T06:38:00.000+00:00", + "joined": "2020-10-15T06:38:00.000+00:00", + "confirm": True, + "mfa": True, + "roles": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.get_membership( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_membership(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c16897e", + "userName": "John Doe", + "userEmail": "john@appwrite.io", + "userPhone": "+1 555 555 5555", + "teamId": "5e5ea5c16897e", + "teamName": "VIP", + "invited": "2020-10-15T06:38:00.000+00:00", + "joined": "2020-10-15T06:38:00.000+00:00", + "confirm": True, + "mfa": True, + "roles": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.update_membership( + '', + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_membership(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.delete_membership( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_membership_status(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c16897e", + "userName": "John Doe", + "userEmail": "john@appwrite.io", + "userPhone": "+1 555 555 5555", + "teamId": "5e5ea5c16897e", + "teamName": "VIP", + "invited": "2020-10-15T06:38:00.000+00:00", + "joined": "2020-10-15T06:38:00.000+00:00", + "confirm": True, + "mfa": True, + "roles": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.update_membership_status( + '', + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_prefs(self, m): + data = {} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.get_prefs( + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_prefs(self, m): + data = {} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.teams.update_prefs( + '', + {}, + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + diff --git a/test/services/test_tokens.py b/test/services/test_tokens.py new file mode 100644 index 00000000..98073aa9 --- /dev/null +++ b/test/services/test_tokens.py @@ -0,0 +1,104 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.tokens import Tokens + +class TokensServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.tokens = Tokens(self.client) + + @requests_mock.Mocker() + def test_list(self, m): + data = { + "total": 5.0, + "tokens": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tokens.list( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_file_token(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "resourceId": "5e5ea5c168bb8:5e5ea5c168bb8", + "resourceType": "files", + "expire": "2020-10-15T06:38:00.000+00:00", + "secret": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tokens.create_file_token( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "resourceId": "5e5ea5c168bb8:5e5ea5c168bb8", + "resourceType": "files", + "expire": "2020-10-15T06:38:00.000+00:00", + "secret": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tokens.get( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "resourceId": "5e5ea5c168bb8:5e5ea5c168bb8", + "resourceType": "files", + "expire": "2020-10-15T06:38:00.000+00:00", + "secret": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tokens.update( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.tokens.delete( + '', + ) + + self.assertEqual(response, data) + diff --git a/test/services/test_users.py b/test/services/test_users.py new file mode 100644 index 00000000..2ecc1c1b --- /dev/null +++ b/test/services/test_users.py @@ -0,0 +1,1092 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.users import Users + +class UsersServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.users = Users(self.client) + + @requests_mock.Mocker() + def test_list(self, m): + data = { + "total": 5.0, + "users": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.list( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_argon2_user(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_argon2_user( + '', + 'email@example.com', + 'password', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_bcrypt_user(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_bcrypt_user( + '', + 'email@example.com', + 'password', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_identities(self, m): + data = { + "total": 5.0, + "identities": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.list_identities( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_identity(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.delete_identity( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_create_md5_user(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_md5_user( + '', + 'email@example.com', + 'password', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_ph_pass_user(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_ph_pass_user( + '', + 'email@example.com', + 'password', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_scrypt_user(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_scrypt_user( + '', + 'email@example.com', + 'password', + '', + 1, + 1, + 1, + 1, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_scrypt_modified_user(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_scrypt_modified_user( + '', + 'email@example.com', + 'password', + '', + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_sha_user(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_sha_user( + '', + 'email@example.com', + 'password', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.get( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.delete( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_email(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_email( + '', + 'email@example.com', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_impersonator(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_impersonator( + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_jwt(self, m): + data = { + "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_jwt( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_labels(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_labels( + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_logs(self, m): + data = { + "total": 5.0, + "logs": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.list_logs( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_memberships(self, m): + data = { + "total": 5.0, + "memberships": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.list_memberships( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_mfa( + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_mfa( + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_mfa_authenticator(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.delete_mfa_authenticator( + '', + 'totp', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_delete_mfa_authenticator(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.delete_mfa_authenticator( + '', + 'totp', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_list_mfa_factors(self, m): + data = { + "totp": True, + "phone": True, + "email": True, + "recoveryCode": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.list_mfa_factors( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_mfa_factors(self, m): + data = { + "totp": True, + "phone": True, + "email": True, + "recoveryCode": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.list_mfa_factors( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.get_mfa_recovery_codes( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.get_mfa_recovery_codes( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_mfa_recovery_codes( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_mfa_recovery_codes( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_mfa_recovery_codes( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_mfa_recovery_codes(self, m): + data = { + "recoveryCodes": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_mfa_recovery_codes( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_name(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_name( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_password(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_password( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_phone(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_phone( + '', + '+12065550100', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_prefs(self, m): + data = {} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.get_prefs( + '', + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_prefs(self, m): + data = {} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_prefs( + '', + {}, + ) + + data['data'] = {} + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_sessions(self, m): + data = { + "total": 5.0, + "sessions": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.list_sessions( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_session(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_session( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_sessions(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.delete_sessions( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_delete_session(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.delete_session( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_status(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_status( + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_list_targets(self, m): + data = { + "total": 5.0, + "targets": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.list_targets( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_target(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Apple iPhone 12", + "userId": "259125845563242502", + "providerType": "email", + "identifier": "token", + "expired": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_target( + '', + '', + 'email', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get_target(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Apple iPhone 12", + "userId": "259125845563242502", + "providerType": "email", + "identifier": "token", + "expired": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.get_target( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_target(self, m): + data = { + "$id": "259125845563242502", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "Apple iPhone 12", + "userId": "259125845563242502", + "providerType": "email", + "identifier": "token", + "expired": True +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_target( + '', + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete_target(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.delete_target( + '', + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_create_token(self, m): + data = { + "$id": "bb8ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5ea5c168bb8", + "secret": "", + "expire": "2020-10-15T06:38:00.000+00:00", + "phrase": "Golden Fox" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.create_token( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_email_verification(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_email_verification( + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update_phone_verification(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "John Doe", + "registration": "2020-10-15T06:38:00.000+00:00", + "status": True, + "labels": [], + "passwordUpdate": "2020-10-15T06:38:00.000+00:00", + "email": "john@appwrite.io", + "phone": "+4930901820", + "emailVerification": True, + "phoneVerification": True, + "mfa": True, + "prefs": {}, + "targets": [], + "accessedAt": "2020-10-15T06:38:00.000+00:00" +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.users.update_phone_verification( + '', + True, + ) + + self.assertEqual(response.to_dict(), data) + diff --git a/test/services/test_webhooks.py b/test/services/test_webhooks.py new file mode 100644 index 00000000..eb7f1f13 --- /dev/null +++ b/test/services/test_webhooks.py @@ -0,0 +1,151 @@ +import json +import requests_mock +import unittest + +from appwrite.client import Client +from appwrite.input_file import InputFile +from appwrite.models import * +from appwrite.services.webhooks import Webhooks + +class WebhooksServiceTest(unittest.TestCase): + + def setUp(self): + self.client = Client() + self.webhooks = Webhooks(self.client) + + @requests_mock.Mocker() + def test_list(self, m): + data = { + "total": 5.0, + "webhooks": [] +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.webhooks.list( + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Webhook", + "url": "https:\/\/example.com\/webhook", + "events": [], + "tls": True, + "authUsername": "username", + "authPassword": "password", + "secret": "ad3d581ca230e2b7059c545e5a", + "enabled": True, + "logs": "Failed to connect to remote server.", + "attempts": 10.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.webhooks.create( + '', + '', + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_get(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Webhook", + "url": "https:\/\/example.com\/webhook", + "events": [], + "tls": True, + "authUsername": "username", + "authPassword": "password", + "secret": "ad3d581ca230e2b7059c545e5a", + "enabled": True, + "logs": "Failed to connect to remote server.", + "attempts": 10.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.webhooks.get( + '', + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_update(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Webhook", + "url": "https:\/\/example.com\/webhook", + "events": [], + "tls": True, + "authUsername": "username", + "authPassword": "password", + "secret": "ad3d581ca230e2b7059c545e5a", + "enabled": True, + "logs": "Failed to connect to remote server.", + "attempts": 10.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.webhooks.update( + '', + '', + '', + [], + ) + + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_delete(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.webhooks.delete( + '', + ) + + self.assertEqual(response, data) + + @requests_mock.Mocker() + def test_update_secret(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Webhook", + "url": "https:\/\/example.com\/webhook", + "events": [], + "tls": True, + "authUsername": "username", + "authPassword": "password", + "secret": "ad3d581ca230e2b7059c545e5a", + "enabled": True, + "logs": "Failed to connect to remote server.", + "attempts": 10.0 +} + headers = {'Content-Type': 'application/json'} + m.request(requests_mock.ANY, requests_mock.ANY, text=json.dumps(data), headers=headers) + + response = self.webhooks.update_secret( + '', + ) + + self.assertEqual(response.to_dict(), data) + diff --git a/test/test_id.py b/test/test_id.py new file mode 100644 index 00000000..280433d4 --- /dev/null +++ b/test/test_id.py @@ -0,0 +1,11 @@ +import unittest + +from appwrite.id import ID + +class TestIDMethods(unittest.TestCase): + + def test_unique(self): + self.assertEqual(len(ID.unique()), 20) + + def test_custom(self): + self.assertEqual(ID.custom('custom'), 'custom') diff --git a/test/test_operator.py b/test/test_operator.py new file mode 100644 index 00000000..f85ec6ec --- /dev/null +++ b/test/test_operator.py @@ -0,0 +1,80 @@ +import unittest + +from appwrite.operator import Operator, Condition + +class TestOperatorMethods(unittest.TestCase): + + def test_increment(self): + self.assertEqual(Operator.increment(1), '{"method":"increment","values":[1]}') + + def test_increment_with_max(self): + self.assertEqual(Operator.increment(5, 100), '{"method":"increment","values":[5,100]}') + + def test_decrement(self): + self.assertEqual(Operator.decrement(1), '{"method":"decrement","values":[1]}') + + def test_decrement_with_min(self): + self.assertEqual(Operator.decrement(3, 0), '{"method":"decrement","values":[3,0]}') + + def test_multiply(self): + self.assertEqual(Operator.multiply(2), '{"method":"multiply","values":[2]}') + + def test_multiply_with_max(self): + self.assertEqual(Operator.multiply(3, 1000), '{"method":"multiply","values":[3,1000]}') + + def test_divide(self): + self.assertEqual(Operator.divide(2), '{"method":"divide","values":[2]}') + + def test_divide_with_min(self): + self.assertEqual(Operator.divide(4, 1), '{"method":"divide","values":[4,1]}') + + def test_modulo(self): + self.assertEqual(Operator.modulo(5), '{"method":"modulo","values":[5]}') + + def test_power(self): + self.assertEqual(Operator.power(2), '{"method":"power","values":[2]}') + + def test_power_with_max(self): + self.assertEqual(Operator.power(3, 100), '{"method":"power","values":[3,100]}') + + def test_array_append(self): + self.assertEqual(Operator.array_append(['item1', 'item2']), '{"method":"arrayAppend","values":["item1","item2"]}') + + def test_array_prepend(self): + self.assertEqual(Operator.array_prepend(['first', 'second']), '{"method":"arrayPrepend","values":["first","second"]}') + + def test_array_insert(self): + self.assertEqual(Operator.array_insert(0, 'newItem'), '{"method":"arrayInsert","values":[0,"newItem"]}') + + def test_array_remove(self): + self.assertEqual(Operator.array_remove('oldItem'), '{"method":"arrayRemove","values":["oldItem"]}') + + def test_array_unique(self): + self.assertEqual(Operator.array_unique(), '{"method":"arrayUnique","values":[]}') + + def test_array_intersect(self): + self.assertEqual(Operator.array_intersect(['a', 'b', 'c']), '{"method":"arrayIntersect","values":["a","b","c"]}') + + def test_array_diff(self): + self.assertEqual(Operator.array_diff(['x', 'y']), '{"method":"arrayDiff","values":["x","y"]}') + + def test_array_filter(self): + self.assertEqual(Operator.array_filter(Condition.EQUAL, 'test'), '{"method":"arrayFilter","values":["equal","test"]}') + + def test_string_concat(self): + self.assertEqual(Operator.string_concat('suffix'), '{"method":"stringConcat","values":["suffix"]}') + + def test_string_replace(self): + self.assertEqual(Operator.string_replace('old', 'new'), '{"method":"stringReplace","values":["old","new"]}') + + def test_toggle(self): + self.assertEqual(Operator.toggle(), '{"method":"toggle","values":[]}') + + def test_date_add_days(self): + self.assertEqual(Operator.date_add_days(7), '{"method":"dateAddDays","values":[7]}') + + def test_date_sub_days(self): + self.assertEqual(Operator.date_sub_days(3), '{"method":"dateSubDays","values":[3]}') + + def test_date_set_now(self): + self.assertEqual(Operator.date_set_now(), '{"method":"dateSetNow","values":[]}') diff --git a/test/test_permission.py b/test/test_permission.py new file mode 100644 index 00000000..54e66429 --- /dev/null +++ b/test/test_permission.py @@ -0,0 +1,21 @@ +import unittest + +from appwrite.permission import Permission +from appwrite.role import Role + +class TestPermissionMethods(unittest.TestCase): + + def test_read(self): + self.assertEqual(Permission.read(Role.any()), 'read("any")') + + def test_write(self): + self.assertEqual(Permission.write(Role.any()), 'write("any")') + + def test_create(self): + self.assertEqual(Permission.create(Role.any()), 'create("any")') + + def test_update(self): + self.assertEqual(Permission.update(Role.any()), 'update("any")') + + def test_delete(self): + self.assertEqual(Permission.delete(Role.any()), 'delete("any")') diff --git a/test/test_query.py b/test/test_query.py new file mode 100644 index 00000000..c8595b5c --- /dev/null +++ b/test/test_query.py @@ -0,0 +1,107 @@ +import unittest + +from appwrite.query import Query + +class BasicFilterQueryTest: + def __init__(self, description: str, value, expected_values: str): + self.description = description + self.value = value + self.expected_values = expected_values + +tests = [ + BasicFilterQueryTest('with a string', 's', '["s"]'), + BasicFilterQueryTest('with an integer', 1, '[1]'), + BasicFilterQueryTest('with a double', 1.2, '[1.2]'), + BasicFilterQueryTest('with a whole number double', 1.0, '[1.0]'), + BasicFilterQueryTest('with a bool', False, '[false]'), + BasicFilterQueryTest('with a list', ['a', 'b', 'c'], '["a","b","c"]'), +] + +class TestQueryMethods(unittest.TestCase): + + def test_equal(self): + for t in tests: + self.assertEqual( + Query.equal('attr', t.value), + f'{{"method":"equal","attribute":"attr","values":{t.expected_values}}}', + t.description + ) + + def test_not_equal(self): + for t in tests: + self.assertEqual( + Query.not_equal('attr', t.value), + f'{{"method":"notEqual","attribute":"attr","values":{t.expected_values}}}', + t.description + ) + + def test_less_than(self): + for t in tests: + self.assertEqual( + Query.less_than('attr', t.value), + f'{{"method":"lessThan","attribute":"attr","values":{t.expected_values}}}', + t.description + ) + + def test_less_than_equal(self): + for t in tests: + self.assertEqual( + Query.less_than_equal('attr', t.value), + f'{{"method":"lessThanEqual","attribute":"attr","values":{t.expected_values}}}', + t.description + ) + + def test_greater_than(self): + for t in tests: + self.assertEqual( + Query.greater_than('attr', t.value), + f'{{"method":"greaterThan","attribute":"attr","values":{t.expected_values}}}', + t.description + ) + + def test_greater_than_equal(self): + for t in tests: + self.assertEqual( + Query.greater_than_equal('attr', t.value), + f'{{"method":"greaterThanEqual","attribute":"attr","values":{t.expected_values}}}', + t.description + ) + + def test_search(self): + self.assertEqual(Query.search('attr', 'keyword1 keyword2'), '{"method":"search","attribute":"attr","values":["keyword1 keyword2"]}') + + def test_is_null(self): + self.assertEqual(Query.is_null('attr'), '{"method":"isNull","attribute":"attr"}') + + def test_is_not_null(self): + self.assertEqual(Query.is_not_null('attr'), '{"method":"isNotNull","attribute":"attr"}') + + def test_between_with_integers(self): + self.assertEqual(Query.between('attr', 1, 2), '{"method":"between","attribute":"attr","values":[1,2]}') + + def test_between_with_doubles(self): + self.assertEqual(Query.between('attr', 1.0, 2.0), '{"method":"between","attribute":"attr","values":[1.0,2.0]}') + + def test_between_with_strings(self): + self.assertEqual(Query.between('attr', 'a', 'z'), '{"method":"between","attribute":"attr","values":["a","z"]}') + + def test_select(self): + self.assertEqual(Query.select(['attr1', 'attr2']), '{"method":"select","values":["attr1","attr2"]}') + + def test_order_asc(self): + self.assertEqual(Query.order_asc('attr'), '{"method":"orderAsc","attribute":"attr"}') + + def test_order_desc(self): + self.assertEqual(Query.order_desc('attr'), '{"method":"orderDesc","attribute":"attr"}') + + def test_cursor_before(self): + self.assertEqual(Query.cursor_before('custom'), '{"method":"cursorBefore","values":["custom"]}') + + def test_cursor_after(self): + self.assertEqual(Query.cursor_after('custom'), '{"method":"cursorAfter","values":["custom"]}') + + def test_limit(self): + self.assertEqual(Query.limit(1), '{"method":"limit","values":[1]}') + + def test_offset(self): + self.assertEqual(Query.offset(1), '{"method":"offset","values":[1]}') diff --git a/test/test_role.py b/test/test_role.py new file mode 100644 index 00000000..53311275 --- /dev/null +++ b/test/test_role.py @@ -0,0 +1,35 @@ +import unittest + +from appwrite.role import Role + +class TestRoleMethods(unittest.TestCase): + + def test_any(self): + self.assertEqual(Role.any(), 'any') + + def test_user_without_status(self): + self.assertEqual(Role.user('custom'), 'user:custom') + + def test_user_with_status(self): + self.assertEqual(Role.user('custom', 'verified'), 'user:custom/verified') + + def test_users_without_status(self): + self.assertEqual(Role.users(), 'users') + + def test_users_with_status(self): + self.assertEqual(Role.users('verified'), 'users/verified') + + def test_guests(self): + self.assertEqual(Role.guests(), 'guests') + + def test_team_without_role(self): + self.assertEqual(Role.team('custom'), 'team:custom') + + def test_team_with_role(self): + self.assertEqual(Role.team('custom', 'owner'), 'team:custom/owner') + + def test_member(self): + self.assertEqual(Role.member('custom'), 'member:custom') + + def test_label(self): + self.assertEqual(Role.label('admin'), 'label:admin')