Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add inc/dec#113

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
abnegate wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromdev
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
# 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.7.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.7.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)
Expand Down
4 changes: 2 additions & 2 deletionsappwrite/client.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,11 +14,11 @@ def __init__(self):
self._endpoint = 'https://cloud.appwrite.io/v1'
self._global_headers = {
'content-type': '',
'user-agent' : f'AppwritePythonSDK/11.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
'user-agent' : f'AppwritePythonSDK/11.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': '11.0.0',
'x-sdk-version': '11.1.0',
'X-Appwrite-Response-Format' : '1.7.0',
}

Expand Down
2 changes: 2 additions & 0 deletionsappwrite/enums/build_runtime.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,7 @@ class BuildRuntime(Enum):
DART_3_1 = "dart-3.1"
DART_3_3 = "dart-3.3"
DART_3_5 = "dart-3.5"
DART_3_8 = "dart-3.8"
DOTNET_6_0 = "dotnet-6.0"
DOTNET_7_0 = "dotnet-7.0"
DOTNET_8_0 = "dotnet-8.0"
Expand All@@ -64,3 +65,4 @@ class BuildRuntime(Enum):
FLUTTER_3_24 = "flutter-3.24"
FLUTTER_3_27 = "flutter-3.27"
FLUTTER_3_29 = "flutter-3.29"
FLUTTER_3_32 = "flutter-3.32"
1 change: 1 addition & 0 deletionsappwrite/enums/image_format.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,3 +7,4 @@ class ImageFormat(Enum):
WEBP = "webp"
HEIC = "heic"
AVIF = "avif"
GIF = "gif"
2 changes: 2 additions & 0 deletionsappwrite/enums/runtime.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,7 @@ class Runtime(Enum):
DART_3_1 = "dart-3.1"
DART_3_3 = "dart-3.3"
DART_3_5 = "dart-3.5"
DART_3_8 = "dart-3.8"
DOTNET_6_0 = "dotnet-6.0"
DOTNET_7_0 = "dotnet-7.0"
DOTNET_8_0 = "dotnet-8.0"
Expand All@@ -64,3 +65,4 @@ class Runtime(Enum):
FLUTTER_3_24 = "flutter-3.24"
FLUTTER_3_27 = "flutter-3.27"
FLUTTER_3_29 = "flutter-3.29"
FLUTTER_3_32 = "flutter-3.32"
181 changes: 179 additions & 2 deletionsappwrite/services/databases.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1812,6 +1812,8 @@ def create_document(self, database_id: str, collection_id: str, document_id: str

def create_documents(self, database_id: str, collection_id: str, documents: List[dict]) -> Dict[str, Any]:
"""
**WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.

Parameters
Expand DownExpand Up@@ -1854,10 +1856,11 @@ def create_documents(self, database_id: str, collection_id: str, documents: List
'content-type': 'application/json',
}, api_params)

def upsert_documents(self, database_id: str, collection_id: str, documents: List[dict] = None) -> Dict[str, Any]:
def upsert_documents(self, database_id: str, collection_id: str, documents: List[dict]) -> Dict[str, Any]:
"""
Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) APIordirectly from your database console.
**WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changesorremoval in future versions.

Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.

Parameters
----------
Expand DownExpand Up@@ -1887,6 +1890,9 @@ def upsert_documents(self, database_id: str, collection_id: str, documents: List
if collection_id is None:
raise AppwriteException('Missing required parameter: "collection_id"')

if documents is None:
raise AppwriteException('Missing required parameter: "documents"')

api_path = api_path.replace('{databaseId}', database_id)
api_path = api_path.replace('{collectionId}', collection_id)

Expand All@@ -1898,6 +1904,8 @@ def upsert_documents(self, database_id: str, collection_id: str, documents: List

def update_documents(self, database_id: str, collection_id: str, data: dict = None, queries: List[str] = None) -> Dict[str, Any]:
"""
**WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated.

Parameters
Expand DownExpand Up@@ -1942,6 +1950,8 @@ def update_documents(self, database_id: str, collection_id: str, data: dict = No

def delete_documents(self, database_id: str, collection_id: str, queries: List[str] = None) -> Dict[str, Any]:
"""
**WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Bulk delete documents using queries, if no queries are passed then all documents are deleted.

Parameters
Expand DownExpand Up@@ -2027,6 +2037,61 @@ def get_document(self, database_id: str, collection_id: str, document_id: str, q
return self.client.call('get', api_path, {
}, api_params)

def upsert_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: List[str] = None) -> Dict[str, Any]:
"""
**WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.

Parameters
----------
database_id : str
Database ID.
collection_id : str
Collection ID.
document_id : str
Document ID.
data : dict
Document data as JSON object. Include all required attributes of the document to be created or updated.
permissions : List[str]
An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).

Returns
-------
Dict[str, Any]
API response as a dictionary

Raises
------
AppwriteException
If API request fails
"""

api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
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 document_id is None:
raise AppwriteException('Missing required parameter: "document_id"')

if data is None:
raise AppwriteException('Missing required parameter: "data"')

api_path = api_path.replace('{databaseId}', database_id)
api_path = api_path.replace('{collectionId}', collection_id)
api_path = api_path.replace('{documentId}', document_id)

api_params['data'] = data
api_params['permissions'] = permissions

return self.client.call('put', api_path, {
'content-type': 'application/json',
}, api_params)

def update_document(self, database_id: str, collection_id: str, document_id: str, data: dict = None, permissions: List[str] = None) -> Dict[str, Any]:
"""
Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
Expand DownExpand Up@@ -2121,6 +2186,118 @@ def delete_document(self, database_id: str, collection_id: str, document_id: str
'content-type': 'application/json',
}, api_params)

def decrement_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: float = None, min: float = None) -> Dict[str, Any]:
"""
Decrement a specific attribute of a document by a given value.

Parameters
----------
database_id : str
Database ID.
collection_id : str
Collection ID.
document_id : str
Document ID.
attribute : str
Attribute key.
value : float
Value to decrement the attribute by. The value must be a number.
min : float
Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.

Returns
-------
Dict[str, Any]
API response as a dictionary

Raises
------
AppwriteException
If API request fails
"""

api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'
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 document_id is None:
raise AppwriteException('Missing required parameter: "document_id"')

if attribute is None:
raise AppwriteException('Missing required parameter: "attribute"')

api_path = api_path.replace('{databaseId}', database_id)
api_path = api_path.replace('{collectionId}', collection_id)
api_path = api_path.replace('{documentId}', document_id)
api_path = api_path.replace('{attribute}', attribute)

api_params['value'] = value
api_params['min'] = min

return self.client.call('patch', api_path, {
'content-type': 'application/json',
}, api_params)

def increment_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: float = None, max: float = None) -> Dict[str, Any]:
"""
Increment a specific attribute of a document by a given value.

Parameters
----------
database_id : str
Database ID.
collection_id : str
Collection ID.
document_id : str
Document ID.
attribute : str
Attribute key.
value : float
Value to increment the attribute by. The value must be a number.
max : float
Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.

Returns
-------
Dict[str, Any]
API response as a dictionary

Raises
------
AppwriteException
If API request fails
"""

api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'
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 document_id is None:
raise AppwriteException('Missing required parameter: "document_id"')

if attribute is None:
raise AppwriteException('Missing required parameter: "attribute"')

api_path = api_path.replace('{databaseId}', database_id)
api_path = api_path.replace('{collectionId}', collection_id)
api_path = api_path.replace('{documentId}', document_id)
api_path = api_path.replace('{attribute}', attribute)

api_params['value'] = value
api_params['max'] = max

return self.client.call('patch', api_path, {
'content-type': 'application/json',
}, api_params)

def list_indexes(self, database_id: str, collection_id: str, queries: List[str] = None) -> Dict[str, Any]:
"""
List indexes in the collection.
Expand Down
2 changes: 1 addition & 1 deletionappwrite/services/tokens.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,7 +49,7 @@ def list(self, bucket_id: str, file_id: str, queries: List[str] = None) -> Dict[

def create_file_token(self, bucket_id: str, file_id: str, expire: str = None) -> Dict[str, Any]:
"""
Create a new token. A token is linked to a file. Token can be passed as aheader orrequestget parameter.
Create a new token. A token is linked to a file. Token can be passed as a requestURL search parameter.

Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletionappwrite/services/users.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1345,7 +1345,7 @@ def list_targets(self, user_id: str, queries: List[str] = None) -> Dict[str, Any
user_id : str
User ID.
queries : 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:name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels
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:userId, providerId, identifier, providerType

Returns
-------
Expand Down
1 change: 1 addition & 0 deletionsdocs/examples/databases/create-document.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ from appwrite.services.databases import Databases

client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_admin('') #
client.set_session('') # The user session to authenticate with
client.set_key('<YOUR_API_KEY>') # Your secret API key
client.set_jwt('<YOUR_JWT>') # Your secret JSON Web Token
Expand Down
18 changes: 18 additions & 0 deletionsdocs/examples/databases/decrement-document-attribute.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
from appwrite.client import Client
from appwrite.services.databases import Databases

client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_key('<YOUR_API_KEY>') # Your secret API key

databases = Databases(client)

result = databases.decrement_document_attribute(
database_id = '<DATABASE_ID>',
collection_id = '<COLLECTION_ID>',
document_id = '<DOCUMENT_ID>',
attribute = '',
value = None, # optional
min = None # optional
)
18 changes: 18 additions & 0 deletionsdocs/examples/databases/increment-document-attribute.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
from appwrite.client import Client
from appwrite.services.databases import Databases

client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_key('<YOUR_API_KEY>') # Your secret API key

databases = Databases(client)

result = databases.increment_document_attribute(
database_id = '<DATABASE_ID>',
collection_id = '<COLLECTION_ID>',
document_id = '<DOCUMENT_ID>',
attribute = '',
value = None, # optional
max = None # optional
)
17 changes: 17 additions & 0 deletionsdocs/examples/databases/upsert-document.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
from appwrite.client import Client
from appwrite.services.databases import Databases

client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

databases = Databases(client)

result = databases.upsert_document(
database_id = '<DATABASE_ID>',
collection_id = '<COLLECTION_ID>',
document_id = '<DOCUMENT_ID>',
data = {},
permissions = ["read("any")"] # optional
)
2 changes: 1 addition & 1 deletiondocs/examples/databases/upsert-documents.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,5 +11,5 @@ databases = Databases(client)
result = databases.upsert_documents(
database_id = '<DATABASE_ID>',
collection_id = '<COLLECTION_ID>',
documents = [] # optional
documents = []
)
4 changes: 2 additions & 2 deletionssetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@
'appwrite/encoders',
'appwrite/enums',
],
version = '11.0.0',
version = '11.1.0',
license='BSD-3-Clause',
description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API',
long_description = long_description,
Expand All@@ -23,7 +23,7 @@
maintainer = 'Appwrite Team',
maintainer_email = 'team@appwrite.io',
url = 'https://appwrite.io/support',
download_url='https://github.com/appwrite/sdk-for-python/archive/11.0.0.tar.gz',
download_url='https://github.com/appwrite/sdk-for-python/archive/11.1.0.tar.gz',
install_requires=[
'requests',
],
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp