def main(): bi.init("Java", "java") schemas_map = bi.schemas_map(add_generics=True) for name, schema in schemas_map.items(): bi.vprint("Generating schema: " + name) bi.write_to_file("water/bindings/pojos/%s.java" % name, generate_schema(name, schema)) for name, values in bi.enums().items(): bi.vprint("Generating enum: " + name) bi.write_to_file("water/bindings/pojos/%s.java" % name, generate_enum(name, sorted(values))) for name, endpoints in bi.endpoint_groups().items(): if name != "SegmentModelsBuilders": bi.vprint("Generating proxy: " + name) bi.write_to_file("water/bindings/proxies/retrofit/%s.java" % name, generate_proxy(name, endpoints)) bi.vprint("Generating H2oApi.java") bi.write_to_file("water/bindings/H2oApi.java", generate_main_class(bi.endpoints())) type_adapter.vprint_translation_map()
def main(): bi.init("Thrift", "thrift") schemas_map = bi.schemas_map() ordered_schemas = OrderedDict() for name, schema in schemas_map.items(): add_schema_to_dependency_array(schema, ordered_schemas, schemas_map) bi.write_to_file("water/bindings/structs/H2O.thrift", generate_thrift(ordered_schemas)) type_adapter.vprint_translation_map()
def main(): bi.init("Java", "java") schemas_map = bi.schemas_map(add_generics=True) for name, schema in schemas_map.items(): bi.vprint("Generating schema: " + name) bi.write_to_file("water/bindings/pojos/%s.java" % name, generate_schema(name, schema)) for name, values in bi.enums().items(): bi.vprint("Generating enum: " + name) bi.write_to_file("water/bindings/pojos/%s.java" % name, generate_enum(name, sorted(values))) for name, endpoints in bi.endpoint_groups().items(): bi.vprint("Generating proxy: " + name) bi.write_to_file("water/bindings/proxies/retrofit/%s.java" % name, generate_proxy(name, endpoints)) bi.vprint("Generating H2oApi.java") bi.write_to_file("water/bindings/H2oApi.java", generate_main_class(bi.endpoints())) type_adapter.vprint_translation_map()
name = field["name"] if name in thrift_reserved_words: name += "_" required = "required" if field["required"] else "optional" yield bi.wrap(field["help"], indent=" # ") yield " {num}: {req} {type} {name},".format(num=i, req=required, type=thrift_type, name=name) yield "" yield "}" yield "" # ---------------------------------------------------------------------------------------------------------------------- # MAIN # ---------------------------------------------------------------------------------------------------------------------- if __name__ == "__main__": bi.init("Thrift", "thrift") type_adapter = ThriftTypeTranslator() schemas_map = bi.schemas_map() ordered_schemas = OrderedDict() for name, schema in schemas_map.items(): add_schema_to_dependency_array(schema, ordered_schemas, schemas_map) bi.write_to_file("water/bindings/structs/H2O.thrift", generate_thrift(ordered_schemas)) type_adapter.vprint_translation_map()
for i, field in enumerate(schema["fields"]): if field["name"] == "__meta": continue thrift_type = translate_type(field["type"], field["schema_name"]) name = field["name"] if name in thrift_reserved_words: name += "_" required = "required" if field["required"] else "optional" yield bi.wrap(field["help"], indent=" # ") yield " {num}: {req} {type} {name},".format(num=i, req=required, type=thrift_type, name=name) yield "" yield "}" yield "" # ---------------------------------------------------------------------------------------------------------------------- # MAIN # ---------------------------------------------------------------------------------------------------------------------- if __name__ == "__main__": bi.init("Thrift", "thrift") type_adapter = ThriftTypeTranslator() schemas_map = bi.schemas_map() ordered_schemas = OrderedDict() for name, schema in schemas_map.items(): add_schema_to_dependency_array(schema, ordered_schemas, schemas_map) bi.write_to_file("water/bindings/structs/H2O.thrift", generate_thrift(ordered_schemas)) type_adapter.vprint_translation_map()