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

fix: jans-cl update WebKeysConfiguration #1211

Merged
merged 2 commits into from
Apr 18, 2022
Merged
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
25 changes: 24 additions & 1 deletion jans-cli/cli/config_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,8 @@ def process_put(self, endpoint):
initialised = False
cur_model = None
go_back = False
key_name = None
parent_model = None

if endpoint.info.get('x-cli-getdata') != '_file':
if 'x-cli-getdata' in endpoint.info and endpoint.info['x-cli-getdata'] != None:
Expand All @@ -1415,6 +1417,9 @@ def process_put(self, endpoint):
while True:
while True:
try:
key_name_desc = self.get_endpiont_url_param(m)
if key_name_desc and 'name' in key_name_desc:
key_name = key_name_desc['name']
cur_model = self.process_get(m, return_value=True)
break
except ValueError as e:
Expand Down Expand Up @@ -1519,6 +1524,9 @@ def print_fields():
elif selection in item_numbers:
item = attr_name_list[int(selection) - 1]
item_unmapped = self.get_model_key_map(cur_model, item)
if schema['properties'].get('keys', {}).get('properties'):
schema = schema['properties']['keys']

schema_item = schema['properties'][item]
schema_item['__name__'] = item
self.get_input_for_schema_(schema, cur_model, initialised=initialised, getitem=schema_item)
Expand All @@ -1537,10 +1545,25 @@ def print_fields():
selection = self.get_input(values=['y', 'n'], text='Continue?')

if selection == 'y':
schema_must = self.get_scheme_for_endpoint(endpoint)
if schema_must['__schema_name__'] != cur_model.__class__.__name__:
for e in endpoint.parent.children:
if e.method == 'get':
parent_model = self.process_get(e, return_value=True)
break


if parent_model and key_name and hasattr(parent_model, 'keys'):
for i, wkey in enumerate(parent_model.keys):
if getattr(wkey, key_name) == getattr(cur_model, key_name):
parent_model.keys[i] = cur_model
cur_model = parent_model
break

print("Please wait while posting data ...\n")
api_caller = self.get_api_caller(endpoint)
put_pname = self.get_url_param(endpoint.path)

try:
if put_pname:
args_ = {'body': cur_model, put_pname: end_point_param_val}
Expand Down