Skip to content

Commit f81e677

Browse files
fix: change instance type endpoint (#174)
* change instance type endpoint * remove old url
1 parent 84af14b commit f81e677

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

src/firebolt/service/instance_type.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from firebolt.model.instance_type import InstanceType, InstanceTypeKey
44
from firebolt.model.region import Region
55
from firebolt.service.base import BaseService
6-
from firebolt.utils.urls import INSTANCE_TYPES_URL
6+
from firebolt.utils.urls import ACCOUNT_INSTANCE_TYPES_URL
77
from firebolt.utils.util import cached_property
88

99

@@ -19,7 +19,10 @@ class InstanceTypeService(BaseService):
1919
def instance_types(self) -> List[InstanceType]:
2020
"""List of instance types available on Firebolt."""
2121

22-
response = self.client.get(url=INSTANCE_TYPES_URL, params={"page.first": 5000})
22+
response = self.client.get(
23+
url=ACCOUNT_INSTANCE_TYPES_URL.format(account_id=self.account_id),
24+
params={"page.first": 5000},
25+
)
2326
return [InstanceType.parse_obj(i["node"]) for i in response.json()["edges"]]
2427

2528
@cached_property
@@ -46,7 +49,7 @@ def get_instance_types_per_region(self, region: Region) -> List[InstanceType]:
4649
"""List of instance types available on Firebolt in specified region."""
4750

4851
response = self.client.get(
49-
url=INSTANCE_TYPES_URL,
52+
url=ACCOUNT_INSTANCE_TYPES_URL.format(account_id=self.account_id),
5053
params={"page.first": 5000, "filter.id_region_id_eq": region.key.region_id},
5154
)
5255

src/firebolt/utils/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
ACCOUNT_BINDINGS_URL = "/core/v1/accounts/{account_id}/bindings"
2626

27+
ACCOUNT_INSTANCE_TYPES_URL = "/aws/v2/accounts/{account_id}/instanceTypes"
28+
2729
PROVIDERS_URL = "/compute/v1/providers"
2830
REGIONS_URL = "/compute/v1/regions"
29-
INSTANCE_TYPES_URL = "/compute/v1/instanceTypes"

tests/unit/service/conftest.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
ACCOUNT_DATABASES_URL,
2525
ACCOUNT_ENGINE_URL,
2626
ACCOUNT_ENGINES_URL,
27-
INSTANCE_TYPES_URL,
27+
ACCOUNT_INSTANCE_TYPES_URL,
2828
PROVIDERS_URL,
2929
REGIONS_URL,
3030
)
@@ -214,23 +214,33 @@ def do_mock(
214214

215215

216216
@pytest.fixture
217-
def instance_type_url(settings: Settings) -> str:
218-
return f"https://{settings.server}{INSTANCE_TYPES_URL}?page.first=5000"
217+
def instance_type_url(settings: Settings, account_id: str) -> str:
218+
return (
219+
f"https://{settings.server}"
220+
+ ACCOUNT_INSTANCE_TYPES_URL.format(account_id=account_id)
221+
+ "?page.first=5000"
222+
)
219223

220224

221225
@pytest.fixture
222-
def instance_type_region_1_url(settings: Settings, region_1: Region) -> str:
226+
def instance_type_region_1_url(
227+
settings: Settings, region_1: Region, account_id: str
228+
) -> str:
223229
return (
224-
f"https://{settings.server}{INSTANCE_TYPES_URL}?page.first=5000&"
225-
f"filter.id_region_id_eq={region_1.key.region_id}"
230+
f"https://{settings.server}"
231+
+ ACCOUNT_INSTANCE_TYPES_URL.format(account_id=account_id)
232+
+ f"?page.first=5000&filter.id_region_id_eq={region_1.key.region_id}"
226233
)
227234

228235

229236
@pytest.fixture
230-
def instance_type_region_2_url(settings: Settings, region_2: Region) -> str:
237+
def instance_type_region_2_url(
238+
settings: Settings, region_2: Region, account_id: str
239+
) -> str:
231240
return (
232-
f"https://{settings.server}{INSTANCE_TYPES_URL}?page.first=5000&"
233-
f"filter.id_region_id_eq={region_2.key.region_id}"
241+
f"https://{settings.server}"
242+
+ ACCOUNT_INSTANCE_TYPES_URL.format(account_id=account_id)
243+
+ f"?page.first=5000&filter.id_region_id_eq={region_2.key.region_id}"
234244
)
235245

236246

0 commit comments

Comments
 (0)