Skip to content

Commit

Permalink
fix: jans-cl update WebKeysConfiguration (#1211)
Browse files Browse the repository at this point in the history
* fix: jans-cl update WebKeysConfiguration

* fix: jans-cl put method
  • Loading branch information
devrimyatar committed Apr 18, 2022
1 parent d1e1ed6 commit 54847bc
Showing 1 changed file with 24 additions and 1 deletion.
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

0 comments on commit 54847bc

Please sign in to comment.