diff libervia/server/restricted_bridge.py @ 1509:106bae41f5c8

massive refactoring from camelCase -> snake_case. See backend commit log for more details
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:44:11 +0200
parents e739600267cd
children a3ca1bab6eb1
line wrap: on
line diff
--- a/libervia/server/restricted_bridge.py	Fri Apr 07 15:20:40 2023 +0200
+++ b/libervia/server/restricted_bridge.py	Sat Apr 08 13:44:11 2023 +0200
@@ -22,7 +22,7 @@
 
 
 class RestrictedBridge:
-    """Bridge with limited access, which can be used in browser
+    """bridge with limited access, which can be used in browser
 
     Only a few method are implemented, with potentially dangerous argument controlled.
     Security limit is used
@@ -32,70 +32,70 @@
         self.host = host
         self.security_limit = C.SECURITY_LIMIT
 
-    def noServiceProfile(self, profile):
+    def no_service_profile(self, profile):
         """Raise an error if service profile is used"""
         if profile == C.SERVICE_PROFILE:
             raise exceptions.PermissionError(
                 "This action is not allowed for service profile"
             )
 
-    async def getContacts(self, profile):
-        return await self.host.bridgeCall("getContacts", profile)
+    async def contacts_get(self, profile):
+        return await self.host.bridge_call("contacts_get", profile)
 
-    async def identityGet(self, entity, metadata_filter, use_cache, profile):
-        return await self.host.bridgeCall(
-            "identityGet", entity, metadata_filter, use_cache, profile)
+    async def identity_get(self, entity, metadata_filter, use_cache, profile):
+        return await self.host.bridge_call(
+            "identity_get", entity, metadata_filter, use_cache, profile)
 
-    async def identitiesGet(self, entities, metadata_filter, profile):
-        return await self.host.bridgeCall(
-            "identitiesGet", entities, metadata_filter, profile)
+    async def identities_get(self, entities, metadata_filter, profile):
+        return await self.host.bridge_call(
+            "identities_get", entities, metadata_filter, profile)
 
-    async def identitiesBaseGet(self, profile):
-        return await self.host.bridgeCall(
-            "identitiesBaseGet", profile)
+    async def identities_base_get(self, profile):
+        return await self.host.bridge_call(
+            "identities_base_get", profile)
 
-    async def psNodeDelete(self, service_s, node, profile):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "psNodeDelete", service_s, node, profile)
+    async def ps_node_delete(self, service_s, node, profile):
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "ps_node_delete", service_s, node, profile)
 
-    async def psNodeAffiliationsSet(self, service_s, node, affiliations, profile):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "psNodeAffiliationsSet", service_s, node, affiliations, profile)
+    async def ps_node_affiliations_set(self, service_s, node, affiliations, profile):
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "ps_node_affiliations_set", service_s, node, affiliations, profile)
 
-    async def psItemRetract(self, service_s, node, item_id, notify, profile):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "psItemRetract", service_s, node, item_id, notify, profile)
+    async def ps_item_retract(self, service_s, node, item_id, notify, profile):
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "ps_item_retract", service_s, node, item_id, notify, profile)
 
-    async def mbPreview(self, service_s, node, data, profile):
-        return await self.host.bridgeCall(
-            "mbPreview", service_s, node, data, profile)
+    async def mb_preview(self, service_s, node, data, profile):
+        return await self.host.bridge_call(
+            "mb_preview", service_s, node, data, profile)
 
-    async def listSet(self, service_s, node, values, schema, item_id, extra, profile):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "listSet", service_s, node, values, "", item_id, "", profile)
+    async def list_set(self, service_s, node, values, schema, item_id, extra, profile):
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "list_set", service_s, node, values, "", item_id, "", profile)
 
 
-    async def fileHTTPUploadGetSlot(
+    async def file_http_upload_get_slot(
         self, filename, size, content_type, upload_jid, profile):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "fileHTTPUploadGetSlot", filename, size, content_type,
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "file_http_upload_get_slot", filename, size, content_type,
             upload_jid, profile)
 
-    async def fileSharingDelete(
+    async def file_sharing_delete(
         self, service_jid, path, namespace, profile):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "fileSharingDelete", service_jid, path, namespace, profile)
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "file_sharing_delete", service_jid, path, namespace, profile)
 
-    async def interestsRegisterFileSharing(
+    async def interests_file_sharing_register(
         self, service, repos_type, namespace, path, name, extra_s, profile
     ):
-        self.noServiceProfile(profile)
+        self.no_service_profile(profile)
         if extra_s:
             # we only allow "thumb_url" here
             extra = data_format.deserialise(extra_s)
@@ -104,31 +104,31 @@
             else:
                 extra_s = ""
 
-        return await self.host.bridgeCall(
-            "interestsRegisterFileSharing", service, repos_type, namespace, path, name,
+        return await self.host.bridge_call(
+            "interests_file_sharing_register", service, repos_type, namespace, path, name,
             extra_s, profile
         )
 
-    async def interestRetract(
+    async def interest_retract(
         self, service_jid, item_id, profile
     ):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "interestRetract", service_jid, item_id, profile)
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "interest_retract", service_jid, item_id, profile)
 
-    async def psInvite(
+    async def ps_invite(
         self, invitee_jid_s, service_s, node, item_id, name, extra_s, profile
     ):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "psInvite", invitee_jid_s, service_s, node, item_id, name, extra_s, profile
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "ps_invite", invitee_jid_s, service_s, node, item_id, name, extra_s, profile
         )
 
-    async def FISInvite(
+    async def fis_invite(
         self, invitee_jid_s, service_s, repos_type, namespace, path, name, extra_s,
         profile
     ):
-        self.noServiceProfile(profile)
+        self.no_service_profile(profile)
         if extra_s:
             # we only allow "thumb_url" here
             extra = data_format.deserialise(extra_s)
@@ -137,24 +137,24 @@
             else:
                 extra_s = ""
 
-        return await self.host.bridgeCall(
-            "FISInvite", invitee_jid_s, service_s, repos_type, namespace, path, name,
+        return await self.host.bridge_call(
+            "fis_invite", invitee_jid_s, service_s, repos_type, namespace, path, name,
             extra_s, profile
         )
 
-    async def FISAffiliationsSet(
+    async def fis_affiliations_set(
         self, service_s, namespace, path, affiliations, profile
     ):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "FISAffiliationsSet", service_s, namespace, path, affiliations, profile
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "fis_affiliations_set", service_s, namespace, path, affiliations, profile
         )
 
-    async def invitationSimpleCreate(
+    async def invitation_simple_create(
         self, invitee_email, invitee_name, url_template, extra_s, profile
     ):
-        self.noServiceProfile(profile)
-        return await self.host.bridgeCall(
-            "invitationSimpleCreate", invitee_email, invitee_name, url_template, extra_s,
+        self.no_service_profile(profile)
+        return await self.host.bridge_call(
+            "invitation_simple_create", invitee_email, invitee_name, url_template, extra_s,
             profile
         )