1
0
Fork 0
mirror of synced 2024-06-26 10:10:57 +12:00

Merge branch '0.6.x' of github.com:appwrite/appwrite into deno-sdk-update

This commit is contained in:
Eldad Fux 2020-07-26 15:38:14 +03:00
commit 71f35a64df
12 changed files with 49 additions and 23 deletions

View file

@ -195,7 +195,7 @@ return [
[
'key' => 'python',
'name' => 'Python',
'version' => '0.0.5',
'version' => '0.0.6',
'url' => 'https://github.com/appwrite/sdk-for-python',
'enabled' => true,
'beta' => true,

View file

@ -1,9 +1,9 @@
# Appwrite Python SDK
![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.6.1-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1)
**This SDK is compatible with Appwrite server version 0.6.1. For older versions, please check previous releases.**
**This SDK is compatible with Appwrite server version 0.6.2. For older versions, please check previous releases.**
Appwrite is an open-source backend as a service server that abstract and simplify 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.
@ -27,4 +27,4 @@ This library is auto-generated by Appwrite custom [SDK Generator](https://github
## License
Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.

View file

@ -1,13 +1,13 @@
import io
import requests
class Client:
def __init__(self):
self._self_signed = False
self._endpoint = 'https://appwrite.io/v1'
self._global_headers = {
'content-type': '',
'x-sdk-version': 'appwrite:python:0.0.5',
'x-sdk-version': 'appwrite:python:0.0.6',
}
def set_self_signed(self, status=True):
@ -47,24 +47,34 @@ class Client:
data = {}
json = {}
files = {}
self._global_headers.update(headers)
headers = {**self._global_headers, **headers}
if method != 'get':
data = params
params = {}
if headers['content-type'] == 'application/json':
if headers['content-type'].startswith('application/json'):
json = data
data = {}
if headers['content-type'].startswith('multipart/form-data'):
del headers['content-type']
for key in data.copy():
if isinstance(data[key], io.BufferedIOBase):
files[key] = data[key]
del data[key]
response = requests.request( # call method dynamically https://stackoverflow.com/a/4246075/2299554
method=method,
url=self._endpoint + path,
params=params,
data=data,
params=self.flatten(params),
data=self.flatten(data),
json=json,
headers=self._global_headers,
files=files,
headers=headers,
verify=self._self_signed,
)
@ -77,3 +87,20 @@ class Client:
return response._content
def flatten(self, data, prefix=''):
output = {}
i = 0
for key in data:
value = data[key] if isinstance(data, dict) else key
finalKey = prefix + '[' + key +']' if prefix else key
finalKey = prefix + '[' + str(i) +']' if isinstance(data, list) else finalKey
i += 1
if isinstance(value, list) or isinstance(value, dict):
output = {**output, **self.flatten(value, finalKey)}
else:
output[finalKey] = value
return output

View file

@ -11,4 +11,4 @@ client = Client()
database = Database(client)
result = database.create_collection('[NAME]', {}, {}, {})
result = database.create_collection('[NAME]', [], [], [])

View file

@ -11,4 +11,4 @@ client = Client()
database = Database(client)
result = database.create_document('[COLLECTION_ID]', {}, {}, {})
result = database.create_document('[COLLECTION_ID]', {}, [], [])

View file

@ -11,4 +11,4 @@ client = Client()
database = Database(client)
result = database.update_collection('[COLLECTION_ID]', '[NAME]', {}, {})
result = database.update_collection('[COLLECTION_ID]', '[NAME]', [], [])

View file

@ -11,4 +11,4 @@ client = Client()
database = Database(client)
result = database.update_document('[COLLECTION_ID]', '[DOCUMENT_ID]', {}, {}, {})
result = database.update_document('[COLLECTION_ID]', '[DOCUMENT_ID]', {}, [], [])

View file

@ -11,4 +11,4 @@ client = Client()
storage = Storage(client)
result = storage.create_file(document.getElementById('uploader').files[0], {}, {})
result = storage.create_file(open('/path/to/file.png', 'rb'), [], [])

View file

@ -11,4 +11,4 @@ client = Client()
storage = Storage(client)
result = storage.update_file('[FILE_ID]', {}, {})
result = storage.update_file('[FILE_ID]', [], [])

View file

@ -11,4 +11,4 @@ client = Client()
teams = Teams(client)
result = teams.create_membership('[TEAM_ID]', 'email@example.com', {}, 'https://example.com')
result = teams.create_membership('[TEAM_ID]', 'email@example.com', [], 'https://example.com')

View file

@ -3,7 +3,7 @@ import setuptools
setuptools.setup(
name = 'appwrite',
packages = ['appwrite', 'appwrite/services'],
version = '0.0.5',
version = '0.0.6',
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',
author = 'Appwrite Team',
@ -11,7 +11,7 @@ setuptools.setup(
maintainer = 'Appwrite Team',
maintainer_email = 'team@localhost.test',
url = 'https://appwrite.io/support',
download_url='https://github.com/appwrite/sdk-for-python/archive/0.0.5.tar.gz',
download_url='https://github.com/appwrite/sdk-for-python/archive/0.0.6.tar.gz',
# keywords = ['SOME', 'MEANINGFULL', 'KEYWORDS'],
install_requires=[
'requests',
@ -23,7 +23,6 @@ setuptools.setup(
'Topic :: Software Development',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',

4
composer.lock generated
View file

@ -1923,7 +1923,7 @@
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator",
"reference": "43d15fc337bcbfe480f2a5503bd7c0615743035b"
"reference": "404cf6bb4c75f8ae3b2419e04f6afd215ed706a5"
},
"require": {
"ext-curl": "*",
@ -1953,7 +1953,7 @@
}
],
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"time": "2020-07-26T09:32:03+00:00"
"time": "2020-07-26T07:11:06+00:00"
},
{
"name": "doctrine/instantiator",