From 419649745fc7eb084949d6aab700b5fc8c35b85d Mon Sep 17 00:00:00 2001 From: Florent <48032461+FlorentLvr@users.noreply.github.com> Date: Wed, 19 Jun 2024 14:41:39 +0200 Subject: [PATCH 1/4] fix: rename domain function assets --- naas_python/domains/asset/AssetSchema.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/naas_python/domains/asset/AssetSchema.py b/naas_python/domains/asset/AssetSchema.py index 56e81e6..a38aba5 100644 --- a/naas_python/domains/asset/AssetSchema.py +++ b/naas_python/domains/asset/AssetSchema.py @@ -34,21 +34,21 @@ class IAssetDomain(metaclass=ABCMeta): adaptor: IAssetAdaptor @abstractmethod - def create_asset(self, workspace_id:str, asset_creation:AssetCreation) -> Asset: + def create(self, workspace_id:str, asset_creation:AssetCreation) -> Asset: raise NotImplementedError() @abstractmethod - def get_asset(self, workspace_id:str, asset_id:str) -> Asset: + def get(self, workspace_id:str, asset_id:str) -> Asset: raise NotImplementedError() @abstractmethod - def update_asset(self, workspace_id:str, asset_id:str, asset_update: AssetUpdate) -> Asset: + def update(self, workspace_id:str, asset_id:str, asset_update: AssetUpdate) -> Asset: raise NotImplementedError() @abstractmethod - def delete_asset(self, workspace_id:str, asset_id:str) -> None: + def delete(self, workspace_id:str, asset_id:str) -> None: raise NotImplementedError() # Primary Adaptor class IAssetPrimaryAdaptor: - pass \ No newline at end of file + pass From 74e4c49c3646129cdc560d018bb5194aa2725090 Mon Sep 17 00:00:00 2001 From: Florent <48032461+FlorentLvr@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:50:43 +0200 Subject: [PATCH 2/4] fix: update AssetDomain.py --- naas_python/domains/asset/AssetDomain.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/naas_python/domains/asset/AssetDomain.py b/naas_python/domains/asset/AssetDomain.py index cfa4391..57bf200 100644 --- a/naas_python/domains/asset/AssetDomain.py +++ b/naas_python/domains/asset/AssetDomain.py @@ -14,19 +14,19 @@ class AssetDomain(IAssetDomain): def __init__(self, adaptor: IAssetAdaptor): self.adaptor = adaptor - def create_asset(self, workspace_id:str, asset_creation:AssetCreation) -> Asset: + def create(self, workspace_id:str, asset_creation:AssetCreation) -> Asset: asset = self.adaptor.create_asset(workspace_id, asset_creation) return asset - def get_asset(self, workspace_id:str, asset_id:str) -> Asset: + def get(self, workspace_id:str, asset_id:str) -> Asset: asset = self.adaptor.get_asset(workspace_id, asset_id) return asset - def update_asset(self, workspace_id:str, asset_id:str, asset_update: AssetUpdate) -> Asset: + def update(self, workspace_id:str, asset_id:str, asset_update: AssetUpdate) -> Asset: response = self.adaptor.update_asset(workspace_id, asset_id, asset_update) return response - def delete_asset(self, workspace_id:str, asset_id:str) -> None: + def delete(self, workspace_id:str, asset_id:str) -> None: self.adaptor.delete_asset(workspace_id, asset_id) - return None \ No newline at end of file + return None From 86c987a6b972116ac24edadd17953a465f698db6 Mon Sep 17 00:00:00 2001 From: Florent <48032461+FlorentLvr@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:54:59 +0200 Subject: [PATCH 3/4] refactor: update StorageDomain.py --- naas_python/domains/storage/StorageDomain.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/naas_python/domains/storage/StorageDomain.py b/naas_python/domains/storage/StorageDomain.py index 5b0a21b..feaa924 100644 --- a/naas_python/domains/storage/StorageDomain.py +++ b/naas_python/domains/storage/StorageDomain.py @@ -18,7 +18,7 @@ def __init__(self, adaptor: IStorageAdaptor, storage_provider_adaptors : Mapping self.storage_provider_adaptors : Mapping[str, IStorageProviderAdaptor] = storage_provider_adaptors ############### API ############### - def create_workspace_storage(self, + def create(self, workspace_id: str, storage_name: Storage.__fields__['name'], ) -> dict: @@ -28,7 +28,7 @@ def create_workspace_storage(self, ) return response - def delete_workspace_storage(self, + def delete(self, workspace_id: str, storage_name: Storage.__fields__['name'] ) -> dict: @@ -38,7 +38,7 @@ def delete_workspace_storage(self, ) return response - def list_workspace_storage(self, + def list(self, workspace_id: str, ) -> dict: response = self.adaptor.list_workspace_storage( @@ -46,7 +46,7 @@ def list_workspace_storage(self, ) return response - def list_workspace_storage_object(self, + def list_objects(self, workspace_id: str, storage_name: Storage.__fields__['name'], storage_prefix: Object.__fields__['prefix'], @@ -58,7 +58,7 @@ def list_workspace_storage_object(self, ) return response - def delete_workspace_storage_object(self, + def delete_object(self, workspace_id: str, storage_name: Storage.__fields__['name'], object_name: Object.__fields__['name'], @@ -70,7 +70,7 @@ def delete_workspace_storage_object(self, ) return response - def create_workspace_storage_credentials(self, + def create_credentials(self, workspace_id: str, storage_name: Storage.__fields__['name'], ) -> dict: @@ -96,7 +96,7 @@ def __get_storage_provider_adaptor(self, return self.storage_provider_adaptors[storage_provider_id] - def post_workspace_storage_object(self, + def post_object(self, workspace_id: str, storage_name: Storage.__fields__['name'], src_file: str, @@ -117,7 +117,7 @@ def post_workspace_storage_object(self, response = storage_provider.post_workspace_storage_object(workspace_id=workspace_id, storage_name=storage_name, src_file=src_file, dst_file=dst_file) return response - def get_workspace_storage_object(self, + def get_object(self, workspace_id: str, storage_name: Storage.__fields__['name'], src_file: str, @@ -136,4 +136,4 @@ def get_workspace_storage_object(self, storage_provider.save_naas_credentials(workspace_id, storage_name, credentials) response = storage_provider.get_workspace_storage_object(workspace_id=workspace_id, storage_name=storage_name, src_file=src_file, dst_file=dst_file) - return response \ No newline at end of file + return response From 581a8dde0dbee430e86be92bad383e097c859e87 Mon Sep 17 00:00:00 2001 From: Florent <48032461+FlorentLvr@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:56:19 +0200 Subject: [PATCH 4/4] refactor: update StorageSchema.py function names --- naas_python/domains/storage/StorageSchema.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/naas_python/domains/storage/StorageSchema.py b/naas_python/domains/storage/StorageSchema.py index f819346..a8aa86f 100644 --- a/naas_python/domains/storage/StorageSchema.py +++ b/naas_python/domains/storage/StorageSchema.py @@ -86,27 +86,27 @@ class IStorageDomain(metaclass=ABCMeta): #TODO to be validated @abstractmethod - def create_workspace_storage(self, + def create(self, workspace_id: str, storage_name: Storage.__fields__['name'], ) -> dict: raise NotImplementedError @abstractmethod - def delete_workspace_storage(self, + def delete(self, workspace_id: str, storage_name: Storage.__fields__['name'], ) -> dict: raise NotImplementedError @abstractmethod - def list_workspace_storage(self, + def list(self, workspace_id: str, ) -> dict: raise NotImplementedError @abstractmethod - def list_workspace_storage_object(self, + def list_objects(self, workspace_id: str, storage_name: Storage.__fields__['name'], storage_prefix: Object.__fields__['prefix'], @@ -114,7 +114,7 @@ def list_workspace_storage_object(self, raise NotImplementedError @abstractmethod - def delete_workspace_storage_object(self, + def delete_object(self, workspace_id: str, storage_name: Storage.__fields__['name'], object_name: Object.__fields__['name'], @@ -122,7 +122,7 @@ def delete_workspace_storage_object(self, raise NotImplementedError @abstractmethod - def post_workspace_storage_object(self, + def post_object(self, workspace_id: str, storage_name: Storage.__fields__['name'], src_file: str, @@ -131,7 +131,7 @@ def post_workspace_storage_object(self, raise NotImplementedError @abstractmethod - def get_workspace_storage_object(self, + def get_object(self, workspace_id: str, storage_name: Storage.__fields__['name'], src_file: str, @@ -141,7 +141,7 @@ def get_workspace_storage_object(self, @abstractmethod - def create_workspace_storage_credentials(self, + def create_credentials(self, workspace_id: str, storage_name: Storage.__fields__['name'], ) -> dict: @@ -213,4 +213,4 @@ class ServiceAuthenticationError(NaasException): class ServiceStatusError(NaasException): pass class ObjectAlreadyExists(NaasException): - pass \ No newline at end of file + pass