Skip to content

Commit b0b1198

Browse files
authored
Merge pull request #49 from jupyter-naas/FlorentLvr-patch-1
fix: rename domain function assets and storage
2 parents 39d0ac9 + 581a8dd commit b0b1198

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

naas_python/domains/asset/AssetDomain.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ class AssetDomain(IAssetDomain):
1414
def __init__(self, adaptor: IAssetAdaptor):
1515
self.adaptor = adaptor
1616

17-
def create_asset(self, workspace_id:str, asset_creation:AssetCreation) -> Asset:
17+
def create(self, workspace_id:str, asset_creation:AssetCreation) -> Asset:
1818
asset = self.adaptor.create_asset(workspace_id, asset_creation)
1919
return asset
2020

21-
def get_asset(self, workspace_id:str, asset_id:str) -> Asset:
21+
def get(self, workspace_id:str, asset_id:str) -> Asset:
2222
asset = self.adaptor.get_asset(workspace_id, asset_id)
2323
return asset
2424

2525

26-
def update_asset(self, workspace_id:str, asset_id:str, asset_update: AssetUpdate) -> Asset:
26+
def update(self, workspace_id:str, asset_id:str, asset_update: AssetUpdate) -> Asset:
2727
response = self.adaptor.update_asset(workspace_id, asset_id, asset_update)
2828
return response
2929

30-
def delete_asset(self, workspace_id:str, asset_id:str) -> None:
30+
def delete(self, workspace_id:str, asset_id:str) -> None:
3131
self.adaptor.delete_asset(workspace_id, asset_id)
32-
return None
32+
return None

naas_python/domains/asset/AssetSchema.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ class IAssetDomain(metaclass=ABCMeta):
3434
adaptor: IAssetAdaptor
3535

3636
@abstractmethod
37-
def create_asset(self, workspace_id:str, asset_creation:AssetCreation) -> Asset:
37+
def create(self, workspace_id:str, asset_creation:AssetCreation) -> Asset:
3838
raise NotImplementedError()
3939

4040
@abstractmethod
41-
def get_asset(self, workspace_id:str, asset_id:str) -> Asset:
41+
def get(self, workspace_id:str, asset_id:str) -> Asset:
4242
raise NotImplementedError()
4343

4444
@abstractmethod
45-
def update_asset(self, workspace_id:str, asset_id:str, asset_update: AssetUpdate) -> Asset:
45+
def update(self, workspace_id:str, asset_id:str, asset_update: AssetUpdate) -> Asset:
4646
raise NotImplementedError()
4747

4848
@abstractmethod
49-
def delete_asset(self, workspace_id:str, asset_id:str) -> None:
49+
def delete(self, workspace_id:str, asset_id:str) -> None:
5050
raise NotImplementedError()
5151

5252
# Primary Adaptor
5353
class IAssetPrimaryAdaptor:
54-
pass
54+
pass

naas_python/domains/storage/StorageDomain.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, adaptor: IStorageAdaptor, storage_provider_adaptors : Mapping
1818
self.storage_provider_adaptors : Mapping[str, IStorageProviderAdaptor] = storage_provider_adaptors
1919

2020
############### API ###############
21-
def create_workspace_storage(self,
21+
def create(self,
2222
workspace_id: str,
2323
storage_name: Storage.__fields__['name'],
2424
) -> dict:
@@ -28,7 +28,7 @@ def create_workspace_storage(self,
2828
)
2929
return response
3030

31-
def delete_workspace_storage(self,
31+
def delete(self,
3232
workspace_id: str,
3333
storage_name: Storage.__fields__['name']
3434
) -> dict:
@@ -38,15 +38,15 @@ def delete_workspace_storage(self,
3838
)
3939
return response
4040

41-
def list_workspace_storage(self,
41+
def list(self,
4242
workspace_id: str,
4343
) -> dict:
4444
response = self.adaptor.list_workspace_storage(
4545
workspace_id=workspace_id,
4646
)
4747
return response
4848

49-
def list_workspace_storage_object(self,
49+
def list_objects(self,
5050
workspace_id: str,
5151
storage_name: Storage.__fields__['name'],
5252
storage_prefix: Object.__fields__['prefix'],
@@ -58,7 +58,7 @@ def list_workspace_storage_object(self,
5858
)
5959
return response
6060

61-
def delete_workspace_storage_object(self,
61+
def delete_object(self,
6262
workspace_id: str,
6363
storage_name: Storage.__fields__['name'],
6464
object_name: Object.__fields__['name'],
@@ -70,7 +70,7 @@ def delete_workspace_storage_object(self,
7070
)
7171
return response
7272

73-
def create_workspace_storage_credentials(self,
73+
def create_credentials(self,
7474
workspace_id: str,
7575
storage_name: Storage.__fields__['name'],
7676
) -> dict:
@@ -96,7 +96,7 @@ def __get_storage_provider_adaptor(self,
9696
return self.storage_provider_adaptors[storage_provider_id]
9797

9898

99-
def post_workspace_storage_object(self,
99+
def post_object(self,
100100
workspace_id: str,
101101
storage_name: Storage.__fields__['name'],
102102
src_file: str,
@@ -117,7 +117,7 @@ def post_workspace_storage_object(self,
117117
response = storage_provider.post_workspace_storage_object(workspace_id=workspace_id, storage_name=storage_name, src_file=src_file, dst_file=dst_file)
118118
return response
119119

120-
def get_workspace_storage_object(self,
120+
def get_object(self,
121121
workspace_id: str,
122122
storage_name: Storage.__fields__['name'],
123123
src_file: str,
@@ -136,4 +136,4 @@ def get_workspace_storage_object(self,
136136
storage_provider.save_naas_credentials(workspace_id, storage_name, credentials)
137137

138138
response = storage_provider.get_workspace_storage_object(workspace_id=workspace_id, storage_name=storage_name, src_file=src_file, dst_file=dst_file)
139-
return response
139+
return response

naas_python/domains/storage/StorageSchema.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -86,43 +86,43 @@ class IStorageDomain(metaclass=ABCMeta):
8686
#TODO to be validated
8787

8888
@abstractmethod
89-
def create_workspace_storage(self,
89+
def create(self,
9090
workspace_id: str,
9191
storage_name: Storage.__fields__['name'],
9292
) -> dict:
9393
raise NotImplementedError
9494

9595
@abstractmethod
96-
def delete_workspace_storage(self,
96+
def delete(self,
9797
workspace_id: str,
9898
storage_name: Storage.__fields__['name'],
9999
) -> dict:
100100
raise NotImplementedError
101101

102102
@abstractmethod
103-
def list_workspace_storage(self,
103+
def list(self,
104104
workspace_id: str,
105105
) -> dict:
106106
raise NotImplementedError
107107

108108
@abstractmethod
109-
def list_workspace_storage_object(self,
109+
def list_objects(self,
110110
workspace_id: str,
111111
storage_name: Storage.__fields__['name'],
112112
storage_prefix: Object.__fields__['prefix'],
113113
) -> dict:
114114
raise NotImplementedError
115115

116116
@abstractmethod
117-
def delete_workspace_storage_object(self,
117+
def delete_object(self,
118118
workspace_id: str,
119119
storage_name: Storage.__fields__['name'],
120120
object_name: Object.__fields__['name'],
121121
) -> dict:
122122
raise NotImplementedError
123123

124124
@abstractmethod
125-
def post_workspace_storage_object(self,
125+
def post_object(self,
126126
workspace_id: str,
127127
storage_name: Storage.__fields__['name'],
128128
src_file: str,
@@ -131,7 +131,7 @@ def post_workspace_storage_object(self,
131131
raise NotImplementedError
132132

133133
@abstractmethod
134-
def get_workspace_storage_object(self,
134+
def get_object(self,
135135
workspace_id: str,
136136
storage_name: Storage.__fields__['name'],
137137
src_file: str,
@@ -141,7 +141,7 @@ def get_workspace_storage_object(self,
141141

142142

143143
@abstractmethod
144-
def create_workspace_storage_credentials(self,
144+
def create_credentials(self,
145145
workspace_id: str,
146146
storage_name: Storage.__fields__['name'],
147147
) -> dict:
@@ -213,4 +213,4 @@ class ServiceAuthenticationError(NaasException):
213213
class ServiceStatusError(NaasException):
214214
pass
215215
class ObjectAlreadyExists(NaasException):
216-
pass
216+
pass

0 commit comments

Comments
 (0)