@@ -214,9 +214,9 @@ def validate_auth(self):
214214 raise ClientError ("Missing login or password" )
215215
216216 @staticmethod
217- def _check_token (f ):
217+ def check_token (f ):
218218 """Wrapper for creating/renewing authorization token.
219- Every function that requires authentication should be decorated with this as @_check_token ."""
219+ Every function that requires authentication should be decorated with this as @check_token ."""
220220
221221 def wrapper (self , * args , ** kwargs ):
222222 # functions that run prior to required function using this decorator
@@ -329,7 +329,7 @@ def username(self):
329329 return None # not authenticated
330330 return self ._user_info ["username" ]
331331
332- @_check_token
332+ @check_token
333333 def workspace_service (self , workspace_id ):
334334 """
335335 This Requests information about a workspace service from /workspace/{id}/service endpoint,
@@ -340,7 +340,7 @@ def workspace_service(self, workspace_id):
340340 resp = self .get (f"/v1/workspace/{ workspace_id } /service" )
341341 return json .load (resp )
342342
343- @_check_token
343+ @check_token
344344 def workspace_usage (self , workspace_id ):
345345 """
346346 This Requests information about a workspace usage from /workspace/{id}/usage endpoint,
@@ -393,7 +393,7 @@ def server_version(self):
393393
394394 return self ._server_version
395395
396- @_check_token
396+ @check_token
397397 def workspaces_list (self ):
398398 """
399399 Find all available workspaces
@@ -404,7 +404,7 @@ def workspaces_list(self):
404404 workspaces = json .load (resp )
405405 return workspaces
406406
407- @_check_token
407+ @check_token
408408 def create_workspace (self , workspace_name ):
409409 """
410410 Create new workspace for currently active user.
@@ -423,7 +423,7 @@ def create_workspace(self, workspace_name):
423423 e .extra = f"Workspace name: { workspace_name } "
424424 raise e
425425
426- @_check_token
426+ @check_token
427427 def create_project (self , project_name , is_public = False , namespace = None ):
428428 """
429429 Create new project repository in user namespace on Mergin Maps server.
@@ -473,7 +473,7 @@ def create_project(self, project_name, is_public=False, namespace=None):
473473 e .extra = f"Namespace: { namespace } , project name: { project_name } "
474474 raise e
475475
476- @_check_token
476+ @check_token
477477 def create_project_and_push (self , project_name , directory , is_public = False , namespace = None ):
478478 """
479479 Convenience method to create project and push the initial version right after that.
@@ -519,7 +519,7 @@ def create_project_and_push(self, project_name, directory, is_public=False, name
519519 if mp .inspect_files ():
520520 self .push_project (directory )
521521
522- @_check_token
522+ @check_token
523523 def paginated_projects_list (
524524 self ,
525525 page = 1 ,
@@ -593,7 +593,7 @@ def paginated_projects_list(
593593 projects = json .load (resp )
594594 return projects
595595
596- @_check_token
596+ @check_token
597597 def projects_list (
598598 self ,
599599 tags = None ,
@@ -663,7 +663,7 @@ def projects_list(
663663 break
664664 return projects
665665
666- @_check_token
666+ @check_token
667667 def project_info (self , project_path_or_id , since = None , version = None ):
668668 """
669669 Fetch info about project.
@@ -687,7 +687,7 @@ def project_info(self, project_path_or_id, since=None, version=None):
687687 resp = self .get ("/v1/project/{}" .format (project_path_or_id ), params )
688688 return json .load (resp )
689689
690- @_check_token
690+ @check_token
691691 def paginated_project_versions (self , project_path , page , per_page = 100 , descending = False ):
692692 """
693693 Get records of project's versions (history) using calculated pagination.
@@ -709,7 +709,7 @@ def paginated_project_versions(self, project_path, page, per_page=100, descendin
709709 resp_json = json .load (resp )
710710 return resp_json ["versions" ], resp_json ["count" ]
711711
712- @_check_token
712+ @check_token
713713 def project_versions_count (self , project_path ):
714714 """
715715 return the total count of versions
@@ -725,7 +725,7 @@ def project_versions_count(self, project_path):
725725 resp_json = json .load (resp )
726726 return resp_json ["count" ]
727727
728- @_check_token
728+ @check_token
729729 def project_versions (self , project_path , since = 1 , to = None ):
730730 """
731731 Get records of project's versions (history) in ascending order.
@@ -773,7 +773,7 @@ def project_versions(self, project_path, since=1, to=None):
773773 filtered_versions = list (filter (lambda v : (num_since <= int_version (v ["name" ]) <= num_to ), versions ))
774774 return filtered_versions
775775
776- @_check_token
776+ @check_token
777777 def download_project (self , project_path , directory , version = None ):
778778 """
779779 Download project into given directory. If version is not specified, latest version is downloaded
@@ -791,7 +791,7 @@ def download_project(self, project_path, directory, version=None):
791791 download_project_wait (job )
792792 download_project_finalize (job )
793793
794- @_check_token
794+ @check_token
795795 def user_info (self ):
796796 server_type = self .server_type ()
797797 if server_type == ServerType .OLD :
@@ -800,7 +800,7 @@ def user_info(self):
800800 resp = self .get ("/v1/user/profile" )
801801 return json .load (resp )
802802
803- @_check_token
803+ @check_token
804804 def set_project_access (self , project_path , access ):
805805 """
806806 Updates access for given project.
@@ -824,7 +824,7 @@ def set_project_access(self, project_path, access):
824824 e .extra = f"Project path: { project_path } "
825825 raise e
826826
827- @_check_token
827+ @check_token
828828 def add_user_permissions_to_project (self , project_path , usernames , permission_level ):
829829 """
830830 Add specified permissions to specified users to project
@@ -858,7 +858,7 @@ def add_user_permissions_to_project(self, project_path, usernames, permission_le
858858 category = DeprecationWarning ,
859859 )
860860
861- @_check_token
861+ @check_token
862862 def remove_user_permissions_from_project (self , project_path , usernames ):
863863 """
864864 Removes specified users from project
@@ -883,7 +883,7 @@ def remove_user_permissions_from_project(self, project_path, usernames):
883883 category = DeprecationWarning ,
884884 )
885885
886- @_check_token
886+ @check_token
887887 def project_user_permissions (self , project_path ):
888888 """
889889 Returns permissions for project
@@ -904,7 +904,7 @@ def project_user_permissions(self, project_path):
904904 result ["readers" ] = access .get ("readersnames" , [])
905905 return result
906906
907- @_check_token
907+ @check_token
908908 def push_project (self , directory ):
909909 """
910910 Upload local changes to the repository.
@@ -918,7 +918,7 @@ def push_project(self, directory):
918918 push_project_wait (job )
919919 push_project_finalize (job )
920920
921- @_check_token
921+ @check_token
922922 def pull_project (self , directory ):
923923 """
924924 Fetch and apply changes from repository.
@@ -932,7 +932,7 @@ def pull_project(self, directory):
932932 pull_project_wait (job )
933933 return pull_project_finalize (job )
934934
935- @_check_token
935+ @check_token
936936 def clone_project (self , source_project_path , cloned_project_name , cloned_project_namespace = None ):
937937 """
938938 Clone project on server.
@@ -978,7 +978,7 @@ def clone_project(self, source_project_path, cloned_project_name, cloned_project
978978 request = urllib .request .Request (url , data = json .dumps (data ).encode (), headers = json_headers , method = "POST" )
979979 self ._do_request (request )
980980
981- @_check_token
981+ @check_token
982982 def delete_project_now (self , project_path ):
983983 """
984984 Delete project repository on server immediately.
@@ -1002,7 +1002,7 @@ def delete_project_now(self, project_path):
10021002 request = urllib .request .Request (url , method = "DELETE" )
10031003 self ._do_request (request )
10041004
1005- @_check_token
1005+ @check_token
10061006 def delete_project (self , project_path ):
10071007 """
10081008 Delete project repository on server. Newer servers since 2023
@@ -1027,7 +1027,7 @@ def delete_project(self, project_path):
10271027 request = urllib .request .Request (url , method = "DELETE" )
10281028 self ._do_request (request )
10291029
1030- @_check_token
1030+ @check_token
10311031 def project_status (self , directory ):
10321032 """
10331033 Get project status, e.g. server and local changes.
@@ -1047,27 +1047,27 @@ def project_status(self, directory):
10471047
10481048 return pull_changes , push_changes , push_changes_summary
10491049
1050- @_check_token
1050+ @check_token
10511051 def project_version_info (self , project_id , version ):
10521052 """Returns JSON with detailed information about a single project version"""
10531053 resp = self .get (f"/v1/project/version/{ project_id } /{ version } " )
10541054 return json .load (resp )
10551055
1056- @_check_token
1056+ @check_token
10571057 def project_file_history_info (self , project_path , file_path ):
10581058 """Returns JSON with full history of a single file within a project"""
10591059 params = {"path" : file_path }
10601060 resp = self .get ("/v1/resource/history/{}" .format (project_path ), params )
10611061 return json .load (resp )
10621062
1063- @_check_token
1063+ @check_token
10641064 def project_file_changeset_info (self , project_path , file_path , version ):
10651065 """Returns JSON with changeset details of a particular version of a file within a project"""
10661066 params = {"path" : file_path }
10671067 resp = self .get ("/v1/resource/changesets/{}/{}" .format (project_path , version ), params )
10681068 return json .load (resp )
10691069
1070- @_check_token
1070+ @check_token
10711071 def get_projects_by_names (self , projects ):
10721072 """Returns JSON with projects' info for list of required projects.
10731073 The schema of the returned information is the same as the response from projects_list().
@@ -1082,7 +1082,7 @@ def get_projects_by_names(self, projects):
10821082 resp = self .post ("/v1/project/by_names" , {"projects" : projects }, {"Content-Type" : "application/json" })
10831083 return json .load (resp )
10841084
1085- @_check_token
1085+ @check_token
10861086 def download_file (self , project_dir , file_path , output_filename , version = None ):
10871087 """
10881088 Download project file at specified version. Get the latest if no version specified.
@@ -1136,7 +1136,7 @@ def get_file_diff(self, project_dir, file_path, output_diff, version_from, versi
11361136 elif len (diffs ) == 1 :
11371137 shutil .copy (diffs [0 ], output_diff )
11381138
1139- @_check_token
1139+ @check_token
11401140 def download_file_diffs (self , project_dir , file_path , versions ):
11411141 """Download file diffs for specified versions if they are not present
11421142 in the cache.
@@ -1213,7 +1213,7 @@ def has_writing_permissions(self, project_path):
12131213 info = self .project_info (project_path )
12141214 return info ["permissions" ]["upload" ]
12151215
1216- @_check_token
1216+ @check_token
12171217 def rename_project (self , project_path : str , new_project_name : str ) -> None :
12181218 """
12191219 Rename project on server.
@@ -1285,7 +1285,7 @@ def reset_local_changes(self, directory: str, files_to_reset: typing.List[str] =
12851285 if files_download :
12861286 self .download_files (directory , files_download , version = current_version )
12871287
1288- @_check_token
1288+ @check_token
12891289 def download_files (
12901290 self , project_dir : str , file_paths : typing .List [str ], output_paths : typing .List [str ] = None , version : str = None
12911291 ):
@@ -1311,7 +1311,7 @@ def has_editor_support(self):
13111311 """
13121312 return is_version_acceptable (self .server_version (), "2024.4.0" )
13131313
1314- @_check_token
1314+ @check_token
13151315 def create_user (
13161316 self ,
13171317 email : str ,
@@ -1343,23 +1343,23 @@ def create_user(
13431343 user_info = self .post ("v2/users" , params , json_headers )
13441344 return json .load (user_info )
13451345
1346- @_check_token
1346+ @check_token
13471347 def get_workspace_member (self , workspace_id : int , user_id : int ) -> dict :
13481348 """
13491349 Get a workspace member detail
13501350 """
13511351 resp = self .get (f"v2/workspaces/{ workspace_id } /members/{ user_id } " )
13521352 return json .load (resp )
13531353
1354- @_check_token
1354+ @check_token
13551355 def list_workspace_members (self , workspace_id : int ) -> List [dict ]:
13561356 """
13571357 Get a list of workspace members
13581358 """
13591359 resp = self .get (f"v2/workspaces/{ workspace_id } /members" )
13601360 return json .load (resp )
13611361
1362- @_check_token
1362+ @check_token
13631363 def update_workspace_member (
13641364 self , workspace_id : int , user_id : int , workspace_role : WorkspaceRole , reset_projects_roles : bool = False
13651365 ) -> dict :
@@ -1375,22 +1375,22 @@ def update_workspace_member(
13751375 workspace_member = self .patch (f"v2/workspaces/{ workspace_id } /members/{ user_id } " , params , json_headers )
13761376 return json .load (workspace_member )
13771377
1378- @_check_token
1378+ @check_token
13791379 def remove_workspace_member (self , workspace_id : int , user_id : int ):
13801380 """
13811381 Remove a user from workspace members
13821382 """
13831383 self .delete (f"v2/workspaces/{ workspace_id } /members/{ user_id } " )
13841384
1385- @_check_token
1385+ @check_token
13861386 def list_project_collaborators (self , project_id : str ) -> List [dict ]:
13871387 """
13881388 Get a list of project collaborators
13891389 """
13901390 project_collaborators = self .get (f"v2/projects/{ project_id } /collaborators" )
13911391 return json .load (project_collaborators )
13921392
1393- @_check_token
1393+ @check_token
13941394 def add_project_collaborator (self , project_id : str , user : str , project_role : ProjectRole ) -> dict :
13951395 """
13961396 Add a user to project collaborators and grant them a project role.
@@ -1402,7 +1402,7 @@ def add_project_collaborator(self, project_id: str, user: str, project_role: Pro
14021402 project_collaborator = self .post (f"v2/projects/{ project_id } /collaborators" , params , json_headers )
14031403 return json .load (project_collaborator )
14041404
1405- @_check_token
1405+ @check_token
14061406 def update_project_collaborator (self , project_id : str , user_id : int , project_role : ProjectRole ) -> dict :
14071407 """
14081408 Update project role of the existing project collaborator.
@@ -1412,7 +1412,7 @@ def update_project_collaborator(self, project_id: str, user_id: int, project_rol
14121412 project_collaborator = self .patch (f"v2/projects/{ project_id } /collaborators/{ user_id } " , params , json_headers )
14131413 return json .load (project_collaborator )
14141414
1415- @_check_token
1415+ @check_token
14161416 def remove_project_collaborator (self , project_id : str , user_id : int ):
14171417 """
14181418 Remove a user from project collaborators
@@ -1424,7 +1424,7 @@ def server_config(self) -> dict:
14241424 response = self .get ("/config" )
14251425 return json .load (response )
14261426
1427- @_check_token
1427+ @check_token
14281428 def send_logs (
14291429 self ,
14301430 logfile : str ,
0 commit comments