Skip to content

Commit a781388

Browse files
committed
Added support for checking availability for a spot instance
1 parent 123dde7 commit a781388

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Changelog
22
=========
33

4+
* Added support for checking availability for a spot instance
5+
46
v1.0.10 (2022-10-18)
57
-------------------
68

datacrunch/instances/instances.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def create(self,
375375
:param is_spot: Is spot instance
376376
:type is_spot: bool, optional
377377
:param coupon: coupon code
378-
:type is_spot: str, optional
378+
:type coupon: str, optional
379379
:return: the new instance object
380380
:rtype: id
381381
"""
@@ -418,13 +418,16 @@ def action(self, id_list: Union[List[str], str], action: str, volume_ids: Option
418418
self._http_client.put(INSTANCES_ENDPOINT, json=payload)
419419
return
420420

421-
def is_available(self, instance_type: str) -> bool:
421+
def is_available(self, instance_type: str, is_spot: bool = None) -> bool:
422422
"""Returns True if a specific instance type is now available for deployment
423423
424424
:param instance_type: instance type
425425
:type instance_type: str
426+
:param is_spot: Is spot instance
427+
:type is_spot: bool, optional
426428
:return: True if available to deploy, False otherwise
427429
:rtype: bool
428430
"""
429-
url = f'/instance-availability/{instance_type}'
431+
query_param = 'true' if is_spot else 'false'
432+
url = f'/instance-availability/{instance_type}?isSpot={query_param}'
430433
return self._http_client.get(url).json()

0 commit comments

Comments
 (0)