@@ -58,26 +58,6 @@ def __init__(self,
5858 self ._instance_id = instance_id
5959 self ._ssh_key_ids = ssh_key_ids
6060
61- # overloading of the init method, initializing the Volume from a dictionary
62- def __init__ (self , volume_dict ) -> None :
63- """Initialize the volume object from a dictionary
64-
65- :param volume_dict: volume dictionary
66- :type volume_dict: dict
67- """
68- self ._id = volume_dict ['id' ]
69- self ._status = volume_dict ['status' ]
70- self ._name = volume_dict ['name' ]
71- self ._size = volume_dict ['size' ]
72- self ._type = volume_dict ['type' ]
73- self ._is_os_volume = volume_dict ['is_os_volume' ]
74- self ._created_at = volume_dict ['created_at' ]
75- self ._target = volume_dict ['target' ] if 'target' in volume_dict else None
76- self ._location = volume_dict ['location' ]
77- self ._instance_id = volume_dict ['instance_id' ] if 'instance_id' in volume_dict else None
78- self ._ssh_key_ids = volume_dict ['ssh_key_ids' ] if 'ssh_key_ids' in volume_dict else [
79- ]
80-
8161 @property
8262 def id (self ) -> str :
8363 """Get the volume id
@@ -202,8 +182,20 @@ def get(self, status: str = None) -> List[Volume]:
202182 """
203183 volumes_dict = self ._http_client .get (
204184 VOLUMES_ENDPOINT , params = {'status' : status }).json ()
205- volumes = list (
206- map (lambda volume_dict : Volume (volume_dict ), volumes_dict ))
185+ volumes = list (map (lambda volume_dict : Volume (
186+ id = volume_dict ['id' ],
187+ status = volume_dict ['status' ],
188+ name = volume_dict ['name' ],
189+ size = volume_dict ['size' ],
190+ type = volume_dict ['type' ],
191+ is_os_volume = volume_dict ['is_os_volume' ],
192+ created_at = volume_dict ['created_at' ],
193+ target = volume_dict ['target' ] if 'target' in volume_dict else None ,
194+ location = volume_dict ['location' ],
195+ instance_id = volume_dict ['instance_id' ] if 'instance_id' in volume_dict else None ,
196+ ssh_key_ids = volume_dict ['ssh_key_ids' ] if 'ssh_key_ids' in volume_dict else [
197+ ],
198+ ), volumes_dict ))
207199 return volumes
208200
209201 def get_by_id (self , id : str ) -> Volume :
@@ -216,7 +208,21 @@ def get_by_id(self, id: str) -> Volume:
216208 """
217209 volume_dict = self ._http_client .get (
218210 VOLUMES_ENDPOINT + f'/{ id } ' ).json ()
219- return Volume (volume_dict )
211+ volume = Volume (
212+ id = volume_dict ['id' ],
213+ status = volume_dict ['status' ],
214+ name = volume_dict ['name' ],
215+ size = volume_dict ['size' ],
216+ type = volume_dict ['type' ],
217+ is_os_volume = volume_dict ['is_os_volume' ],
218+ created_at = volume_dict ['created_at' ],
219+ target = volume_dict ['target' ] if 'target' in volume_dict else None ,
220+ location = volume_dict ['location' ],
221+ instance_id = volume_dict ['instance_id' ] if 'instance_id' in volume_dict else None ,
222+ ssh_key_ids = volume_dict ['ssh_key_ids' ] if 'ssh_key_ids' in volume_dict else [
223+ ],
224+ )
225+ return volume
220226
221227 def create (self ,
222228 type : str ,
0 commit comments