template for generating protobuf spec of existing XOS data model

Change-Id: Ice0b9962eb3407ce21ff060d9a56f374d1449d66
diff --git a/xos/tools/apigen/modelgen b/xos/tools/apigen/modelgen
index e5e4232..a34798f 100755
--- a/xos/tools/apigen/modelgen
+++ b/xos/tools/apigen/modelgen
@@ -77,6 +77,7 @@
 		self.model = m
 		self.props = []
 		self.fields = []
+                self.all_fields = []
 		self.field_dict = []
 		self.refs = []
 		self.plural_name = None
@@ -184,7 +185,8 @@
                                         if (type(f)==ForeignKey):
                                             f.related.model.class_name = f.related.model.__name__
                                         if (f.name not in base_props):
-                                            obj.fields.append(f) 
+                                            obj.fields.append(f)
+                                        obj.all_fields.append(f)
                                         obj.props.append(f.name)
 
 			m2m = obj.model._meta.many_to_many
diff --git a/xos/tools/apigen/protobuf.template.txt b/xos/tools/apigen/protobuf.template.txt
new file mode 100644
index 0000000..ca77283
--- /dev/null
+++ b/xos/tools/apigen/protobuf.template.txt
@@ -0,0 +1,34 @@
+syntax = "proto3";
+
+package xos;
+
+{% for object in generator.all() %}
+
+message {{ object.camel() }} {
+  {%- for field in object.all_fields -%}
+    {%- if (field.get_internal_type() == "CharField") or (field.get_internal_type() == "TextField") or (field.get_internal_type() == "SlugField") %}
+      string {{ field.name }} = {{ loop.index }};
+    {%- elif field.get_internal_type() == "BooleanField" %}
+      bool {{ field.name }} = {{ loop.index }};
+    {%- elif field.get_internal_type() == "ForeignKey" %}
+      int32 {{ field.name }}_id = {{ loop.index }};
+    {%- elif field.get_internal_type() == "DateTimeField" %}
+      int32 {{ field.name }} = {{ loop.index }};
+    {%- elif field.get_internal_type() == "AutoField" %}
+      int32 {{ field.name }} = {{ loop.index }};
+    {%- elif field.get_internal_type() == "IntegerField" %}
+      int32 {{ field.name }} = {{ loop.index }};
+    {%- elif field.get_internal_type() == "PositiveIntegerField" %}
+      uint32 {{ field.name }} = {{ loop.index }};
+    {%- elif field.get_internal_type() == "FloatField" %}
+      float {{ field.name }} = {{ loop.index }};
+    {%- elif field.get_internal_type() == "GenericIPAddressField" %}
+      string {{ field.name }} = {{ loop.index }};
+    {%- else %}
+      UNKNOWN {{ field.get_internal_type() }} {{ field.name }} = {{ loop.index }};
+    {%- endif %}
+  {%- endfor %}
+}
+
+{% endfor %}
+