diff --git a/jans-cli/cli/config_cli.py b/jans-cli/cli/config_cli.py index 7d210f49f8f..186f39e1acd 100644 --- a/jans-cli/cli/config_cli.py +++ b/jans-cli/cli/config_cli.py @@ -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: @@ -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: @@ -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) @@ -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}