Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support endpoints alongside endpoint #298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading