Skip to content

Commit f4d5bbf

Browse files
ChiragAgg5kChirag Aggarwal
andauthored
feat: SDK update for version 0.6.0 (#8)
* chore: update Console Python SDK to 0.1.0 * chore: update Console Python SDK to 0.1.0 * chore: update Console Python SDK to 0.2.0 * chore: update Console Python SDK to 0.2.1 * chore: update Console Python SDK to 0.3.0 * chore: update Console Python SDK to 0.4.0 * chore: update Console Python SDK to 0.4.0 * chore: update Console Python SDK to 0.5.0 * chore: update Console Python SDK to 0.5.0 * chore: update Console Python SDK to 0.5.0 * chore: update Console Python SDK to 0.6.0 * chore: update Console Python SDK to 0.6.0 * chore: update Console Python SDK to 0.6.0 * chore: update Console Python SDK to 0.6.0 --------- Co-authored-by: Chirag Aggarwal <chirag@appwrite.io>
1 parent a24a77f commit f4d5bbf

621 files changed

Lines changed: 32657 additions & 28014 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Change Log
22

3+
## 0.6.0
4+
5+
* Breaking: `Execution.functionId` replaced by `resourceId` and `resourceType`
6+
* Breaking: `UsageEventMetric` and `UsageGaugeMetric` are plain string constants, not `Enum` members
7+
* Breaking: `list_events` and `list_gauges` take `metrics` as plain strings
8+
* Breaking: `UsageOrganizationProject` usage fields are single totals, not `List[Metric]`
9+
* Breaking: `conditions`, `resourceData`, `items`, `discounts`, `authorizationDetails` and `rows` are lists, not dicts
10+
* Breaking: Removed `ProjectKeyScopes.DEDICATEDDATABASES_EXECUTE`
11+
* Breaking: `Addon` enum renamed to `AddonKey`; `get_addon_price` takes `AddonKey`
12+
* Added: `huggingface` OAuth2 provider, `OAuth2HuggingFace` and `update_o_auth2_hugging_face`
13+
* Added: `avatars.get_photo` for Gravatar-backed profile photos
14+
* Added: `scopes` on `sites.create`, `sites.update` and `Site`
15+
* Added: `strategy` and `max_bucket_size` on WAF rate limit rules
16+
* Added: `bun-1.4` runtime and build runtime
17+
* Added: usage metrics for webhook events, phone auth, messages, per-service build mbSeconds and WAF challenges
18+
* Added: `BillingPlan.databaseComputeCredit` and `BillingPlan.supportsDedicatedDatabases`
19+
* Added: `Database.lifecycleState`, `Database.containerStatus` and `Database.error`
20+
* Added: `DatabaseMigration.changelogWatermark`, `replicating` on replicas and members, `DedicatedDatabaseBranchList.total`
21+
* Added: `_APP_VCS_PROVIDERS_WITH_PUBLIC_REPOSITORIES` and `_APP_VCS_PROVIDERS_WITH_REPOSITORY_CREATION`
22+
* Fixed: chunked uploads only probe for prior progress when an `upload_id` is given
23+
* Updated: `Project.wafEnabled` and `UsageDataPoint.time` are optional
24+
325
## 0.5.0
426

527
* Breaking: `Preferences` serializes its keys at the top level, not nested under `data`

‎appwrite_console/__init__.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

‎appwrite_console/client.py‎

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@
1010
from .exception import AppwriteException
1111
from .encoders.value_class_encoder import ValueClassEncoder
1212

13+
1314
class Client:
1415
def __init__(self):
15-
self._chunk_size = 5*1024*1024
16+
self._chunk_size = 5 * 1024 * 1024
1617
self._self_signed = False
1718
self._endpoint = 'https://cloud.appwrite.io/v1'
1819
self._global_headers = {
1920
'content-type': '',
20-
'user-agent' : f'AppwritePythonSDK/0.5.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
21+
'user-agent': f'AppwritePythonSDK/0.6.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
2122
'x-sdk-name': 'Console Python',
2223
'x-sdk-platform': 'console',
2324
'x-sdk-language': 'python',
24-
'x-sdk-version': '0.5.0',
25-
'X-Appwrite-Response-Format' : '1.9.6',
25+
'x-sdk-version': '0.6.0',
26+
'X-Appwrite-Response-Format': '1.9.6',
2627
}
2728
self._config = {}
2829

@@ -179,7 +180,7 @@ def call(self, method, path='', headers=None, params=None, response_type='json')
179180
files=files,
180181
headers=headers,
181182
verify=(not self._self_signed),
182-
allow_redirects=False if response_type == 'location' else True
183+
allow_redirects=False if response_type == 'location' else True,
183184
)
184185

185186
response.raise_for_status()
@@ -202,7 +203,9 @@ def call(self, method, path='', headers=None, params=None, response_type='json')
202203
if response != None:
203204
content_type = response.headers['Content-Type']
204205
if content_type.startswith('application/json'):
205-
raise AppwriteException(response.json()['message'], response.status_code, response.json().get('type'), response.text)
206+
raise AppwriteException(
207+
response.json()['message'], response.status_code, response.json().get('type'), response.text
208+
)
206209
else:
207210
raise AppwriteException(response.text, response.status_code, None, response.text)
208211
else:
@@ -211,11 +214,11 @@ def call(self, method, path='', headers=None, params=None, response_type='json')
211214
def chunked_upload(
212215
self,
213216
path,
214-
headers = None,
215-
params = None,
216-
param_name = '',
217-
on_progress = None,
218-
upload_id = ''
217+
headers=None,
218+
params=None,
219+
param_name='',
220+
on_progress=None,
221+
upload_id='',
219222
):
220223
input_file = params[param_name]
221224

@@ -232,21 +235,17 @@ def chunked_upload(
232235
input_file.data = input.read()
233236

234237
params[param_name] = input_file
235-
return self.call(
236-
'post',
237-
path,
238-
headers,
239-
params
240-
)
238+
return self.call('post', path, headers, params)
241239

242240
offset = 0
243241
counter = 0
244242

245-
try:
246-
result = self.call('get', path + '/' + upload_id, headers)
247-
counter = result['chunksUploaded']
248-
except:
249-
pass
243+
if upload_id:
244+
try:
245+
result = self.call('get', path + '/' + upload_id, headers)
246+
counter = result['chunksUploaded']
247+
except:
248+
pass
250249

251250
if counter > 0:
252251
offset = counter * self._chunk_size
@@ -255,11 +254,13 @@ def chunked_upload(
255254
chunks = []
256255
while offset < size:
257256
end = min(offset + self._chunk_size, size)
258-
chunks.append({
259-
'index': counter,
260-
'start': offset,
261-
'end': end,
262-
})
257+
chunks.append(
258+
{
259+
'index': counter,
260+
'start': offset,
261+
'end': end,
262+
}
263+
)
263264
offset = end
264265
counter = counter + 1
265266

@@ -291,7 +292,7 @@ def upload_chunk(chunk, current_upload_id):
291292
chunk_input = InputFile.from_bytes(
292293
read_chunk(chunk['start'], chunk['end']),
293294
input_file.filename,
294-
getattr(input_file, 'mime_type', None)
295+
getattr(input_file, 'mime_type', None),
295296
)
296297
chunk_params = {**params, param_name: chunk_input}
297298
chunk_headers = {**headers}
@@ -315,13 +316,15 @@ def upload_chunk(chunk, current_upload_id):
315316
uploaded_size = chunks[0]['end']
316317

317318
if on_progress is not None:
318-
on_progress({
319-
"$id": result.get("$id"),
320-
"progress": uploaded_size / size * 100,
321-
"sizeUploaded": uploaded_size,
322-
"chunksTotal": total_chunks,
323-
"chunksUploaded": completed_count,
324-
})
319+
on_progress(
320+
{
321+
"$id": result.get("$id"),
322+
"progress": uploaded_size / size * 100,
323+
"sizeUploaded": uploaded_size,
324+
"chunksTotal": total_chunks,
325+
"chunksUploaded": completed_count,
326+
}
327+
)
325328

326329
def upload_remaining_chunk(chunk):
327330
nonlocal completed_count, uploaded_size, last_result, final_result
@@ -333,13 +336,15 @@ def upload_remaining_chunk(chunk):
333336
if is_upload_complete(chunk_result):
334337
final_result = chunk_result
335338
if on_progress is not None:
336-
on_progress({
337-
"$id": upload_id_header,
338-
"progress": uploaded_size / size * 100,
339-
"sizeUploaded": uploaded_size,
340-
"chunksTotal": total_chunks,
341-
"chunksUploaded": completed_count,
342-
})
339+
on_progress(
340+
{
341+
"$id": upload_id_header,
342+
"progress": uploaded_size / size * 100,
343+
"sizeUploaded": uploaded_size,
344+
"chunksTotal": total_chunks,
345+
"chunksUploaded": completed_count,
346+
}
347+
)
343348

344349
with ThreadPoolExecutor(max_workers=8) as executor:
345350
futures = [executor.submit(upload_remaining_chunk, chunk) for chunk in chunks[1:]]
@@ -354,8 +359,8 @@ def flatten(self, data, prefix='', stringify=False):
354359

355360
for key in data:
356361
value = data[key] if isinstance(data, dict) else key
357-
finalKey = prefix + '[' + key +']' if prefix else key
358-
finalKey = prefix + '[' + str(i) +']' if isinstance(data, list) else finalKey
362+
finalKey = prefix + '[' + key + ']' if prefix else key
363+
finalKey = prefix + '[' + str(i) + ']' if isinstance(data, list) else finalKey
359364
i += 1
360365

361366
if isinstance(value, list) or isinstance(value, dict):
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

‎appwrite_console/encoders/value_class_encoder.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from ..enums.supabase_migration_resource import SupabaseMigrationResource
4242
from ..enums.organization_key_scopes import OrganizationKeyScopes
4343
from ..enums.region import Region
44-
from ..enums.addon import Addon
44+
from ..enums.addon_key import AddonKey
4545
from ..enums.usage_range import UsageRange
4646
from ..enums.project_auth_method_id import ProjectAuthMethodId
4747
from ..enums.project_o_auth2_google_prompt import ProjectOAuth2GooglePrompt
@@ -83,6 +83,7 @@
8383
from ..enums.detection_framework_type import DetectionFrameworkType
8484
from ..enums.detection_runtime_type import DetectionRuntimeType
8585
from ..enums.deployment_status import DeploymentStatus
86+
from ..enums.execution_resource_type import ExecutionResourceType
8687
from ..enums.execution_trigger import ExecutionTrigger
8788
from ..enums.execution_status import ExecutionStatus
8889
from ..enums.o_auth2_google_prompt import OAuth2GooglePrompt
@@ -96,6 +97,7 @@
9697
from ..enums.domain_purchase_status import DomainPurchaseStatus
9798
from ..enums.waf_rule_action import WafRuleAction
9899

100+
99101
class ValueClassEncoder(json.JSONEncoder):
100102
def default(self, o):
101103
if isinstance(o, AppwriteModel):
@@ -224,7 +226,7 @@ def default(self, o):
224226
if isinstance(o, Region):
225227
return o.value
226228

227-
if isinstance(o, Addon):
229+
if isinstance(o, AddonKey):
228230
return o.value
229231

230232
if isinstance(o, UsageRange):
@@ -350,6 +352,9 @@ def default(self, o):
350352
if isinstance(o, DeploymentStatus):
351353
return o.value
352354

355+
if isinstance(o, ExecutionResourceType):
356+
return o.value
357+
353358
if isinstance(o, ExecutionTrigger):
354359
return o.value
355360

‎appwrite_console/enums/__init__.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

‎appwrite_console/enums/account_key_scopes.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from enum import Enum
22

3+
34
class AccountKeyScopes(Enum):
45
ACCOUNT = "account"
56
TEAMS_READ = "teams.read"

‎appwrite_console/enums/adapter.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from enum import Enum
22

3+
34
class Adapter(Enum):
45
STATIC = "static"
56
SSR = "ssr"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from enum import Enum
22

3-
class Addon(Enum):
3+
4+
class AddonKey(Enum):
45
BAA = "baa"
56
PREMIUMGEODB = "premiumgeodb"
67
PREMIUMGEODBORG = "premiumgeodborg"

‎appwrite_console/enums/appwrite_migration_resource.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from enum import Enum
22

3+
34
class AppwriteMigrationResource(Enum):
45
USER = "user"
56
TEAM = "team"

0 commit comments

Comments
 (0)