11from typing import List , Union , Optional , Dict
22from datacrunch .helpers import stringify_class_object_properties
3+ from datacrunch .constants import Locations
34
45INSTANCES_ENDPOINT = '/instances'
56
@@ -24,7 +25,7 @@ def __init__(self,
2425 storage : dict ,
2526 os_volume_id : str ,
2627 gpu_memory : dict ,
27- location : str = "FIN1" ,
28+ location : str = Locations . FIN_01 ,
2829 startup_script_id : str = None ,
2930 is_spot : bool = False
3031 ) -> None :
@@ -62,7 +63,7 @@ def __init__(self,
6263 :type id: str
6364 :param memory: gpu memory details
6465 :type memory: dict
65- :param location: datacenter location, defaults to "FIN1 "
66+ :param location: datacenter location, defaults to "FIN-01 "
6667 :type location: str, optional
6768 :param startup_script_id: startup script id, defaults to None
6869 :type startup_script_id: str, optional
@@ -268,6 +269,7 @@ def __str__(self) -> str:
268269 """
269270 return stringify_class_object_properties (self )
270271
272+
271273class InstancesService :
272274 """A service for interacting with the instances endpoint"""
273275
@@ -295,7 +297,8 @@ def get(self, status: str = None) -> List[Instance]:
295297 ip = instance_dict ['ip' ],
296298 status = instance_dict ['status' ],
297299 created_at = instance_dict ['created_at' ],
298- ssh_key_ids = instance_dict ['ssh_key_ids' ] if 'ssh_key_ids' in instance_dict else [],
300+ ssh_key_ids = instance_dict ['ssh_key_ids' ] if 'ssh_key_ids' in instance_dict else [
301+ ],
299302 startup_script_id = instance_dict ['startup_script_id' ] if 'startup_script_id' in instance_dict else None ,
300303 cpu = instance_dict ['cpu' ],
301304 gpu = instance_dict ['gpu' ],
@@ -328,7 +331,8 @@ def get_by_id(self, id: str) -> Instance:
328331 ip = instance_dict ['ip' ],
329332 status = instance_dict ['status' ],
330333 created_at = instance_dict ['created_at' ],
331- ssh_key_ids = instance_dict ['ssh_key_ids' ] if 'ssh_key_ids' in instance_dict else [],
334+ ssh_key_ids = instance_dict ['ssh_key_ids' ] if 'ssh_key_ids' in instance_dict else [
335+ ],
332336 startup_script_id = instance_dict ['startup_script_id' ] if 'startup_script_id' in instance_dict else None ,
333337 cpu = instance_dict ['cpu' ],
334338 gpu = instance_dict ['gpu' ],
@@ -346,7 +350,7 @@ def create(self,
346350 hostname : str ,
347351 description : str ,
348352 ssh_key_ids : list = [],
349- location : str = "FIN1" ,
353+ location : str = Locations . FIN_01 ,
350354 startup_script_id : str = None ,
351355 volumes : List [Dict ] = None ,
352356 existing_volumes : List [str ] = None ,
@@ -365,7 +369,7 @@ def create(self,
365369 :type hostname: str
366370 :param description: instance description
367371 :type description: str
368- :param location: datacenter location, defaults to "FIN1 "
372+ :param location: datacenter location, defaults to "FIN-01 "
369373 :type location: str, optional
370374 :param startup_script_id: startup script id, defaults to None
371375 :type startup_script_id: str, optional
@@ -389,7 +393,7 @@ def create(self,
389393 "startup_script_id" : startup_script_id ,
390394 "hostname" : hostname ,
391395 "description" : description ,
392- "location " : location ,
396+ "location_code " : location ,
393397 "os_volume" : os_volume ,
394398 "volumes" : volumes ,
395399 "existing_volumes" : existing_volumes ,
0 commit comments