Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions appwrite_console/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,10 @@ def flatten(self, data, prefix='', stringify=False):

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
if isinstance(data, list):
finalKey = prefix + '[' + str(i) + ']'
else:
finalKey = prefix + '[' + key + ']' if prefix else key
i += 1

if isinstance(value, list) or isinstance(value, dict):
Expand Down
14 changes: 14 additions & 0 deletions appwrite_console/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ def _normalize_value(self, value: Any) -> Any:

return value

def _validate_string_list(self, name: str, value: Any, nullable_items: bool = False) -> None:
"""Validate item types; generated required checks handle missing lists."""
if value is None:
return

if not isinstance(value, list) or any(
not isinstance(self._normalize_value(item), str) and not (nullable_items and item is None) for item in value
):
expected = 'strings or None' if nullable_items else 'strings'
raise AppwriteException(
f'Invalid parameter: "{name}" must be a list of {expected}.',
type='sdk_input_validation',
)

def _parse_response(self, response: Any, model: Optional[Type[ModelType]] = None) -> Any:
if model is None:
return response
Expand Down
11 changes: 11 additions & 0 deletions appwrite_console/services/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def list_billing_addresses(

api_path = '/account/billing-addresses'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down Expand Up @@ -461,6 +462,7 @@ def list_consents(

api_path = '/account/consents'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
if total is not None:
Expand Down Expand Up @@ -591,6 +593,7 @@ def list_consent_tokens(
api_params = {}
if consent_id is None:
raise AppwriteException('Missing required parameter: "consent_id"')
self._validate_string_list('queries', queries)
api_path = api_path.replace('{consentId}', str(self._normalize_value(consent_id)))
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
Expand Down Expand Up @@ -821,6 +824,7 @@ def list_identities(

api_path = '/account/identities'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
if total is not None:
Expand Down Expand Up @@ -902,6 +906,7 @@ def list_invoices(

api_path = '/account/invoices'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down Expand Up @@ -1030,6 +1035,7 @@ def create_key(
raise AppwriteException('Missing required parameter: "name"')
if scopes is None:
raise AppwriteException('Missing required parameter: "scopes"')
self._validate_string_list('scopes', scopes)
api_params['name'] = self._normalize_value(name)
api_params['scopes'] = self._normalize_value(scopes)
if expire is not None:
Expand Down Expand Up @@ -1127,6 +1133,7 @@ def update_key(
raise AppwriteException('Missing required parameter: "name"')
if scopes is None:
raise AppwriteException('Missing required parameter: "scopes"')
self._validate_string_list('scopes', scopes)
api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id)))
api_params['name'] = self._normalize_value(name)
api_params['scopes'] = self._normalize_value(scopes)
Expand Down Expand Up @@ -1214,6 +1221,7 @@ def list_logs(

api_path = '/account/logs'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
if total is not None:
Expand Down Expand Up @@ -1741,6 +1749,7 @@ def list_payment_methods(

api_path = '/account/payment-methods'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down Expand Up @@ -2494,6 +2503,7 @@ def create_o_auth2_session(
api_params = {}
if provider is None:
raise AppwriteException('Missing required parameter: "provider"')
self._validate_string_list('scopes', scopes)
api_path = api_path.replace('{provider}', str(self._normalize_value(provider)))
if success is not None:
api_params['success'] = self._normalize_value(success)
Expand Down Expand Up @@ -3063,6 +3073,7 @@ def create_o_auth2_token(
api_params = {}
if provider is None:
raise AppwriteException('Missing required parameter: "provider"')
self._validate_string_list('scopes', scopes)
api_path = api_path.replace('{provider}', str(self._normalize_value(provider)))
if success is not None:
api_params['success'] = self._normalize_value(success)
Expand Down
1 change: 1 addition & 0 deletions appwrite_console/services/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def list_events(

api_path = '/activities/events'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down
2 changes: 2 additions & 0 deletions appwrite_console/services/advisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def list_reports(

api_path = '/reports'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
if total is not None:
Expand Down Expand Up @@ -170,6 +171,7 @@ def list_insights(
api_params = {}
if report_id is None:
raise AppwriteException('Missing required parameter: "report_id"')
self._validate_string_list('queries', queries)
api_path = api_path.replace('{reportId}', str(self._normalize_value(report_id)))
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
Expand Down
3 changes: 3 additions & 0 deletions appwrite_console/services/affiliates.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def list_links(

api_path = '/affiliates/links'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down Expand Up @@ -205,6 +206,7 @@ def list_referrals(

api_path = '/affiliates/referrals'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down Expand Up @@ -244,6 +246,7 @@ def list_rewards(

api_path = '/affiliates/rewards'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down
16 changes: 16 additions & 0 deletions appwrite_console/services/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def list(

api_path = '/apps'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
if total is not None:
Expand Down Expand Up @@ -149,6 +150,11 @@ def create(
raise AppwriteException('Missing required parameter: "name"')
if redirect_uris is None:
raise AppwriteException('Missing required parameter: "redirect_uris"')
self._validate_string_list('redirect_uris', redirect_uris)
self._validate_string_list('contacts', contacts)
self._validate_string_list('tags', tags)
self._validate_string_list('images', images)
self._validate_string_list('post_logout_redirect_uris', post_logout_redirect_uris)
api_params['appId'] = self._normalize_value(app_id)
api_params['name'] = self._normalize_value(name)
if description is not None:
Expand Down Expand Up @@ -385,6 +391,12 @@ def update(
raise AppwriteException('Missing required parameter: "app_id"')
if name is None:
raise AppwriteException('Missing required parameter: "name"')
self._validate_string_list('contacts', contacts)
self._validate_string_list('tags', tags)
self._validate_string_list('images', images)
self._validate_string_list('redirect_uris', redirect_uris)
self._validate_string_list('post_logout_redirect_uris', post_logout_redirect_uris)
self._validate_string_list('installation_scopes', installation_scopes)
api_path = api_path.replace('{appId}', str(self._normalize_value(app_id)))
api_params['name'] = self._normalize_value(name)
if description is not None:
Expand Down Expand Up @@ -510,6 +522,7 @@ def list_installations(
api_params = {}
if app_id is None:
raise AppwriteException('Missing required parameter: "app_id"')
self._validate_string_list('queries', queries)
api_path = api_path.replace('{appId}', str(self._normalize_value(app_id)))
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
Expand Down Expand Up @@ -700,6 +713,7 @@ def list_keys(
api_params = {}
if app_id is None:
raise AppwriteException('Missing required parameter: "app_id"')
self._validate_string_list('queries', queries)
api_path = api_path.replace('{appId}', str(self._normalize_value(app_id)))
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
Expand Down Expand Up @@ -883,6 +897,7 @@ def update_labels(
raise AppwriteException('Missing required parameter: "app_id"')
if labels is None:
raise AppwriteException('Missing required parameter: "labels"')
self._validate_string_list('labels', labels)
api_path = api_path.replace('{appId}', str(self._normalize_value(app_id)))
api_params['labels'] = self._normalize_value(labels)

Expand Down Expand Up @@ -931,6 +946,7 @@ def list_secrets(
api_params = {}
if app_id is None:
raise AppwriteException('Missing required parameter: "app_id"')
self._validate_string_list('queries', queries)
api_path = api_path.replace('{appId}', str(self._normalize_value(app_id)))
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
Expand Down
1 change: 1 addition & 0 deletions appwrite_console/services/avatars.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ def get_screenshot(
api_params = {}
if url is None:
raise AppwriteException('Missing required parameter: "url"')
self._validate_string_list('permissions', permissions)
api_params['url'] = self._normalize_value(url)
if headers is not None:
api_params['headers'] = self._normalize_value(headers)
Expand Down
6 changes: 6 additions & 0 deletions appwrite_console/services/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def list_archives(

api_path = '/backups/archives'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down Expand Up @@ -85,6 +86,7 @@ def create_archive(
api_params = {}
if services is None:
raise AppwriteException('Missing required parameter: "services"')
self._validate_string_list('services', services)
api_params['services'] = self._normalize_value(services)
if resource_id is not None:
api_params['resourceId'] = self._normalize_value(resource_id)
Expand Down Expand Up @@ -207,6 +209,7 @@ def list_policies(

api_path = '/backups/policies'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down Expand Up @@ -272,6 +275,7 @@ def create_policy(
raise AppwriteException('Missing required parameter: "retention"')
if schedule is None:
raise AppwriteException('Missing required parameter: "schedule"')
self._validate_string_list('services', services)
api_params['policyId'] = self._normalize_value(policy_id)
if name is not None:
api_params['name'] = self._normalize_value(name)
Expand Down Expand Up @@ -483,6 +487,7 @@ def create_restoration(
raise AppwriteException('Missing required parameter: "archive_id"')
if services is None:
raise AppwriteException('Missing required parameter: "services"')
self._validate_string_list('services', services)
api_params['archiveId'] = self._normalize_value(archive_id)
api_params['services'] = self._normalize_value(services)
if new_resource_id is not None:
Expand Down Expand Up @@ -527,6 +532,7 @@ def list_restorations(

api_path = '/backups/restorations'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)

Expand Down
1 change: 1 addition & 0 deletions appwrite_console/services/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def list_databases(

api_path = '/console/databases'
api_params = {}
self._validate_string_list('queries', queries)
if queries is not None:
api_params['queries'] = self._normalize_value(queries)
if search is not None:
Expand Down
Loading