Skip to content

Commit 5bafba0

Browse files
author
Anatoli Kurtsevich
authored
RAI-12688 - Removing EngineSize enumeration to give more flexibility on engine specification (#125)
* removing EngineSize enumeration to give more flexibility on engine specification * updated CHANGELOG
1 parent 2623767 commit 5bafba0

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.6.12
4+
5+
* `create_engine` and `create_engine_wait` accept engine size as a string (e.g. "XS", "M", etc).
6+
37
## v0.6.11
48

59
* Log warnings if failed to read or write to the local access token cache.

examples/create_engine.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
import json
1919
from urllib.request import HTTPError
2020
from railib import api, config, show
21-
from railib.api import EngineSize
2221

2322

2423
def run(engine: str, size: str, profile: str):
2524
cfg = config.read(profile=profile)
2625
ctx = api.Context(**cfg)
27-
api.create_engine_wait(ctx, engine, EngineSize(size))
26+
api.create_engine(ctx, engine, size)
2827
print(json.dumps(api.get_engine(ctx, engine), indent=2))
2928

3029

railib/api.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@
3939
logger = logging.getLogger(__package__)
4040

4141

42-
# Engine sizes
43-
@unique
44-
class EngineSize(str, Enum):
45-
XS = "XS"
46-
S = "S"
47-
M = "M"
48-
L = "L"
49-
XL = "XL"
50-
51-
5242
# Database modes
5343
@unique
5444
class Mode(str, Enum):
@@ -113,7 +103,6 @@ class Permission(str, Enum):
113103

114104
__all__ = [
115105
"Context",
116-
"EngineSize",
117106
"Mode",
118107
"Role",
119108
"Permission",
@@ -371,14 +360,14 @@ def is_engine_term_state(state: str) -> bool:
371360
return state == "PROVISIONED" or ("FAILED" in state)
372361

373362

374-
def create_engine(ctx: Context, engine: str, size: EngineSize = EngineSize.XS, **kwargs):
375-
data = {"region": ctx.region, "name": engine, "size": size.value}
363+
def create_engine(ctx: Context, engine: str, size: str = "XS", **kwargs):
364+
data = {"region": ctx.region, "name": engine, "size": size}
376365
url = _mkurl(ctx, PATH_ENGINE)
377366
rsp = rest.put(ctx, url, data, **kwargs)
378367
return json.loads(rsp.read())
379368

380369

381-
def create_engine_wait(ctx: Context, engine: str, size: EngineSize = EngineSize.XS, **kwargs):
370+
def create_engine_wait(ctx: Context, engine: str, size: str = "XS", **kwargs):
382371
create_engine(ctx, engine, size, **kwargs)
383372
poll_with_specified_overhead(
384373
lambda: is_engine_term_state(get_engine(ctx, engine)["state"]),

0 commit comments

Comments
 (0)