Skip to content

Commit 7eaeeae

Browse files
committed
support endpoints alongside endpoint
Signed-off-by: Matthias Gatto <[email protected]>
1 parent 0a41c4d commit 7eaeeae

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

osc_sdk/sdk.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ def patch_conf(conf: Configuration, endpoint: Optional[str] = None) -> Configura
721721
return conf
722722

723723

724-
def get_conf(profile: str) -> Configuration:
724+
def get_conf(profile: str, service: str) -> Configuration:
725725
# Check which conf_path is used.
726726
conf_path = next((path for path in CONF_PATHS if path.exists()), None)
727727

@@ -741,6 +741,29 @@ def get_conf(profile: str) -> Configuration:
741741
if not "https" in json_profile:
742742
json_profile["https"] = True
743743

744+
if "endpoints" in json_profile:
745+
if service == "api" and "api" in json_profile["endpoints"]:
746+
json_profile["endpoint"] = json_profile["endpoints"]["api"]
747+
del json_profile["endpoints"]
748+
elif (
749+
service == "directlink"
750+
and "directlink" in json_profile["endpoints"]
751+
):
752+
json_profile["endpoint"] = json_profile["endpoints"]["directlink"]
753+
del json_profile["endpoints"]
754+
elif service == "eim" and "eim" in json_profile["endpoints"]:
755+
json_profile["endpoint"] = json_profile["endpoints"]["eim"]
756+
del json_profile["endpoints"]
757+
elif service == "fcu" and "fcu" in json_profile["endpoints"]:
758+
json_profile["endpoint"] = json_profile["endpoints"]["fcu"]
759+
del json_profile["endpoints"]
760+
elif service == "lbu" and "lbu" in json_profile["endpoints"]:
761+
json_profile["endpoint"] = json_profile["endpoints"]["lbu"]
762+
del json_profile["endpoints"]
763+
elif service == "okms" and "okms" in json_profile["endpoints"]:
764+
json_profile["endpoint"] = json_profile["endpoints"]["okms"]
765+
del json_profile["endpoints"]
766+
744767
if not "region_name" in json_profile:
745768
json_profile["region_name"] = json_profile["region"]
746769
del json_profile["region"]
@@ -792,7 +815,7 @@ def api_connect(
792815
login,
793816
PASSWORD_ARG,
794817
authentication_method,
795-
**patch_conf(get_conf(profile), endpoint),
818+
**patch_conf(get_conf(profile, service), endpoint),
796819
)
797820

798821
handler.make_request(call, **kwargs)

0 commit comments

Comments
 (0)