Skip to content

Commit

Permalink
Align return value of get_mapping_by_name to match other getters of t…
Browse files Browse the repository at this point in the history
…he API
  • Loading branch information
lenggi committed Apr 9, 2024
1 parent f98f2ab commit b9cba3e
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -511,17 +511,16 @@ def get_mapping_by_id(gw_session: GatewaySession, mapping_id: str) -> dict:
def get_mapping_by_name(gw_session: GatewaySession, name: str) -> dict:
'''
Returns a dictionary object representing the mapping
with the given `name` or an empty dictionary if no
such mapping was found.
with the given `name` or None if no such mapping was found.
'''
path = f'/configuration/mappings?filter=name=={name}'
res = get(gw_session, path, exp_code=200)

candidate_list = res.json().get('data')
if len(candidate_list) == 1:
return candidate_list[0]
else:
return {}

return None


def get_all_mapping_names(gw_session: GatewaySession) -> list:
Expand Down Expand Up @@ -1021,7 +1020,7 @@ def import_config(gw_session: GatewaySession, cfg_zip: str):
with open(cfg_zip, 'rb') as file:
cfg_host_name = _get_hostname_from_config_zip(cfg_zip)
load_empty_config(gw_session, cfg_host_name)
path = "/configuration/configurations/import/"
path = "/configuration/configurations/import"
req_raw(gw_session, "PUT", path, "application/zip", file, 200)


Expand Down

0 comments on commit b9cba3e

Please sign in to comment.