Skip to content

Commit

Permalink
support endpoints alongside endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed May 3, 2024
1 parent 0a41c4d commit 7eaeeae
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions osc_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def patch_conf(conf: Configuration, endpoint: Optional[str] = None) -> Configura
return conf


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

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

if "endpoints" in json_profile:
if service == "api" and "api" in json_profile["endpoints"]:
json_profile["endpoint"] = json_profile["endpoints"]["api"]
del json_profile["endpoints"]
elif (
service == "directlink"
and "directlink" in json_profile["endpoints"]
):
json_profile["endpoint"] = json_profile["endpoints"]["directlink"]
del json_profile["endpoints"]
elif service == "eim" and "eim" in json_profile["endpoints"]:
json_profile["endpoint"] = json_profile["endpoints"]["eim"]
del json_profile["endpoints"]
elif service == "fcu" and "fcu" in json_profile["endpoints"]:
json_profile["endpoint"] = json_profile["endpoints"]["fcu"]
del json_profile["endpoints"]
elif service == "lbu" and "lbu" in json_profile["endpoints"]:
json_profile["endpoint"] = json_profile["endpoints"]["lbu"]
del json_profile["endpoints"]
elif service == "okms" and "okms" in json_profile["endpoints"]:
json_profile["endpoint"] = json_profile["endpoints"]["okms"]
del json_profile["endpoints"]

if not "region_name" in json_profile:
json_profile["region_name"] = json_profile["region"]
del json_profile["region"]
Expand Down Expand Up @@ -792,7 +815,7 @@ def api_connect(
login,
PASSWORD_ARG,
authentication_method,
**patch_conf(get_conf(profile), endpoint),
**patch_conf(get_conf(profile, service), endpoint),
)

handler.make_request(call, **kwargs)
Expand Down

0 comments on commit 7eaeeae

Please sign in to comment.