-
Notifications
You must be signed in to change notification settings - Fork 67
feat: SDK update for version 24.0.0 #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| from typing import Any, Dict, List, Optional, Union, cast | ||
| from pydantic import Field, PrivateAttr | ||
|
|
||
| from .base_model import AppwriteModel | ||
|
|
||
|
|
||
| class OAuth2Cloudflare(AppwriteModel): | ||
| """ | ||
| OAuth2Cloudflare | ||
|
|
||
| Attributes | ||
| ---------- | ||
| id : str | ||
| OAuth2 provider ID. | ||
| enabled : bool | ||
| OAuth2 provider is active and can be used to create sessions. | ||
| clientid : str | ||
| Cloudflare OAuth2 client ID. | ||
| clientsecret : str | ||
| Cloudflare OAuth2 client secret. | ||
| """ | ||
|
|
||
| id: str = Field(..., alias='$id') | ||
| enabled: bool = Field(..., alias='enabled') | ||
| clientid: str = Field(..., alias='clientId') | ||
| clientsecret: str = Field(..., alias='clientSecret') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,8 @@ | |
| from .o_auth2_kick import OAuth2Kick | ||
| from .o_auth2_microsoft import OAuth2Microsoft | ||
| from .o_auth2_hugging_face import OAuth2HuggingFace | ||
| from .o_auth2_resend import OAuth2Resend | ||
| from .o_auth2_cloudflare import OAuth2Cloudflare | ||
|
|
||
|
|
||
| class OAuth2ProviderList(AppwriteModel): | ||
|
|
@@ -54,7 +56,7 @@ class OAuth2ProviderList(AppwriteModel): | |
| ---------- | ||
| 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, OAuth2Appwrite, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2HuggingFace]] | ||
| 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, OAuth2Appwrite, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare]] | ||
| List of OAuth2 providers. | ||
| """ | ||
|
|
||
|
|
@@ -103,5 +105,7 @@ class OAuth2ProviderList(AppwriteModel): | |
| OAuth2Kick, | ||
| OAuth2Microsoft, | ||
| OAuth2HuggingFace, | ||
| OAuth2Resend, | ||
| OAuth2Cloudflare, | ||
|
Comment on lines
+108
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Knowledge Base Used: Prompt To Fix With AIThis is a comment left during a code review.
Path: appwrite/models/o_auth2_provider_list.py
Line: 108-109
Comment:
**Provider union loses nominal type**
When `list_o_auth2_providers` parses a Resend or Cloudflare response with the common provider fields, an earlier structurally identical member of this untagged union wins validation, causing callers to receive the wrong provider model and breaking `isinstance`-based dispatch.
**Knowledge Base Used:**
- [API data contracts](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/sdk-for-python/-/docs/api-data-contracts.md)
- [Project and platform services](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/sdk-for-python/-/docs/project-and-platform-services.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| ] | ||
| ] = Field(..., alias='providers') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| from typing import Any, Dict, List, Optional, Union, cast | ||
| from pydantic import Field, PrivateAttr | ||
|
|
||
| from .base_model import AppwriteModel | ||
|
|
||
|
|
||
| class OAuth2Resend(AppwriteModel): | ||
| """ | ||
| OAuth2Resend | ||
|
|
||
| Attributes | ||
| ---------- | ||
| id : str | ||
| OAuth2 provider ID. | ||
| enabled : bool | ||
| OAuth2 provider is active and can be used to create sessions. | ||
| clientid : str | ||
| Resend OAuth2 client ID. | ||
| clientsecret : str | ||
| Resend OAuth2 client secret. | ||
| """ | ||
|
|
||
| id: str = Field(..., alias='$id') | ||
| enabled: bool = Field(..., alias='enabled') | ||
| clientid: str = Field(..., alias='clientId') | ||
| clientsecret: str = Field(..., alias='clientSecret') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -949,6 +949,7 @@ def create_document( | |
| document_id: str, | ||
| data: Dict[str, Any], | ||
| permissions: Optional[List[str]] = None, | ||
| transaction_id: Optional[str] = None, | ||
| model_type: Type[T] = dict, | ||
|
Comment on lines
+952
to
953
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an existing caller passes Knowledge Base Used: Prompt To Fix With AIThis is a comment left during a code review.
Path: appwrite/services/documents_db.py
Line: 952-953
Comment:
**Positional model type is misbound**
When an existing caller passes `model_type` positionally, the new parameter order binds that class to `transaction_id`; the class is then placed in the JSON payload, causing serialization to raise `TypeError` before the request is sent. The same incompatible ordering was added to both creation methods in DocumentsDB and VectorsDB.
**Knowledge Base Used:**
- [Document and vector database services](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/sdk-for-python/-/docs/document-and-vector-database-services.md)
- [API data contracts](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/sdk-for-python/-/docs/api-data-contracts.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| ) -> Document[T]: | ||
| """ | ||
|
|
@@ -966,6 +967,8 @@ def create_document( | |
| Document data as JSON object. | ||
| permissions : Optional[List[str]] | ||
| An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | ||
| transaction_id : Optional[str] | ||
| Transaction ID for staging the operation. | ||
| model_type : Type[T], optional | ||
| Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. | ||
|
|
||
|
|
@@ -996,6 +999,8 @@ def create_document( | |
| api_params['data'] = self._normalize_value(data) | ||
| if permissions is not None: | ||
| api_params['permissions'] = self._normalize_value(permissions) | ||
| if transaction_id is not None: | ||
| api_params['transactionId'] = self._normalize_value(transaction_id) | ||
|
|
||
| response = self.client.call( | ||
| 'post', | ||
|
|
@@ -1015,6 +1020,7 @@ def create_documents( | |
| database_id: str, | ||
| collection_id: str, | ||
| documents: List[Dict[str, Any]], | ||
| transaction_id: Optional[str] = None, | ||
| model_type: Type[T] = dict, | ||
| ) -> DocumentList[T]: | ||
| """ | ||
|
|
@@ -1028,6 +1034,8 @@ def create_documents( | |
| Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. | ||
| documents : List[Dict[str, Any]] | ||
| Array of documents data as JSON objects. | ||
| transaction_id : Optional[str] | ||
| Transaction ID for staging the operation. | ||
| model_type : Type[T], optional | ||
| Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. | ||
|
|
||
|
|
@@ -1053,6 +1061,8 @@ def create_documents( | |
| api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) | ||
| api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) | ||
| api_params['documents'] = self._normalize_value(documents) | ||
| if transaction_id is not None: | ||
| api_params['transactionId'] = self._normalize_value(transaction_id) | ||
|
|
||
| response = self.client.call( | ||
| 'post', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the API returns
credentialGenerationas null before the rotation contract is initialized, this requiredfloatfails Pydantic validation, causing the SDK to raiseAppwriteExceptionfor an otherwise successful database response.Knowledge Base Used:
Prompt To Fix With AI