def do_generateapis_from_apispecfile(self, args): api_spec_file = "/etc/cloud/cli/commands.xml" cs_api_folder = "." if args: inp = args.strip().split(' ') for items in inp: (key, value) = items.split('=') if key.lower() == 'api-spec-file': if os.path.exists(value): api_spec_file = value elif not os.path.exists(api_spec_file): print "=== Mentioned api spec file :%s does not exists ===" % str( api_spec_file) sys.exit(1) if key.lower() == 'cs-folder-path': cs_api_folder = self.create_marvin_api_folder(value) cg = CodeGenerator(cs_api_folder) if api_spec_file: try: cg.generateCodeFromXML(api_spec_file) return SUCCESS except Exception as e: print "==== Generating apis from api spec file failed: %s ====" % str( e.message()) return FAILED return FAILED
def do_generateapis_from_endpoint(self, args): endpoint_url = 'http://%s:8096/client/api?command=listApis&\ response=json' cs_api_folder = "." if args: inp = args.strip().split(' ') for items in inp: (key, value) = items.split('=') if key.lower() == 'endpoint': cs_end_point = value if key.lower() == 'cs-folder-path': cs_api_folder = self.create_marvin_api_folder(value) cg = CodeGenerator(cs_api_folder) if cs_end_point: try: endpoint_url = endpoint_url % str(cs_end_point) cg.generateCodeFromJSON(endpoint_url) return SUCCESS except Exception as e: print "==== Generating apis from end point failed: %s ====" % str(e.message()) return FAILED return FAILED
def do_generateapis_from_apispecfile(self, args): api_spec_file = "/etc/cloud/cli/commands.xml" cs_api_folder = "." if args: inp = args.strip().split(' ') for items in inp: (key, value) = items.split('=') if key.lower() == 'api-spec-file': if os.path.exists(value): api_spec_file = value elif not os.path.exists(api_spec_file): print "=== Mentioned api spec file :%s does not exists ===" % str(api_spec_file) sys.exit(1) if key.lower() == 'cs-folder-path': cs_api_folder = self.create_marvin_api_folder(value) cg = CodeGenerator(cs_api_folder) if api_spec_file: try: cg.generateCodeFromXML(api_spec_file) return SUCCESS except Exception as e: print "==== Generating apis from api spec file failed: %s ====" % str(e.message()) return FAILED return FAILED