def get_all_services_urls(components_urls, verify): service_url_dict = {} for url in components_urls: services = utils.get_json(url, verify) for service in services: service_url_dict[service['href']] = service['name'] return service_url_dict
def process_service_urls(self, package_name, service_urls, output_dir, structure_dict, enum_dict, service_dict, service_url_dict, http_error_map, rest_navigation_url, enable_filtering, spec, gen_unique_op_id): print('processing package ' + package_name + os.linesep) type_dict = {} path_list = [] for service_url in service_urls: service_name, service_end_point = service_url_dict.get( service_url, None) service_info = service_dict.get(service_name, None) if service_info is None: continue if utils.is_filtered(service_info.metadata, enable_filtering): continue if self.contains_rm_annotation(service_info): for operation in service_info.operations.values(): url, method = self.find_url_method(operation) operation_id = operation.name op_metadata = service_info.operations[ operation_id].metadata if utils.is_filtered(op_metadata, enable_filtering): continue operation_info = service_info.operations.get(operation_id) if spec == '2': path = swagg.get_path(operation_info, method, url, service_name, type_dict, structure_dict, enum_dict, operation_id, http_error_map, enable_filtering) if spec == '3': path = openapi.get_path(operation_info, method, url, service_name, type_dict, structure_dict, enum_dict, operation_id, http_error_map, enable_filtering) path_list.append(path) continue # use rest navigation service to get the REST mappings for a # service. service_operations = utils.get_json( rest_navigation_url + service_url + '?~method=OPTIONS', False) if service_operations is None: continue for service_operation in service_operations: service_name = service_operation['service'] # service_info must be re-assigned when service_operations are obtained through ?~method=OPTIONS. # this is because all service operations matching the prefix of the service is returned instead of returning # only operations which has exact match. # for example OPTIONS on com.vmware.content.library returns operations from following services # instead of just com.vmware.content.library.item # com.vmware.content.library.item.storage # com.vmware.content.library.item # com.vmware.content.library.item.file # com.vmware.content.library.item.update_session # com.vmware.content.library.item.updatesession.file service_info = service_dict.get(service_name, None) if service_info is None: continue operation_id = service_operation['name'] if operation_id not in service_info.operations: continue op_metadata = service_info.operations[operation_id].metadata if utils.is_filtered(op_metadata, enable_filtering): continue url, method = self.find_url(service_operation['links']) url = self.get_service_path_from_service_url( url, rest_navigation_url) operation_info = service_info.operations.get(operation_id) if spec == '2': path = swagg.get_path(operation_info, method, url, service_name, type_dict, structure_dict, enum_dict, operation_id, http_error_map, enable_filtering) if spec == '3': path = openapi.get_path(operation_info, method, url, service_name, type_dict, structure_dict, enum_dict, operation_id, http_error_map, enable_filtering) path_list.append(path) path_dict = self.convert_path_list_to_path_map(path_list) self.cleanup(path_dict=path_dict, type_dict=type_dict) if spec == '2': rest_swagg_fpp.process_output(path_dict, type_dict, output_dir, package_name, gen_unique_op_id) if spec == '3': rest_openapi_fpp.process_output(path_dict, type_dict, output_dir, package_name, gen_unique_op_id)
def get_service_operations(self, service_url): return utils.get_json( self.rest_navigation_url + service_url + '?~method=OPTIONS', False)
def get_component_services_urls(cloudvm_url, verify): components_url = utils.get_json(cloudvm_url, verify)['components']['href'] components = utils.get_json(components_url, verify) return [component['services']['href'] for component in components]