CORD-1097: Generate API from xproto
Change-Id: I13b956401eae58af874bdd2b9ba6a5ffa6919376
diff --git a/xos/core/models/core.xproto b/xos/core/models/core.xproto
index c460261..25aa6a2 100644
--- a/xos/core/models/core.xproto
+++ b/xos/core/models/core.xproto
@@ -1,15 +1,16 @@
-option app_name = "core";
+option app_label = "core";
message XOSBase {
option skip_init = True;
+
required string created = 1 [content_type = "date", auto_now_add = True];
required string updated = 2 [default = "now()", content_type = "date"];
optional string enacted = 3 [null = True, content_type = "date", blank = True, default = None];
optional string policed = 4 [null = True, content_type = "date", blank = True, default = None];
- optional string backend_register = 5 [default = "{}", max_length = 1024, null = True];
+ optional string backend_register = 5 [default = "{}", max_length = 1024];
required bool backend_need_delete = 6 [default = False];
required bool backend_need_reap = 7 [default = False];
- required string backend_status = 8 [default = "0 - Provisioning in progress", max_length = 1024];
+ required string backend_status = 8 [default = "0 - Provisioning in progress", max_length = 1024, null = True];
required bool deleted = 9 [default = False];
required bool write_protect = 10 [default = False];
required bool lazy_blocked = 11 [default = False];
@@ -20,36 +21,38 @@
message User (AbstractBaseUser,PlModelMixIn) {
option skip_django = True;
+
required string email = 1 [db_index = True, max_length = 255, null = False, blank = False];
required string username = 2 [default = "Something", max_length = 255, content_type = "stripped", blank = False, null = False, db_index = False];
- required string firstname = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's given name", null = False, db_index = False];
- required string lastname = 4 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's surname", null = False, db_index = False];
- optional string phone = 5 [max_length = 100, content_type = "stripped", blank = True, help_text = "phone number contact", null = True, db_index = False];
- optional string user_url = 6 [db_index = False, max_length = 200, null = True, content_type = "url", blank = True];
- required manytoone site->Site:users = 7 [help_text = "Site this user will be homed too", null = False, db_index = True, blank = False];
- optional string public_key = 8 [help_text = "Public key string", max_length = 1024, null = True, db_index = False, blank = True, varchar = True];
- required bool is_active = 9 [default = True, null = False, db_index = False, blank = True];
- required bool is_admin = 10 [default = False, null = False, db_index = False, blank = True];
- required bool is_staff = 11 [default = True, null = False, db_index = False, blank = True];
- required bool is_readonly = 12 [default = False, null = False, db_index = False, blank = True];
- required bool is_registering = 13 [default = False, null = False, db_index = False, blank = True];
- required bool is_appuser = 14 [default = False, null = False, db_index = False, blank = True];
- optional string login_page = 15 [max_length = 200, content_type = "stripped", blank = True, help_text = "send this user to a specific page on login", null = True, db_index = False];
- required string created = 16 [db_index = False, null = False, content_type = "date", blank = True];
- required string updated = 17 [db_index = False, null = False, content_type = "date", blank = True];
- optional string enacted = 18 [db_index = False, null = True, content_type = "date", blank = False];
- optional string policed = 19 [db_index = False, null = True, content_type = "date", blank = False];
- required string backend_status = 20 [default = "Provisioning in progress", max_length = 1024, content_type = "stripped", blank = False, null = False, db_index = False];
- required bool backend_need_delete = 21 [default = False, null = False, db_index = False, blank = True];
- required bool backend_need_reap = 22 [default = False, null = False, db_index = False, blank = True];
- required bool deleted = 23 [default = False, null = False, db_index = False, blank = True];
- required bool write_protect = 24 [default = False, null = False, db_index = False, blank = True];
- required bool lazy_blocked = 25 [default = False, null = False, db_index = False, blank = True];
- required bool no_sync = 26 [default = False, null = False, db_index = False, blank = True];
- required bool no_policy = 27 [default = False, null = False, db_index = False, blank = True];
- required string timezone = 28 [default = "America/New_York", max_length = 100, blank = False, null = False, db_index = False];
- required manytomany dashboards->DashboardView/UserDashboardView:user = 29 [db_index = False, null = False, blank = True];
-}
+ required string password = 3 [default = "Something", max_length = 255, blank = False, null = False, db_index = False];
+ required string firstname = 4 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's given name", null = False, db_index = False];
+ required string lastname = 5 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's surname", null = False, db_index = False];
+ optional string phone = 6 [max_length = 100, content_type = "stripped", blank = True, help_text = "phone number contact", null = True, db_index = False];
+ optional string user_url = 7 [db_index = False, max_length = 200, null = True, content_type = "url", blank = True];
+ required manytoone site->Site:users = 8 [help_text = "Site this user will be homed too", null = False, db_index = True, blank = False];
+ optional string public_key = 9 [help_text = "Public key string", max_length = 1024, null = True, db_index = False, blank = True, varchar = True];
+ required bool is_active = 10 [default = True, null = False, db_index = False, blank = True];
+ required bool is_admin = 11 [default = False, null = False, db_index = False, blank = True];
+ required bool is_staff = 12 [default = True, null = False, db_index = False, blank = True];
+ required bool is_readonly = 13 [default = False, null = False, db_index = False, blank = True];
+ required bool is_registering = 14 [default = False, null = False, db_index = False, blank = True];
+ required bool is_appuser = 15 [default = False, null = False, db_index = False, blank = True];
+ optional string login_page = 16 [max_length = 200, content_type = "stripped", blank = True, help_text = "send this user to a specific page on login", null = True, db_index = False];
+ required string created = 17 [db_index = False, null = False, content_type = "date", blank = True];
+ required string updated = 18 [db_index = False, null = False, content_type = "date", blank = True];
+ optional string enacted = 19 [db_index = False, null = True, content_type = "date", blank = False];
+ optional string policed = 20 [db_index = False, null = True, content_type = "date", blank = False];
+ required string backend_status = 21 [default = "Provisioning in progress", max_length = 1024, content_type = "stripped", blank = False, null = False, db_index = False];
+ required bool backend_need_delete = 22 [default = False, null = False, db_index = False, blank = True];
+ required bool backend_need_reap = 23 [default = False, null = False, db_index = False, blank = True];
+ required bool deleted = 24 [default = False, null = False, db_index = False, blank = True];
+ required bool write_protect = 25 [default = False, null = False, db_index = False, blank = True];
+ required bool lazy_blocked = 26 [default = False, null = False, db_index = False, blank = True];
+ required bool no_sync = 27 [default = False, null = False, db_index = False, blank = True];
+ required bool no_policy = 28 [default = False, null = False, db_index = False, blank = True];
+ required string timezone = 29 [default = "America/New_York", max_length = 100, blank = False, null = False, db_index = False];
+ required manytomany dashboards->DashboardView/UserDashboardView:user = 30 [db_index = False, null = False, blank = True];
+}
message AddressPool (XOSBase) {
required string name = 1 [db_index = False, max_length = 32, null = False, blank = False];
@@ -81,7 +84,7 @@
message ControllerDashboardView (XOSBase) {
required manytoone controller->Controller:controllerdashboardviews = 1 [db_index = True, null = False, blank = False];
required manytoone dashboardView->DashboardView:controllerdashboardviews = 2 [db_index = True, null = False, blank = False];
- required bool enabled = 3 [default = True, null = False, db_index = False, blank = True];
+ required bool enabled = 3 [default = True, db_index = False, blank = True];
required string url = 4 [max_length = 1024, content_type = "stripped", blank = False, help_text = "URL of Dashboard", null = False, db_index = False];
}
@@ -150,7 +153,7 @@
message DashboardView (XOSBase) {
required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name of the View", null = False, db_index = False];
required string url = 2 [max_length = 1024, content_type = "stripped", blank = False, help_text = "URL of Dashboard", null = False, db_index = False];
- required bool enabled = 3 [default = True, null = False, db_index = False, blank = True];
+ required bool enabled = 3 [default = True, db_index = False, blank = True];
required string icon = 4 [default = "default-icon.png", max_length = 200, blank = False, help_text = "Icon for Dashboard", null = False, db_index = False];
required string icon_active = 5 [default = "default-icon-active.png", max_length = 200, blank = False, help_text = "Icon for active Dashboard", null = False, db_index = False];
required manytomany controllers->Controller/ControllerDashboardView:dashboardviews = 6 [db_index = False, null = False, blank = True];
@@ -375,7 +378,9 @@
message SiteRole (XOSBase) {
required string role = 1 [choices = "(('admin', 'Admin'), ('pi', 'PI'), ('tech', 'Tech'), ('billing', 'Billing'))", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False];
}
+
message Slice (XOSBase) {
+ option plural = "Slices";
required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False];
required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True];
required string description = 4 [help_text = "High level description of the slice and expected activities", max_length = 1024, null = False, db_index = False, blank = True, varchar = True];
@@ -414,7 +419,6 @@
required uint32 object_id = 5 [db_index = False, null = False, blank = False, help_text = "Object linked to this tag"];
}
-
message Tenant (XOSBase,AttributeMixin) {
optional string name = 1 [db_index = False, max_length = 200, null = True, content_type = "stripped", blank = True];
required string kind = 2 [default = "generic", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False];
@@ -429,26 +433,22 @@
required string connect_method = 11 [default = "na", choices = "(('public', 'Public'), ('private', 'Private'), ('private-unidirectional', 'Private Unidirectional'), ('na', 'Not Applicable'))", max_length = 30, blank = False, null = False, db_index = False];
}
-
message TenantAttribute (XOSBase) {
required string name = 1 [help_text = "Attribute Name", max_length = 128, null = False, db_index = False, blank = False];
required string value = 2 [help_text = "Attribute Value", null = False, db_index = False, blank = False];
required manytoone tenant->Tenant:tenantattributes = 3 [help_text = "The Tenant this attribute is associated with", null = False, db_index = True, blank = False];
}
-
message TenantPrivilege (XOSBase) {
required manytoone user->User:tenantprivileges = 1 [db_index = True, null = False, blank = False];
required manytoone tenant->Tenant:tenantprivileges = 2 [db_index = True, null = False, blank = False];
required manytoone role->TenantRole:tenantprivileges = 3 [db_index = True, null = False, blank = False];
}
-
message TenantRole (XOSBase) {
required string role = 1 [choices = "(('admin', 'Admin'), ('access', 'Access'))", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False];
}
-
message TenantRoot (XOSBase,AttributeMixin) {
required string kind = 1 [default = "generic", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False];
optional string name = 2 [max_length = 255, content_type = "stripped", blank = True, help_text = "name", null = True, db_index = False];
@@ -456,19 +456,16 @@
optional string service_specific_id = 4 [db_index = False, max_length = 30, null = True, content_type = "stripped", blank = True];
}
-
message TenantRootPrivilege (XOSBase) {
required manytoone user->User:tenant_root_privileges = 1 [db_index = True, null = False, blank = False, unique_with = "tenant_root"];
required manytoone tenant_root->TenantRoot:tenant_root_privileges = 2 [db_index = True, null = False, blank = False, unique_with = "role"];
required manytoone role->TenantRootRole:tenant_root_privileges = 3 [db_index = True, null = False, blank = False];
}
-
message TenantRootRole (XOSBase) {
required string role = 1 [choices = "(('admin', 'Admin'), ('access', 'Access'))", max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False];
}
-
message TenantWithContainer (Tenant) {
optional manytoone instance->Instance:+ = 1 [help_text = "Instance used by this Tenant", null = True, db_index = True, blank = True];
optional manytoone creator->User:+ = 2 [help_text = "Creator of this Tenant", null = True, db_index = True, blank = True];
@@ -476,8 +473,9 @@
optional string external_container = 4 [max_length = 30, content_type = "stripped", blank = True, help_text = "External host name", null = True, db_index = False];
}
-
message XOS (XOSBase) {
+ option singular="XOS";
+ option plural="XOSes";
required string name = 1 [default = "XOS", max_length = 200, content_type = "stripped", blank = False, help_text = "Name of XOS", null = False, db_index = False];
}
diff --git a/xos/coreapi/protos/Makefile b/xos/coreapi/protos/Makefile
index dbe1fed..0412464 100644
--- a/xos/coreapi/protos/Makefile
+++ b/xos/coreapi/protos/Makefile
@@ -22,6 +22,7 @@
default: build
+XOS_DIR=/opt/xos
PROTO_FILES := $(wildcard *.proto) $(wildcard third_party/google/api/*proto)
PROTO_PB2_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,_pb2.py,$(f)))
PROTO_DESC_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,.desc,$(f)))
@@ -38,6 +39,9 @@
PROTOC_DOWNLOAD_URI := $(PROTOC_DOWNLOAD_PREFIX)/v$(PROTOC_VERSION)/$(PROTOC_TARBALL)
PROTOC_BUILD_TMP_DIR := "/tmp/protobuf-build-$(shell uname -s | tr '[:upper:]' '[:lower:]')"
+XPROTO_FILES := $(wildcard $(XOS_DIR)/core/models/core.xproto $(XOS_DIR)/services/*/*.xproto)
+XOSGEN_PATH := $(XOS_DIR)/genx
+
build: $(PROTOC) $(PROTO_PB2_FILES)
%_pb2.py: %.proto Makefile
@@ -81,8 +85,21 @@
cd $(PROTOC_BUILD_TMP_DIR)/$(PROTOC_DIR); \
sudo make uninstall
-rebuild-protos:
- cd ../../tools/apigen && python ./modelgen -a "*" protobuf.template.txt > /opt/xos/coreapi/protos/xos.proto
- cd ../../tools/apigen && python ./modelgen -a "*" grpc_api.template.py > /opt/xos/coreapi/xos_grpc_api.py
- cd ../../tools/apigen && python ./modelgen -a "*" grpc_list_test.template.py > /opt/xos/coreapi/tests/list_test.py
- cd ../../tools/apigen && python ./modelgen -a "*" chameleon_list_test.template.sh > /opt/xos/coreapi/tests/chameleon_list_test.sh
+# Note: If you want to generate a new file, you need to do two things: Add a line of the type specified in the following line,
+# and add the generated file to "AUTOGENERATED"
+# <file to be generated>: <xtarget template that it depends on>
+
+$(XOS_DIR)/coreapi/protos/xos.proto: $(XOSGEN_PATH)/targets/protoapi.xtarget
+$(XOS_DIR)/coreapi/xos_grpc_api.py: $(XOSGEN_PATH)/targets/grpc_api.xtarget
+$(XOS_DIR)/coreapi/tests/list_test.py: $(XOSGEN_PATH)/targets/grpc_list_test.xtarget
+$(XOS_DIR)/coreapi/tests/chameleon_list_test.sh: $(XOSGEN_PATH)/targets/chameleon_list_test.xtarget
+$(XOS_DIR)/coreapi/protos/modeldefs.yaml: $(XOSGEN_PATH)/targets/modeldefs.xtarget
+
+AUTOGENERATED=$(XOS_DIR)/coreapi/protos/xos.proto $(XOS_DIR)/coreapi/xos_grpc_api.py $(XOS_DIR)/coreapi/tests/list_test.py $(XOS_DIR)/coreapi/tests/chameleon_list_test.sh $(XOS_DIR)/coreapi/protos/modeldefs.yaml
+
+$(AUTOGENERATED):
+ python $(XOSGEN_PATH)/tool/xosgen --target $< $(XPROTO_FILES) > $@
+
+rebuild-protos: $(AUTOGENERATED)
+
+.PHONY: $(AUTOGENERATED) rebuild-protos
diff --git a/xos/coreapi/xos_grpc_api.py b/xos/coreapi/xos_grpc_api.py
deleted file mode 100644
index a9ed79d..0000000
--- a/xos/coreapi/xos_grpc_api.py
+++ /dev/null
@@ -1,1740 +0,0 @@
-import base64
-import time
-from protos import xos_pb2
-from google.protobuf.empty_pb2 import Empty
-
-from django.contrib.auth import authenticate as django_authenticate
-from core.models import *
-from xos.exceptions import *
-from apihelper import XOSAPIHelperMixin
-
-class XosService(xos_pb2.xosServicer, XOSAPIHelperMixin):
- def __init__(self, thread_pool):
- self.thread_pool = thread_pool
-
- def stop(self):
- pass
-
- def ListServiceControllerResource(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ServiceControllerResource, ServiceControllerResource.objects.all())
-
- def GetServiceControllerResource(self, request, context):
- user=self.authenticate(context)
- return self.get(ServiceControllerResource, request.id)
-
- def CreateServiceControllerResource(self, request, context):
- user=self.authenticate(context)
- return self.create(ServiceControllerResource, user, request)
-
- def DeleteServiceControllerResource(self, request, context):
- user=self.authenticate(context)
- return self.delete(ServiceControllerResource, user, request.id)
-
- def UpdateServiceControllerResource(self, request, context):
- user=self.authenticate(context)
- return self.update(ServiceControllerResource, user, request.id, request)
-
-
- def ListXOSVolume(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(XOSVolume, XOSVolume.objects.all())
-
- def GetXOSVolume(self, request, context):
- user=self.authenticate(context)
- return self.get(XOSVolume, request.id)
-
- def CreateXOSVolume(self, request, context):
- user=self.authenticate(context)
- return self.create(XOSVolume, user, request)
-
- def DeleteXOSVolume(self, request, context):
- user=self.authenticate(context)
- return self.delete(XOSVolume, user, request.id)
-
- def UpdateXOSVolume(self, request, context):
- user=self.authenticate(context)
- return self.update(XOSVolume, user, request.id, request)
-
-
- def ListServiceAttribute(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ServiceAttribute, ServiceAttribute.objects.all())
-
- def GetServiceAttribute(self, request, context):
- user=self.authenticate(context)
- return self.get(ServiceAttribute, request.id)
-
- def CreateServiceAttribute(self, request, context):
- user=self.authenticate(context)
- return self.create(ServiceAttribute, user, request)
-
- def DeleteServiceAttribute(self, request, context):
- user=self.authenticate(context)
- return self.delete(ServiceAttribute, user, request.id)
-
- def UpdateServiceAttribute(self, request, context):
- user=self.authenticate(context)
- return self.update(ServiceAttribute, user, request.id, request)
-
-
- def ListControllerImages(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ControllerImages, ControllerImages.objects.all())
-
- def GetControllerImages(self, request, context):
- user=self.authenticate(context)
- return self.get(ControllerImages, request.id)
-
- def CreateControllerImages(self, request, context):
- user=self.authenticate(context)
- return self.create(ControllerImages, user, request)
-
- def DeleteControllerImages(self, request, context):
- user=self.authenticate(context)
- return self.delete(ControllerImages, user, request.id)
-
- def UpdateControllerImages(self, request, context):
- user=self.authenticate(context)
- return self.update(ControllerImages, user, request.id, request)
-
-
- def ListControllerSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ControllerSitePrivilege, ControllerSitePrivilege.objects.all())
-
- def GetControllerSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.get(ControllerSitePrivilege, request.id)
-
- def CreateControllerSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.create(ControllerSitePrivilege, user, request)
-
- def DeleteControllerSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.delete(ControllerSitePrivilege, user, request.id)
-
- def UpdateControllerSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.update(ControllerSitePrivilege, user, request.id, request)
-
-
- def ListImage(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Image, Image.objects.all())
-
- def GetImage(self, request, context):
- user=self.authenticate(context)
- return self.get(Image, request.id)
-
- def CreateImage(self, request, context):
- user=self.authenticate(context)
- return self.create(Image, user, request)
-
- def DeleteImage(self, request, context):
- user=self.authenticate(context)
- return self.delete(Image, user, request.id)
-
- def UpdateImage(self, request, context):
- user=self.authenticate(context)
- return self.update(Image, user, request.id, request)
-
-
- def ListControllerNetwork(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ControllerNetwork, ControllerNetwork.objects.all())
-
- def GetControllerNetwork(self, request, context):
- user=self.authenticate(context)
- return self.get(ControllerNetwork, request.id)
-
- def CreateControllerNetwork(self, request, context):
- user=self.authenticate(context)
- return self.create(ControllerNetwork, user, request)
-
- def DeleteControllerNetwork(self, request, context):
- user=self.authenticate(context)
- return self.delete(ControllerNetwork, user, request.id)
-
- def UpdateControllerNetwork(self, request, context):
- user=self.authenticate(context)
- return self.update(ControllerNetwork, user, request.id, request)
-
-
- def ListSite(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Site, Site.objects.all())
-
- def GetSite(self, request, context):
- user=self.authenticate(context)
- return self.get(Site, request.id)
-
- def CreateSite(self, request, context):
- user=self.authenticate(context)
- return self.create(Site, user, request)
-
- def DeleteSite(self, request, context):
- user=self.authenticate(context)
- return self.delete(Site, user, request.id)
-
- def UpdateSite(self, request, context):
- user=self.authenticate(context)
- return self.update(Site, user, request.id, request)
-
-
- def ListLibrary(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Library, Library.objects.all())
-
- def GetLibrary(self, request, context):
- user=self.authenticate(context)
- return self.get(Library, request.id)
-
- def CreateLibrary(self, request, context):
- user=self.authenticate(context)
- return self.create(Library, user, request)
-
- def DeleteLibrary(self, request, context):
- user=self.authenticate(context)
- return self.delete(Library, user, request.id)
-
- def UpdateLibrary(self, request, context):
- user=self.authenticate(context)
- return self.update(Library, user, request.id, request)
-
-
- def ListSliceRole(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(SliceRole, SliceRole.objects.all())
-
- def GetSliceRole(self, request, context):
- user=self.authenticate(context)
- return self.get(SliceRole, request.id)
-
- def CreateSliceRole(self, request, context):
- user=self.authenticate(context)
- return self.create(SliceRole, user, request)
-
- def DeleteSliceRole(self, request, context):
- user=self.authenticate(context)
- return self.delete(SliceRole, user, request.id)
-
- def UpdateSliceRole(self, request, context):
- user=self.authenticate(context)
- return self.update(SliceRole, user, request.id, request)
-
-
- def ListSiteDeployment(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(SiteDeployment, SiteDeployment.objects.all())
-
- def GetSiteDeployment(self, request, context):
- user=self.authenticate(context)
- return self.get(SiteDeployment, request.id)
-
- def CreateSiteDeployment(self, request, context):
- user=self.authenticate(context)
- return self.create(SiteDeployment, user, request)
-
- def DeleteSiteDeployment(self, request, context):
- user=self.authenticate(context)
- return self.delete(SiteDeployment, user, request.id)
-
- def UpdateSiteDeployment(self, request, context):
- user=self.authenticate(context)
- return self.update(SiteDeployment, user, request.id, request)
-
-
- def ListXOSComponentLink(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(XOSComponentLink, XOSComponentLink.objects.all())
-
- def GetXOSComponentLink(self, request, context):
- user=self.authenticate(context)
- return self.get(XOSComponentLink, request.id)
-
- def CreateXOSComponentLink(self, request, context):
- user=self.authenticate(context)
- return self.create(XOSComponentLink, user, request)
-
- def DeleteXOSComponentLink(self, request, context):
- user=self.authenticate(context)
- return self.delete(XOSComponentLink, user, request.id)
-
- def UpdateXOSComponentLink(self, request, context):
- user=self.authenticate(context)
- return self.update(XOSComponentLink, user, request.id, request)
-
-
- def ListTenantPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(TenantPrivilege, TenantPrivilege.objects.all())
-
- def GetTenantPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.get(TenantPrivilege, request.id)
-
- def CreateTenantPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.create(TenantPrivilege, user, request)
-
- def DeleteTenantPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.delete(TenantPrivilege, user, request.id)
-
- def UpdateTenantPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.update(TenantPrivilege, user, request.id, request)
-
-
- def ListTag(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Tag, Tag.objects.all())
-
- def GetTag(self, request, context):
- user=self.authenticate(context)
- return self.get(Tag, request.id)
-
- def CreateTag(self, request, context):
- user=self.authenticate(context)
- return self.create(Tag, user, request)
-
- def DeleteTag(self, request, context):
- user=self.authenticate(context)
- return self.delete(Tag, user, request.id)
-
- def UpdateTag(self, request, context):
- user=self.authenticate(context)
- return self.update(Tag, user, request.id, request)
-
-
- def ListServiceMonitoringAgentInfo(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ServiceMonitoringAgentInfo, ServiceMonitoringAgentInfo.objects.all())
-
- def GetServiceMonitoringAgentInfo(self, request, context):
- user=self.authenticate(context)
- return self.get(ServiceMonitoringAgentInfo, request.id)
-
- def CreateServiceMonitoringAgentInfo(self, request, context):
- user=self.authenticate(context)
- return self.create(ServiceMonitoringAgentInfo, user, request)
-
- def DeleteServiceMonitoringAgentInfo(self, request, context):
- user=self.authenticate(context)
- return self.delete(ServiceMonitoringAgentInfo, user, request.id)
-
- def UpdateServiceMonitoringAgentInfo(self, request, context):
- user=self.authenticate(context)
- return self.update(ServiceMonitoringAgentInfo, user, request.id, request)
-
-
- def ListXOSComponent(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(XOSComponent, XOSComponent.objects.all())
-
- def GetXOSComponent(self, request, context):
- user=self.authenticate(context)
- return self.get(XOSComponent, request.id)
-
- def CreateXOSComponent(self, request, context):
- user=self.authenticate(context)
- return self.create(XOSComponent, user, request)
-
- def DeleteXOSComponent(self, request, context):
- user=self.authenticate(context)
- return self.delete(XOSComponent, user, request.id)
-
- def UpdateXOSComponent(self, request, context):
- user=self.authenticate(context)
- return self.update(XOSComponent, user, request.id, request)
-
-
- def ListInvoice(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Invoice, Invoice.objects.all())
-
- def GetInvoice(self, request, context):
- user=self.authenticate(context)
- return self.get(Invoice, request.id)
-
- def CreateInvoice(self, request, context):
- user=self.authenticate(context)
- return self.create(Invoice, user, request)
-
- def DeleteInvoice(self, request, context):
- user=self.authenticate(context)
- return self.delete(Invoice, user, request.id)
-
- def UpdateInvoice(self, request, context):
- user=self.authenticate(context)
- return self.update(Invoice, user, request.id, request)
-
-
- def ListSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(SlicePrivilege, SlicePrivilege.objects.all())
-
- def GetSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.get(SlicePrivilege, request.id)
-
- def CreateSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.create(SlicePrivilege, user, request)
-
- def DeleteSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.delete(SlicePrivilege, user, request.id)
-
- def UpdateSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.update(SlicePrivilege, user, request.id, request)
-
-
- def ListFlavor(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Flavor, Flavor.objects.all())
-
- def GetFlavor(self, request, context):
- user=self.authenticate(context)
- return self.get(Flavor, request.id)
-
- def CreateFlavor(self, request, context):
- user=self.authenticate(context)
- return self.create(Flavor, user, request)
-
- def DeleteFlavor(self, request, context):
- user=self.authenticate(context)
- return self.delete(Flavor, user, request.id)
-
- def UpdateFlavor(self, request, context):
- user=self.authenticate(context)
- return self.update(Flavor, user, request.id, request)
-
-
- def ListPort(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Port, Port.objects.all())
-
- def GetPort(self, request, context):
- user=self.authenticate(context)
- return self.get(Port, request.id)
-
- def CreatePort(self, request, context):
- user=self.authenticate(context)
- return self.create(Port, user, request)
-
- def DeletePort(self, request, context):
- user=self.authenticate(context)
- return self.delete(Port, user, request.id)
-
- def UpdatePort(self, request, context):
- user=self.authenticate(context)
- return self.update(Port, user, request.id, request)
-
-
- def ListServiceRole(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ServiceRole, ServiceRole.objects.all())
-
- def GetServiceRole(self, request, context):
- user=self.authenticate(context)
- return self.get(ServiceRole, request.id)
-
- def CreateServiceRole(self, request, context):
- user=self.authenticate(context)
- return self.create(ServiceRole, user, request)
-
- def DeleteServiceRole(self, request, context):
- user=self.authenticate(context)
- return self.delete(ServiceRole, user, request.id)
-
- def UpdateServiceRole(self, request, context):
- user=self.authenticate(context)
- return self.update(ServiceRole, user, request.id, request)
-
-
- def ListControllerSite(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ControllerSite, ControllerSite.objects.all())
-
- def GetControllerSite(self, request, context):
- user=self.authenticate(context)
- return self.get(ControllerSite, request.id)
-
- def CreateControllerSite(self, request, context):
- user=self.authenticate(context)
- return self.create(ControllerSite, user, request)
-
- def DeleteControllerSite(self, request, context):
- user=self.authenticate(context)
- return self.delete(ControllerSite, user, request.id)
-
- def UpdateControllerSite(self, request, context):
- user=self.authenticate(context)
- return self.update(ControllerSite, user, request.id, request)
-
-
- def ListControllerSlice(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ControllerSlice, ControllerSlice.objects.all())
-
- def GetControllerSlice(self, request, context):
- user=self.authenticate(context)
- return self.get(ControllerSlice, request.id)
-
- def CreateControllerSlice(self, request, context):
- user=self.authenticate(context)
- return self.create(ControllerSlice, user, request)
-
- def DeleteControllerSlice(self, request, context):
- user=self.authenticate(context)
- return self.delete(ControllerSlice, user, request.id)
-
- def UpdateControllerSlice(self, request, context):
- user=self.authenticate(context)
- return self.update(ControllerSlice, user, request.id, request)
-
-
- def ListTenantRole(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(TenantRole, TenantRole.objects.all())
-
- def GetTenantRole(self, request, context):
- user=self.authenticate(context)
- return self.get(TenantRole, request.id)
-
- def CreateTenantRole(self, request, context):
- user=self.authenticate(context)
- return self.create(TenantRole, user, request)
-
- def DeleteTenantRole(self, request, context):
- user=self.authenticate(context)
- return self.delete(TenantRole, user, request.id)
-
- def UpdateTenantRole(self, request, context):
- user=self.authenticate(context)
- return self.update(TenantRole, user, request.id, request)
-
-
- def ListSlice(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Slice, Slice.objects.all())
-
- def GetSlice(self, request, context):
- user=self.authenticate(context)
- return self.get(Slice, request.id)
-
- def CreateSlice(self, request, context):
- user=self.authenticate(context)
- return self.create(Slice, user, request)
-
- def DeleteSlice(self, request, context):
- user=self.authenticate(context)
- return self.delete(Slice, user, request.id)
-
- def UpdateSlice(self, request, context):
- user=self.authenticate(context)
- return self.update(Slice, user, request.id, request)
-
-
- def ListLoadableModuleResource(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(LoadableModuleResource, LoadableModuleResource.objects.all())
-
- def GetLoadableModuleResource(self, request, context):
- user=self.authenticate(context)
- return self.get(LoadableModuleResource, request.id)
-
- def CreateLoadableModuleResource(self, request, context):
- user=self.authenticate(context)
- return self.create(LoadableModuleResource, user, request)
-
- def DeleteLoadableModuleResource(self, request, context):
- user=self.authenticate(context)
- return self.delete(LoadableModuleResource, user, request.id)
-
- def UpdateLoadableModuleResource(self, request, context):
- user=self.authenticate(context)
- return self.update(LoadableModuleResource, user, request.id, request)
-
-
- def ListControllerRole(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ControllerRole, ControllerRole.objects.all())
-
- def GetControllerRole(self, request, context):
- user=self.authenticate(context)
- return self.get(ControllerRole, request.id)
-
- def CreateControllerRole(self, request, context):
- user=self.authenticate(context)
- return self.create(ControllerRole, user, request)
-
- def DeleteControllerRole(self, request, context):
- user=self.authenticate(context)
- return self.delete(ControllerRole, user, request.id)
-
- def UpdateControllerRole(self, request, context):
- user=self.authenticate(context)
- return self.update(ControllerRole, user, request.id, request)
-
-
- def ListDiag(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Diag, Diag.objects.all())
-
- def GetDiag(self, request, context):
- user=self.authenticate(context)
- return self.get(Diag, request.id)
-
- def CreateDiag(self, request, context):
- user=self.authenticate(context)
- return self.create(Diag, user, request)
-
- def DeleteDiag(self, request, context):
- user=self.authenticate(context)
- return self.delete(Diag, user, request.id)
-
- def UpdateDiag(self, request, context):
- user=self.authenticate(context)
- return self.update(Diag, user, request.id, request)
-
-
- def ListXOS(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(XOS, XOS.objects.all())
-
- def GetXOS(self, request, context):
- user=self.authenticate(context)
- return self.get(XOS, request.id)
-
- def CreateXOS(self, request, context):
- user=self.authenticate(context)
- return self.create(XOS, user, request)
-
- def DeleteXOS(self, request, context):
- user=self.authenticate(context)
- return self.delete(XOS, user, request.id)
-
- def UpdateXOS(self, request, context):
- user=self.authenticate(context)
- return self.update(XOS, user, request.id, request)
-
-
- def ListServiceClass(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ServiceClass, ServiceClass.objects.all())
-
- def GetServiceClass(self, request, context):
- user=self.authenticate(context)
- return self.get(ServiceClass, request.id)
-
- def CreateServiceClass(self, request, context):
- user=self.authenticate(context)
- return self.create(ServiceClass, user, request)
-
- def DeleteServiceClass(self, request, context):
- user=self.authenticate(context)
- return self.delete(ServiceClass, user, request.id)
-
- def UpdateServiceClass(self, request, context):
- user=self.authenticate(context)
- return self.update(ServiceClass, user, request.id, request)
-
-
- def ListTenantAttribute(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(TenantAttribute, TenantAttribute.objects.all())
-
- def GetTenantAttribute(self, request, context):
- user=self.authenticate(context)
- return self.get(TenantAttribute, request.id)
-
- def CreateTenantAttribute(self, request, context):
- user=self.authenticate(context)
- return self.create(TenantAttribute, user, request)
-
- def DeleteTenantAttribute(self, request, context):
- user=self.authenticate(context)
- return self.delete(TenantAttribute, user, request.id)
-
- def UpdateTenantAttribute(self, request, context):
- user=self.authenticate(context)
- return self.update(TenantAttribute, user, request.id, request)
-
-
- def ListSiteRole(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(SiteRole, SiteRole.objects.all())
-
- def GetSiteRole(self, request, context):
- user=self.authenticate(context)
- return self.get(SiteRole, request.id)
-
- def CreateSiteRole(self, request, context):
- user=self.authenticate(context)
- return self.create(SiteRole, user, request)
-
- def DeleteSiteRole(self, request, context):
- user=self.authenticate(context)
- return self.delete(SiteRole, user, request.id)
-
- def UpdateSiteRole(self, request, context):
- user=self.authenticate(context)
- return self.update(SiteRole, user, request.id, request)
-
-
- def ListSubscriber(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Subscriber, Subscriber.objects.all())
-
- def GetSubscriber(self, request, context):
- user=self.authenticate(context)
- return self.get(Subscriber, request.id)
-
- def CreateSubscriber(self, request, context):
- user=self.authenticate(context)
- return self.create(Subscriber, user, request)
-
- def DeleteSubscriber(self, request, context):
- user=self.authenticate(context)
- return self.delete(Subscriber, user, request.id)
-
- def UpdateSubscriber(self, request, context):
- user=self.authenticate(context)
- return self.update(Subscriber, user, request.id, request)
-
-
- def ListInstance(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Instance, Instance.objects.all())
-
- def GetInstance(self, request, context):
- user=self.authenticate(context)
- return self.get(Instance, request.id)
-
- def CreateInstance(self, request, context):
- user=self.authenticate(context)
- return self.create(Instance, user, request)
-
- def DeleteInstance(self, request, context):
- user=self.authenticate(context)
- return self.delete(Instance, user, request.id)
-
- def UpdateInstance(self, request, context):
- user=self.authenticate(context)
- return self.update(Instance, user, request.id, request)
-
-
- def ListCharge(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Charge, Charge.objects.all())
-
- def GetCharge(self, request, context):
- user=self.authenticate(context)
- return self.get(Charge, request.id)
-
- def CreateCharge(self, request, context):
- user=self.authenticate(context)
- return self.create(Charge, user, request)
-
- def DeleteCharge(self, request, context):
- user=self.authenticate(context)
- return self.delete(Charge, user, request.id)
-
- def UpdateCharge(self, request, context):
- user=self.authenticate(context)
- return self.update(Charge, user, request.id, request)
-
-
- def ListProgram(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Program, Program.objects.all())
-
- def GetProgram(self, request, context):
- user=self.authenticate(context)
- return self.get(Program, request.id)
-
- def CreateProgram(self, request, context):
- user=self.authenticate(context)
- return self.create(Program, user, request)
-
- def DeleteProgram(self, request, context):
- user=self.authenticate(context)
- return self.delete(Program, user, request.id)
-
- def UpdateProgram(self, request, context):
- user=self.authenticate(context)
- return self.update(Program, user, request.id, request)
-
-
- def ListRole(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Role, Role.objects.all())
-
- def GetRole(self, request, context):
- user=self.authenticate(context)
- return self.get(Role, request.id)
-
- def CreateRole(self, request, context):
- user=self.authenticate(context)
- return self.create(Role, user, request)
-
- def DeleteRole(self, request, context):
- user=self.authenticate(context)
- return self.delete(Role, user, request.id)
-
- def UpdateRole(self, request, context):
- user=self.authenticate(context)
- return self.update(Role, user, request.id, request)
-
-
- def ListNodeLabel(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(NodeLabel, NodeLabel.objects.all())
-
- def GetNodeLabel(self, request, context):
- user=self.authenticate(context)
- return self.get(NodeLabel, request.id)
-
- def CreateNodeLabel(self, request, context):
- user=self.authenticate(context)
- return self.create(NodeLabel, user, request)
-
- def DeleteNodeLabel(self, request, context):
- user=self.authenticate(context)
- return self.delete(NodeLabel, user, request.id)
-
- def UpdateNodeLabel(self, request, context):
- user=self.authenticate(context)
- return self.update(NodeLabel, user, request.id, request)
-
-
- def ListNetworkTemplate(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(NetworkTemplate, NetworkTemplate.objects.all())
-
- def GetNetworkTemplate(self, request, context):
- user=self.authenticate(context)
- return self.get(NetworkTemplate, request.id)
-
- def CreateNetworkTemplate(self, request, context):
- user=self.authenticate(context)
- return self.create(NetworkTemplate, user, request)
-
- def DeleteNetworkTemplate(self, request, context):
- user=self.authenticate(context)
- return self.delete(NetworkTemplate, user, request.id)
-
- def UpdateNetworkTemplate(self, request, context):
- user=self.authenticate(context)
- return self.update(NetworkTemplate, user, request.id, request)
-
-
- def ListServiceController(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ServiceController, ServiceController.objects.all())
-
- def GetServiceController(self, request, context):
- user=self.authenticate(context)
- return self.get(ServiceController, request.id)
-
- def CreateServiceController(self, request, context):
- user=self.authenticate(context)
- return self.create(ServiceController, user, request)
-
- def DeleteServiceController(self, request, context):
- user=self.authenticate(context)
- return self.delete(ServiceController, user, request.id)
-
- def UpdateServiceController(self, request, context):
- user=self.authenticate(context)
- return self.update(ServiceController, user, request.id, request)
-
-
- def ListLoadableModule(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(LoadableModule, LoadableModule.objects.all())
-
- def GetLoadableModule(self, request, context):
- user=self.authenticate(context)
- return self.get(LoadableModule, request.id)
-
- def CreateLoadableModule(self, request, context):
- user=self.authenticate(context)
- return self.create(LoadableModule, user, request)
-
- def DeleteLoadableModule(self, request, context):
- user=self.authenticate(context)
- return self.delete(LoadableModule, user, request.id)
-
- def UpdateLoadableModule(self, request, context):
- user=self.authenticate(context)
- return self.update(LoadableModule, user, request.id, request)
-
-
- def ListUsableObject(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(UsableObject, UsableObject.objects.all())
-
- def GetUsableObject(self, request, context):
- user=self.authenticate(context)
- return self.get(UsableObject, request.id)
-
- def CreateUsableObject(self, request, context):
- user=self.authenticate(context)
- return self.create(UsableObject, user, request)
-
- def DeleteUsableObject(self, request, context):
- user=self.authenticate(context)
- return self.delete(UsableObject, user, request.id)
-
- def UpdateUsableObject(self, request, context):
- user=self.authenticate(context)
- return self.update(UsableObject, user, request.id, request)
-
-
- def ListNode(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Node, Node.objects.all())
-
- def GetNode(self, request, context):
- user=self.authenticate(context)
- return self.get(Node, request.id)
-
- def CreateNode(self, request, context):
- user=self.authenticate(context)
- return self.create(Node, user, request)
-
- def DeleteNode(self, request, context):
- user=self.authenticate(context)
- return self.delete(Node, user, request.id)
-
- def UpdateNode(self, request, context):
- user=self.authenticate(context)
- return self.update(Node, user, request.id, request)
-
-
- def ListAddressPool(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(AddressPool, AddressPool.objects.all())
-
- def GetAddressPool(self, request, context):
- user=self.authenticate(context)
- return self.get(AddressPool, request.id)
-
- def CreateAddressPool(self, request, context):
- user=self.authenticate(context)
- return self.create(AddressPool, user, request)
-
- def DeleteAddressPool(self, request, context):
- user=self.authenticate(context)
- return self.delete(AddressPool, user, request.id)
-
- def UpdateAddressPool(self, request, context):
- user=self.authenticate(context)
- return self.update(AddressPool, user, request.id, request)
-
-
- def ListDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(DashboardView, DashboardView.objects.all())
-
- def GetDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.get(DashboardView, request.id)
-
- def CreateDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.create(DashboardView, user, request)
-
- def DeleteDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.delete(DashboardView, user, request.id)
-
- def UpdateDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.update(DashboardView, user, request.id, request)
-
-
- def ListNetworkParameter(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(NetworkParameter, NetworkParameter.objects.all())
-
- def GetNetworkParameter(self, request, context):
- user=self.authenticate(context)
- return self.get(NetworkParameter, request.id)
-
- def CreateNetworkParameter(self, request, context):
- user=self.authenticate(context)
- return self.create(NetworkParameter, user, request)
-
- def DeleteNetworkParameter(self, request, context):
- user=self.authenticate(context)
- return self.delete(NetworkParameter, user, request.id)
-
- def UpdateNetworkParameter(self, request, context):
- user=self.authenticate(context)
- return self.update(NetworkParameter, user, request.id, request)
-
-
- def ListImageDeployments(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ImageDeployments, ImageDeployments.objects.all())
-
- def GetImageDeployments(self, request, context):
- user=self.authenticate(context)
- return self.get(ImageDeployments, request.id)
-
- def CreateImageDeployments(self, request, context):
- user=self.authenticate(context)
- return self.create(ImageDeployments, user, request)
-
- def DeleteImageDeployments(self, request, context):
- user=self.authenticate(context)
- return self.delete(ImageDeployments, user, request.id)
-
- def UpdateImageDeployments(self, request, context):
- user=self.authenticate(context)
- return self.update(ImageDeployments, user, request.id, request)
-
-
- def ListControllerUser(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ControllerUser, ControllerUser.objects.all())
-
- def GetControllerUser(self, request, context):
- user=self.authenticate(context)
- return self.get(ControllerUser, request.id)
-
- def CreateControllerUser(self, request, context):
- user=self.authenticate(context)
- return self.create(ControllerUser, user, request)
-
- def DeleteControllerUser(self, request, context):
- user=self.authenticate(context)
- return self.delete(ControllerUser, user, request.id)
-
- def UpdateControllerUser(self, request, context):
- user=self.authenticate(context)
- return self.update(ControllerUser, user, request.id, request)
-
-
- def ListReservedResource(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ReservedResource, ReservedResource.objects.all())
-
- def GetReservedResource(self, request, context):
- user=self.authenticate(context)
- return self.get(ReservedResource, request.id)
-
- def CreateReservedResource(self, request, context):
- user=self.authenticate(context)
- return self.create(ReservedResource, user, request)
-
- def DeleteReservedResource(self, request, context):
- user=self.authenticate(context)
- return self.delete(ReservedResource, user, request.id)
-
- def UpdateReservedResource(self, request, context):
- user=self.authenticate(context)
- return self.update(ReservedResource, user, request.id, request)
-
-
- def ListJournalEntry(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(JournalEntry, JournalEntry.objects.all())
-
- def GetJournalEntry(self, request, context):
- user=self.authenticate(context)
- return self.get(JournalEntry, request.id)
-
- def CreateJournalEntry(self, request, context):
- user=self.authenticate(context)
- return self.create(JournalEntry, user, request)
-
- def DeleteJournalEntry(self, request, context):
- user=self.authenticate(context)
- return self.delete(JournalEntry, user, request.id)
-
- def UpdateJournalEntry(self, request, context):
- user=self.authenticate(context)
- return self.update(JournalEntry, user, request.id, request)
-
-
- def ListUserCredential(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(UserCredential, UserCredential.objects.all())
-
- def GetUserCredential(self, request, context):
- user=self.authenticate(context)
- return self.get(UserCredential, request.id)
-
- def CreateUserCredential(self, request, context):
- user=self.authenticate(context)
- return self.create(UserCredential, user, request)
-
- def DeleteUserCredential(self, request, context):
- user=self.authenticate(context)
- return self.delete(UserCredential, user, request.id)
-
- def UpdateUserCredential(self, request, context):
- user=self.authenticate(context)
- return self.update(UserCredential, user, request.id, request)
-
-
- def ListControllerDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ControllerDashboardView, ControllerDashboardView.objects.all())
-
- def GetControllerDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.get(ControllerDashboardView, request.id)
-
- def CreateControllerDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.create(ControllerDashboardView, user, request)
-
- def DeleteControllerDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.delete(ControllerDashboardView, user, request.id)
-
- def UpdateControllerDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.update(ControllerDashboardView, user, request.id, request)
-
-
- def ListUserDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(UserDashboardView, UserDashboardView.objects.all())
-
- def GetUserDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.get(UserDashboardView, request.id)
-
- def CreateUserDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.create(UserDashboardView, user, request)
-
- def DeleteUserDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.delete(UserDashboardView, user, request.id)
-
- def UpdateUserDashboardView(self, request, context):
- user=self.authenticate(context)
- return self.update(UserDashboardView, user, request.id, request)
-
-
- def ListController(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Controller, Controller.objects.all())
-
- def GetController(self, request, context):
- user=self.authenticate(context)
- return self.get(Controller, request.id)
-
- def CreateController(self, request, context):
- user=self.authenticate(context)
- return self.create(Controller, user, request)
-
- def DeleteController(self, request, context):
- user=self.authenticate(context)
- return self.delete(Controller, user, request.id)
-
- def UpdateController(self, request, context):
- user=self.authenticate(context)
- return self.update(Controller, user, request.id, request)
-
-
- def ListTenantRootRole(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(TenantRootRole, TenantRootRole.objects.all())
-
- def GetTenantRootRole(self, request, context):
- user=self.authenticate(context)
- return self.get(TenantRootRole, request.id)
-
- def CreateTenantRootRole(self, request, context):
- user=self.authenticate(context)
- return self.create(TenantRootRole, user, request)
-
- def DeleteTenantRootRole(self, request, context):
- user=self.authenticate(context)
- return self.delete(TenantRootRole, user, request.id)
-
- def UpdateTenantRootRole(self, request, context):
- user=self.authenticate(context)
- return self.update(TenantRootRole, user, request.id, request)
-
-
- def ListDeployment(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Deployment, Deployment.objects.all())
-
- def GetDeployment(self, request, context):
- user=self.authenticate(context)
- return self.get(Deployment, request.id)
-
- def CreateDeployment(self, request, context):
- user=self.authenticate(context)
- return self.create(Deployment, user, request)
-
- def DeleteDeployment(self, request, context):
- user=self.authenticate(context)
- return self.delete(Deployment, user, request.id)
-
- def UpdateDeployment(self, request, context):
- user=self.authenticate(context)
- return self.update(Deployment, user, request.id, request)
-
-
- def ListReservation(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Reservation, Reservation.objects.all())
-
- def GetReservation(self, request, context):
- user=self.authenticate(context)
- return self.get(Reservation, request.id)
-
- def CreateReservation(self, request, context):
- user=self.authenticate(context)
- return self.create(Reservation, user, request)
-
- def DeleteReservation(self, request, context):
- user=self.authenticate(context)
- return self.delete(Reservation, user, request.id)
-
- def UpdateReservation(self, request, context):
- user=self.authenticate(context)
- return self.update(Reservation, user, request.id, request)
-
-
- def ListSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(SitePrivilege, SitePrivilege.objects.all())
-
- def GetSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.get(SitePrivilege, request.id)
-
- def CreateSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.create(SitePrivilege, user, request)
-
- def DeleteSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.delete(SitePrivilege, user, request.id)
-
- def UpdateSitePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.update(SitePrivilege, user, request.id, request)
-
-
- def ListPayment(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Payment, Payment.objects.all())
-
- def GetPayment(self, request, context):
- user=self.authenticate(context)
- return self.get(Payment, request.id)
-
- def CreatePayment(self, request, context):
- user=self.authenticate(context)
- return self.create(Payment, user, request)
-
- def DeletePayment(self, request, context):
- user=self.authenticate(context)
- return self.delete(Payment, user, request.id)
-
- def UpdatePayment(self, request, context):
- user=self.authenticate(context)
- return self.update(Payment, user, request.id, request)
-
-
- def ListTenant(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Tenant, Tenant.objects.all())
-
- def GetTenant(self, request, context):
- user=self.authenticate(context)
- return self.get(Tenant, request.id)
-
- def CreateTenant(self, request, context):
- user=self.authenticate(context)
- return self.create(Tenant, user, request)
-
- def DeleteTenant(self, request, context):
- user=self.authenticate(context)
- return self.delete(Tenant, user, request.id)
-
- def UpdateTenant(self, request, context):
- user=self.authenticate(context)
- return self.update(Tenant, user, request.id, request)
-
-
- def ListNetwork(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Network, Network.objects.all())
-
- def GetNetwork(self, request, context):
- user=self.authenticate(context)
- return self.get(Network, request.id)
-
- def CreateNetwork(self, request, context):
- user=self.authenticate(context)
- return self.create(Network, user, request)
-
- def DeleteNetwork(self, request, context):
- user=self.authenticate(context)
- return self.delete(Network, user, request.id)
-
- def UpdateNetwork(self, request, context):
- user=self.authenticate(context)
- return self.update(Network, user, request.id, request)
-
-
- def ListNetworkSlice(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(NetworkSlice, NetworkSlice.objects.all())
-
- def GetNetworkSlice(self, request, context):
- user=self.authenticate(context)
- return self.get(NetworkSlice, request.id)
-
- def CreateNetworkSlice(self, request, context):
- user=self.authenticate(context)
- return self.create(NetworkSlice, user, request)
-
- def DeleteNetworkSlice(self, request, context):
- user=self.authenticate(context)
- return self.delete(NetworkSlice, user, request.id)
-
- def UpdateNetworkSlice(self, request, context):
- user=self.authenticate(context)
- return self.update(NetworkSlice, user, request.id, request)
-
-
- def ListAccount(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Account, Account.objects.all())
-
- def GetAccount(self, request, context):
- user=self.authenticate(context)
- return self.get(Account, request.id)
-
- def CreateAccount(self, request, context):
- user=self.authenticate(context)
- return self.create(Account, user, request)
-
- def DeleteAccount(self, request, context):
- user=self.authenticate(context)
- return self.delete(Account, user, request.id)
-
- def UpdateAccount(self, request, context):
- user=self.authenticate(context)
- return self.update(Account, user, request.id, request)
-
-
- def ListTenantRoot(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(TenantRoot, TenantRoot.objects.all())
-
- def GetTenantRoot(self, request, context):
- user=self.authenticate(context)
- return self.get(TenantRoot, request.id)
-
- def CreateTenantRoot(self, request, context):
- user=self.authenticate(context)
- return self.create(TenantRoot, user, request)
-
- def DeleteTenantRoot(self, request, context):
- user=self.authenticate(context)
- return self.delete(TenantRoot, user, request.id)
-
- def UpdateTenantRoot(self, request, context):
- user=self.authenticate(context)
- return self.update(TenantRoot, user, request.id, request)
-
-
- def ListService(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Service, Service.objects.all())
-
- def GetService(self, request, context):
- user=self.authenticate(context)
- return self.get(Service, request.id)
-
- def CreateService(self, request, context):
- user=self.authenticate(context)
- return self.create(Service, user, request)
-
- def DeleteService(self, request, context):
- user=self.authenticate(context)
- return self.delete(Service, user, request.id)
-
- def UpdateService(self, request, context):
- user=self.authenticate(context)
- return self.update(Service, user, request.id, request)
-
-
- def ListControllerSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ControllerSlicePrivilege, ControllerSlicePrivilege.objects.all())
-
- def GetControllerSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.get(ControllerSlicePrivilege, request.id)
-
- def CreateControllerSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.create(ControllerSlicePrivilege, user, request)
-
- def DeleteControllerSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.delete(ControllerSlicePrivilege, user, request.id)
-
- def UpdateControllerSlicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.update(ControllerSlicePrivilege, user, request.id, request)
-
-
- def ListSiteCredential(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(SiteCredential, SiteCredential.objects.all())
-
- def GetSiteCredential(self, request, context):
- user=self.authenticate(context)
- return self.get(SiteCredential, request.id)
-
- def CreateSiteCredential(self, request, context):
- user=self.authenticate(context)
- return self.create(SiteCredential, user, request)
-
- def DeleteSiteCredential(self, request, context):
- user=self.authenticate(context)
- return self.delete(SiteCredential, user, request.id)
-
- def UpdateSiteCredential(self, request, context):
- user=self.authenticate(context)
- return self.update(SiteCredential, user, request.id, request)
-
-
- def ListDeploymentPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(DeploymentPrivilege, DeploymentPrivilege.objects.all())
-
- def GetDeploymentPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.get(DeploymentPrivilege, request.id)
-
- def CreateDeploymentPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.create(DeploymentPrivilege, user, request)
-
- def DeleteDeploymentPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.delete(DeploymentPrivilege, user, request.id)
-
- def UpdateDeploymentPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.update(DeploymentPrivilege, user, request.id, request)
-
-
- def ListNetworkParameterType(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(NetworkParameterType, NetworkParameterType.objects.all())
-
- def GetNetworkParameterType(self, request, context):
- user=self.authenticate(context)
- return self.get(NetworkParameterType, request.id)
-
- def CreateNetworkParameterType(self, request, context):
- user=self.authenticate(context)
- return self.create(NetworkParameterType, user, request)
-
- def DeleteNetworkParameterType(self, request, context):
- user=self.authenticate(context)
- return self.delete(NetworkParameterType, user, request.id)
-
- def UpdateNetworkParameterType(self, request, context):
- user=self.authenticate(context)
- return self.update(NetworkParameterType, user, request.id, request)
-
-
- def ListProvider(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Provider, Provider.objects.all())
-
- def GetProvider(self, request, context):
- user=self.authenticate(context)
- return self.get(Provider, request.id)
-
- def CreateProvider(self, request, context):
- user=self.authenticate(context)
- return self.create(Provider, user, request)
-
- def DeleteProvider(self, request, context):
- user=self.authenticate(context)
- return self.delete(Provider, user, request.id)
-
- def UpdateProvider(self, request, context):
- user=self.authenticate(context)
- return self.update(Provider, user, request.id, request)
-
-
- def ListTenantWithContainer(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(TenantWithContainer, TenantWithContainer.objects.all())
-
- def GetTenantWithContainer(self, request, context):
- user=self.authenticate(context)
- return self.get(TenantWithContainer, request.id)
-
- def CreateTenantWithContainer(self, request, context):
- user=self.authenticate(context)
- return self.create(TenantWithContainer, user, request)
-
- def DeleteTenantWithContainer(self, request, context):
- user=self.authenticate(context)
- return self.delete(TenantWithContainer, user, request.id)
-
- def UpdateTenantWithContainer(self, request, context):
- user=self.authenticate(context)
- return self.update(TenantWithContainer, user, request.id, request)
-
-
- def ListDeploymentRole(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(DeploymentRole, DeploymentRole.objects.all())
-
- def GetDeploymentRole(self, request, context):
- user=self.authenticate(context)
- return self.get(DeploymentRole, request.id)
-
- def CreateDeploymentRole(self, request, context):
- user=self.authenticate(context)
- return self.create(DeploymentRole, user, request)
-
- def DeleteDeploymentRole(self, request, context):
- user=self.authenticate(context)
- return self.delete(DeploymentRole, user, request.id)
-
- def UpdateDeploymentRole(self, request, context):
- user=self.authenticate(context)
- return self.update(DeploymentRole, user, request.id, request)
-
-
- def ListProject(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Project, Project.objects.all())
-
- def GetProject(self, request, context):
- user=self.authenticate(context)
- return self.get(Project, request.id)
-
- def CreateProject(self, request, context):
- user=self.authenticate(context)
- return self.create(Project, user, request)
-
- def DeleteProject(self, request, context):
- user=self.authenticate(context)
- return self.delete(Project, user, request.id)
-
- def UpdateProject(self, request, context):
- user=self.authenticate(context)
- return self.update(Project, user, request.id, request)
-
-
- def ListTenantRootPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(TenantRootPrivilege, TenantRootPrivilege.objects.all())
-
- def GetTenantRootPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.get(TenantRootPrivilege, request.id)
-
- def CreateTenantRootPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.create(TenantRootPrivilege, user, request)
-
- def DeleteTenantRootPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.delete(TenantRootPrivilege, user, request.id)
-
- def UpdateTenantRootPrivilege(self, request, context):
- user=self.authenticate(context)
- return self.update(TenantRootPrivilege, user, request.id, request)
-
-
- def ListXOSComponentVolume(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(XOSComponentVolume, XOSComponentVolume.objects.all())
-
- def GetXOSComponentVolume(self, request, context):
- user=self.authenticate(context)
- return self.get(XOSComponentVolume, request.id)
-
- def CreateXOSComponentVolume(self, request, context):
- user=self.authenticate(context)
- return self.create(XOSComponentVolume, user, request)
-
- def DeleteXOSComponentVolume(self, request, context):
- user=self.authenticate(context)
- return self.delete(XOSComponentVolume, user, request.id)
-
- def UpdateXOSComponentVolume(self, request, context):
- user=self.authenticate(context)
- return self.update(XOSComponentVolume, user, request.id, request)
-
-
- def ListSliceCredential(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(SliceCredential, SliceCredential.objects.all())
-
- def GetSliceCredential(self, request, context):
- user=self.authenticate(context)
- return self.get(SliceCredential, request.id)
-
- def CreateSliceCredential(self, request, context):
- user=self.authenticate(context)
- return self.create(SliceCredential, user, request)
-
- def DeleteSliceCredential(self, request, context):
- user=self.authenticate(context)
- return self.delete(SliceCredential, user, request.id)
-
- def UpdateSliceCredential(self, request, context):
- user=self.authenticate(context)
- return self.update(SliceCredential, user, request.id, request)
-
-
- def ListSliceTag(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(SliceTag, SliceTag.objects.all())
-
- def GetSliceTag(self, request, context):
- user=self.authenticate(context)
- return self.get(SliceTag, request.id)
-
- def CreateSliceTag(self, request, context):
- user=self.authenticate(context)
- return self.create(SliceTag, user, request)
-
- def DeleteSliceTag(self, request, context):
- user=self.authenticate(context)
- return self.delete(SliceTag, user, request.id)
-
- def UpdateSliceTag(self, request, context):
- user=self.authenticate(context)
- return self.update(SliceTag, user, request.id, request)
-
-
- def ListCoarseTenant(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(CoarseTenant, CoarseTenant.objects.all())
-
- def GetCoarseTenant(self, request, context):
- user=self.authenticate(context)
- return self.get(CoarseTenant, request.id)
-
- def CreateCoarseTenant(self, request, context):
- user=self.authenticate(context)
- return self.create(CoarseTenant, user, request)
-
- def DeleteCoarseTenant(self, request, context):
- user=self.authenticate(context)
- return self.delete(CoarseTenant, user, request.id)
-
- def UpdateCoarseTenant(self, request, context):
- user=self.authenticate(context)
- return self.update(CoarseTenant, user, request.id, request)
-
-
- def ListRouter(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(Router, Router.objects.all())
-
- def GetRouter(self, request, context):
- user=self.authenticate(context)
- return self.get(Router, request.id)
-
- def CreateRouter(self, request, context):
- user=self.authenticate(context)
- return self.create(Router, user, request)
-
- def DeleteRouter(self, request, context):
- user=self.authenticate(context)
- return self.delete(Router, user, request.id)
-
- def UpdateRouter(self, request, context):
- user=self.authenticate(context)
- return self.update(Router, user, request.id, request)
-
-
- def ListServiceResource(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ServiceResource, ServiceResource.objects.all())
-
- def GetServiceResource(self, request, context):
- user=self.authenticate(context)
- return self.get(ServiceResource, request.id)
-
- def CreateServiceResource(self, request, context):
- user=self.authenticate(context)
- return self.create(ServiceResource, user, request)
-
- def DeleteServiceResource(self, request, context):
- user=self.authenticate(context)
- return self.delete(ServiceResource, user, request.id)
-
- def UpdateServiceResource(self, request, context):
- user=self.authenticate(context)
- return self.update(ServiceResource, user, request.id, request)
-
-
- def ListServicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(ServicePrivilege, ServicePrivilege.objects.all())
-
- def GetServicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.get(ServicePrivilege, request.id)
-
- def CreateServicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.create(ServicePrivilege, user, request)
-
- def DeleteServicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.delete(ServicePrivilege, user, request.id)
-
- def UpdateServicePrivilege(self, request, context):
- user=self.authenticate(context)
- return self.update(ServicePrivilege, user, request.id, request)
-
-
- def ListUser(self, request, context):
- user=self.authenticate(context)
- return self.querysetToProto(User, User.objects.all())
-
- def GetUser(self, request, context):
- user=self.authenticate(context)
- return self.get(User, request.id)
-
- def CreateUser(self, request, context):
- user=self.authenticate(context)
- return self.create(User, user, request)
-
- def DeleteUser(self, request, context):
- user=self.authenticate(context)
- return self.delete(User, user, request.id)
-
- def UpdateUser(self, request, context):
- user=self.authenticate(context)
- return self.update(User, user, request.id, request)
-
-
-
diff --git a/xos/coreapi/xos_modeldefs_api.py b/xos/coreapi/xos_modeldefs_api.py
index 63a7a23..8a9d239 100644
--- a/xos/coreapi/xos_modeldefs_api.py
+++ b/xos/coreapi/xos_modeldefs_api.py
@@ -1,14 +1,23 @@
import base64
import time
+import yaml
from protos import modeldefs_pb2
from google.protobuf.empty_pb2 import Empty
-from django.contrib.auth import authenticate as django_authenticate
-import django.apps
-from core.models import *
from xos.exceptions import *
from apihelper import XOSAPIHelperMixin
+def yaml_to_grpc(yaml_repr, grpc_container, yaml_key = None, grpc_parent = None):
+ if isinstance(yaml_repr, dict):
+ for k,v in yaml_repr.items():
+ grpc_sub_container = getattr(grpc_container, k)
+ yaml_to_grpc(v, grpc_sub_container, k, grpc_container)
+ elif isinstance(yaml_repr, list):
+ for i in yaml_repr:
+ grpc_sub_container = grpc_container.add()
+ yaml_to_grpc(i, grpc_sub_container, None, grpc_container)
+ else:
+ setattr(grpc_parent, yaml_key, yaml_repr)
class ModelDefsService(modeldefs_pb2.modeldefsServicer, XOSAPIHelperMixin):
def __init__(self, thread_pool):
@@ -17,137 +26,22 @@
def stop(self):
pass
- typeMap = {
- 'BooleanField': 'boolean',
- 'TextField': 'text',
- 'CharField': 'string',
- 'ForeignKey': 'number',
- 'IntegerField': 'number',
- 'AutoField': 'number',
- 'DateTimeField': 'date'
- }
-
- validatorMap = {
- 'EmailValidator': 'email',
- 'MaxLengthValidator': 'maxlength',
- 'URLValidator': 'url',
- 'MinValueValidator': 'min',
- 'MaxValueValidator': 'max',
- 'validate_ipv46_address': 'ip'
- }
-
- def convertType(self, type):
- try:
- jsType = self.typeMap[type]
- return jsType
- except Exception:
- return None
-
- def convertValidator(self, validator):
- try:
- jsValidator = self.validatorMap[validator]
- return jsValidator
- except Exception:
- return None
-
- def getRelationType(self, field):
- if (field.many_to_many):
- return 'many_to_many'
- if (field.many_to_one):
- return 'many_to_one'
- if (field.one_to_many):
- return 'one_to_many'
- if (field.one_to_one):
- return 'one_to_one'
-
- def parseModuleName(self, module):
- if 'core' in module:
- return 'core'
- if 'service' in module:
- return module[:-7]
- return module
-
def ListModelDefs(self, request, context):
- models = django.apps.apps.get_models()
+ ystr = open('protos/modeldefs.yaml').read()
+ yaml_repr = yaml.load(ystr)
modeldefs = modeldefs_pb2.ModelDefs()
- response = []
+ yaml_to_grpc(yaml_repr, modeldefs)
- for model in models:
- # NOTE removing Django internal models
- if 'django' in model.__module__:
- continue
- if 'cors' in model.__module__:
- continue
- if 'contenttypes' in model.__module__:
- continue
- if 'core.models.journal' in model.__module__:
- continue
- if 'core.models.project' in model.__module__:
- continue
-
- modeldef = modeldefs.items.add()
-
- modeldef.name = model.__name__
- modeldef.app = self.parseModuleName(model.__module__)
-
- parent_field_names = [x.name for x in model._meta.parents.values() if x is not None]
- for parent_model in model._meta.get_parent_list():
- parent_field_names.extend([x.name for x in parent_model._meta.parents.values() if x is not None])
-
- for f in model._meta.fields:
- if f.name in parent_field_names:
- # skip fields that are pointers to the parent class
- continue
-
- field = modeldef.fields.add()
-
- field.name = f.name
- field.hint = f.help_text
-
- fieldtype = self.convertType(f.get_internal_type())
- if fieldtype is not None:
- field.type = fieldtype
- else:
- field.type = 'string'
-
- if not f.blank and not f.null:
- val = field.validators.add()
- val.name = "required"
- val.bool_value = True
-
- for v in f.validators:
- val = field.validators.add()
- validator_name = v.__class__.__name__
- if 'function' in validator_name:
- validator_name = v.__name__
- validator_name = self.convertValidator(validator_name)
-
- if not validator_name:
- continue
-
- val.name = validator_name
- if hasattr(v, 'limit_value'):
- try:
- val.int_value = v.limit_value
- except TypeError:
- val.str_value = str(v.limit_value)
- else:
- val.bool_value = True
-
- if f.is_relation and f.related_model:
-
- if 'ContentType' in f.related_model.__name__:
- # ContentType is a Django internal
- continue
-
- field.name = field.name + '_id'
- field.relation.model = f.related_model.__name__
- field.relation.type = self.getRelationType(f)
-
- rel = modeldef.relations.add()
- rel.model = f.related_model.__name__
- rel.type = self.getRelationType(f)
return modeldefs
+
+if __name__=='__main__':
+ ystr = open('protos/modeldefs.yaml').read()
+ yaml_repr = yaml.load(ystr)
+
+ modeldefs = modeldefs_pb2.ModelDefs()
+ yaml_to_grpc(yaml_repr, modeldefs)
+ print modeldefs
+
diff --git a/xos/genx/targets/chameleon_list_test.xtarget b/xos/genx/targets/chameleon_list_test.xtarget
new file mode 100644
index 0000000..fcb02fb
--- /dev/null
+++ b/xos/genx/targets/chameleon_list_test.xtarget
@@ -0,0 +1,19 @@
+source /opt/xos/coreapi/tests/testconfig-chameleon.sh
+
+# test modeldefs
+curl -f --silent http://$HOSTNAME:8080/xosapi/v1/modeldefs > /dev/null
+if [[ $? -ne 0 ]]; then
+ echo fail modeldefs
+fi
+
+{% for object in proto.messages %}
+{%- if object.name!='XOSBase' -%}
+curl -f --silent http://$HOSTNAME:8080/xosapi/v1/{{ xproto_unquote(options.app_label) }}/{{ xproto_pluralize(object) | lower }} > /dev/null
+if [[ $? -ne 0 ]]; then
+ echo fail {{ object.name }}
+fi
+{%endif-%}
+{%- endfor %}
+
+echo "okay"
+
diff --git a/xos/genx/targets/django-split.xtarget b/xos/genx/targets/django-split.xtarget
index 28a1ea4..d170dde 100644
--- a/xos/genx/targets/django-split.xtarget
+++ b/xos/genx/targets/django-split.xtarget
@@ -2,7 +2,6 @@
{% for m in proto.messages %}{% if not m.options.skip_django -%}
{% if file_exists(xproto_base_name(m.name)|lower+'_header.py') -%}from {{xproto_base_name(m.name)|lower }}_header import *{%- else -%}from header import *{% endif %}
{% if file_exists(xproto_base_name(m.name)|lower+'_top.py') -%}{{ include_file(xproto_base_name(m.name)|lower+'_top.py') }} {% endif %}
-
{%- for l in m.links %}
{% if l.peer.name != m.name %}
diff --git a/xos/genx/targets/grpc_api.xtarget b/xos/genx/targets/grpc_api.xtarget
new file mode 100644
index 0000000..a0373a3
--- /dev/null
+++ b/xos/genx/targets/grpc_api.xtarget
@@ -0,0 +1,58 @@
+import base64
+import time
+from protos import xos_pb2
+from google.protobuf.empty_pb2 import Empty
+
+from django.contrib.auth import authenticate as django_authenticate
+from xos.exceptions import *
+from apihelper import XOSAPIHelperMixin, translate_exceptions
+
+class XosService(xos_pb2.xosServicer, XOSAPIHelperMixin):
+ def __init__(self, thread_pool):
+ self.thread_pool = thread_pool
+ XOSAPIHelperMixin.__init__(self)
+
+ def stop(self):
+ pass
+
+{% for object in proto.messages | sort(attribute='name') %}
+{%- if object.name!='XOSBase' %}
+ @translate_exceptions
+ def List{{ object.name }}(self, request, context):
+ user=self.authenticate(context)
+ model=self.get_model("{{ object.name }}")
+ return self.querysetToProto(model, model.objects.all())
+
+ @translate_exceptions
+ def Filter{{ object.name }}(self, request, context):
+ user=self.authenticate(context)
+ model=self.get_model("{{ object.name }}")
+ return self.filter(model, request)
+
+ @translate_exceptions
+ def Get{{ object.name }}(self, request, context):
+ user=self.authenticate(context)
+ model=self.get_model("{{ object.name }}")
+ return self.get(model, request.id)
+
+ @translate_exceptions
+ def Create{{ object.name }}(self, request, context):
+ user=self.authenticate(context)
+ model=self.get_model("{{ object.name }}")
+ return self.create(model, user, request)
+
+ @translate_exceptions
+ def Delete{{ object.name }}(self, request, context):
+ user=self.authenticate(context)
+ model=self.get_model("{{ object.name }}")
+ return self.delete(model, user, request.id)
+
+ @translate_exceptions
+ def Update{{ object.name }}(self, request, context):
+ user=self.authenticate(context)
+ model=self.get_model("{{ object.name }}")
+ return self.update(model, user, request.id, request, context)
+{%- endif %}
+{% endfor %}
+
+
diff --git a/xos/genx/targets/grpc_list_test.xtarget b/xos/genx/targets/grpc_list_test.xtarget
new file mode 100644
index 0000000..e968959
--- /dev/null
+++ b/xos/genx/targets/grpc_list_test.xtarget
@@ -0,0 +1,49 @@
+import grpc_client
+from grpc_client import Empty
+from testconfig import *
+
+c=grpc_client.InsecureClient("xos-core.cord.lab")
+
+{% for object in proto.messages %}
+{%- if object.name!='XOSBase' %}
+print "testing insecure List{{ object.name }}...",
+c.stub.List{{ object.name }}(Empty())
+print "Okay"
+{%- endif %}
+{%- endfor %}
+
+c=grpc_client.SecureClient("xos-core.cord.lab", username=USERNAME, password=PASSWORD)
+
+{% for object in proto.messages %}
+{%- if object.name!='XOSBase' %}
+print "testing basic secure List{{ object.name }}...",
+c.stub.List{{ object.name }}(Empty())
+print "Okay"
+{%- endif %}
+{%- endfor %}
+
+# now try to login
+c=grpc_client.InsecureClient("xos-core.cord.lab")
+lr=grpc_client.LoginRequest()
+lr.username=USERNAME
+lr.password=PASSWORD
+session=c.utility.Login(lr)
+
+c=grpc_client.SecureClient("xos-core.cord.lab", sessionid=session.sessionid)
+{% for object in proto.messages %}
+{%- if object.name!='XOSBase' %}
+print "testing session secure List{{ object.name }}...",
+c.stub.List{{ object.name }}(Empty())
+print "Okay"
+{%- endif %}
+{%- endfor %}
+
+c=grpc_client.SecureClient("xos-core.cord.lab", sessionid=session.sessionid)
+{% for object in proto.messages %}
+{%- if object.name!='XOSBase' %}
+print "testing session secure xos_orm.{{ object.name }}.objects.all() ...",
+c.xos_orm.{{ object.name }}.objects.all()
+print "Okay"
+{%- endif %}
+{%- endfor %}
+
diff --git a/xos/genx/targets/model-deps-graphviz.xtarget b/xos/genx/targets/model-deps-graphviz.xtarget
index 429c9f4..b855a4a 100644
--- a/xos/genx/targets/model-deps-graphviz.xtarget
+++ b/xos/genx/targets/model-deps-graphviz.xtarget
@@ -1,4 +1,4 @@
-digraph {{ context.app_name }} {
+digraph {{ context.app_label }} {
{%- for model in proto.messages %}
{%- for l in model.links %}
"{{ model.name }}" -> "{{ l.peer }}" [label="{{ l.src_port }}"];
diff --git a/xos/genx/targets/modeldefs.xtarget b/xos/genx/targets/modeldefs.xtarget
index b426b79..615a8cc 100644
--- a/xos/genx/targets/modeldefs.xtarget
+++ b/xos/genx/targets/modeldefs.xtarget
@@ -1,7 +1,7 @@
items:
{%- for m in proto.messages | sort(attribute='name') %}
{%- if m.name != 'XOSBase' %}
-- app: {{ xproto_unquote(xproto_first_non_empty([m.options.app_name, context.app_name, options.app_name])) }}
+- app: {{ xproto_unquote(xproto_first_non_empty([m.options.app_label, context.app_label, options.app_label])) }}
fields:
{%- set id_field = {'type':'int32', 'name':'id', 'options':{}} %}
{% for f in (xproto_base_fields(m, proto.message_table) + m.fields + [id_field]) | sort(attribute='name') -%}
diff --git a/xos/genx/targets/protoapi.xtarget b/xos/genx/targets/protoapi.xtarget
new file mode 100644
index 0000000..f375dae
--- /dev/null
+++ b/xos/genx/targets/protoapi.xtarget
@@ -0,0 +1,88 @@
+syntax = "proto3";
+
+package xos;
+
+import "google/protobuf/empty.proto";
+import "google/api/annotations.proto";
+import "common.proto";
+import "xosoptions.proto";
+
+// Note: all fields are wrapped in a "oneof". This causes proto3 to always send
+// fields that are set by the caller, regardless if they are set to a default
+// value. XOS uses this to know when to apply a default value.
+
+{% for object in proto.messages|sort(attribute='name') %}
+{% if object.name != 'XOSBase' -%}
+message {{ object.name }} {
+ {%- if object.name=='CordSubscriberRoot' %}
+ option (contentTypeId) = "rcord.{{ object.name | lower }}";
+ {%- else %}
+ option (contentTypeId) = "{{ xproto_unquote(xproto_first_non_empty([object.options.name, object.options.app_label, options.name, context.app_label])) }}.{{ object.name | lower }}";
+ {%- endif %}
+ {%- set id_field = {'type':'int32', 'name':'id', 'options':{}} -%}
+ {%- for field in (xproto_base_fields(object, proto.message_table) + object.fields + [id_field]) | sort(attribute='name')%}
+ oneof {{ field.name }}_present {
+ {{ xproto_api_type(field) }} {{ field.name }}{% if field.link -%}_id{% endif %} = {{ loop.index }}{{ xproto_api_opts(field) }};
+ }
+ {%- endfor -%}
+
+ {%- for ref in xproto_base_rlinks(object, proto.message_table) + object.rlinks | sort(attribute='src_port') %}
+ {%- if '+' not in ref.src_port and '+' not in ref.dst_port %}
+ repeated int32 {{ ref.src_port }}_ids = {{ loop.index + 100 }} [(reverseForeignKey).modelName = "{{ ref.peer.name }}"];
+ {%- endif -%}
+ {%- endfor %}
+ string class_names = 201;
+ string self_content_type_id = 202;
+}
+
+message {{ xproto_pluralize(object) }} {
+ repeated {{ object.name }} items = 1;
+}
+
+{%- endif %}
+{% endfor %}
+
+service xos {
+{% for object in proto.messages | sort(attribute='name')%}
+{% if object.name != 'XOSBase' -%}
+ rpc List{{ object.name }}(google.protobuf.Empty) returns ({{ xproto_pluralize(object) }}) {
+ option (google.api.http) = {
+ {%- if object.name=='CordSubscriberRoot' %}
+ get: "/xosapi/v1/rcord/{{ xproto_pluralize(object) | lower }}"
+ {%- else %}
+ get: "/xosapi/v1/{{ xproto_unquote(xproto_first_non_empty([object.options.name, object.options.app_label, options.name, context.app_label])) }}/{{ xproto_pluralize(object) | lower }}"
+ {%- endif %}
+ };
+ }
+ rpc Filter{{ object.name }}(Query) returns ({{ xproto_pluralize(object) }}) {
+ }
+ rpc Get{{ object.name }}(ID) returns ({{ object.name }}) {
+ option (google.api.http) = {
+ {%- if object.name=='CordSubscriberRoot' %}
+ get: "/xosapi/v1/rcord/{{ xproto_pluralize(object) | lower }}/{id}"
+ {%- else %}
+ get: "/xosapi/v1/{{ xproto_unquote(xproto_first_non_empty([object.options.name, object.options.app_label, options.name, context.app_label])) }}/{{ xproto_pluralize(object) | lower }}/{id}"
+ {%- endif %}
+ };
+ }
+ rpc Create{{ object.name }}({{ object.name }}) returns ({{ object.name }}) {
+ option (google.api.http) = {
+ post: "/xosapi/v1/{{ xproto_unquote(xproto_first_non_empty([object.options.name, object.options.app_label, options.name, context.app_label])) }}/{{ xproto_pluralize(object) | lower }}"
+ body: "*"
+ };
+ }
+ rpc Update{{ object.name }}({{ object.name }}) returns ({{ object.name }}) {
+ option (google.api.http) = {
+ put: "/xosapi/v1/{{ xproto_unquote(xproto_first_non_empty([object.options.name, object.options.app_label, options.name, context.app_label])) }}/{{ xproto_pluralize(object) | lower }}/{id}"
+ body: "*"
+ };
+ }
+ rpc Delete{{ object.name }}(ID) returns (google.protobuf.Empty) {
+ option (google.api.http) = {
+ delete: "/xosapi/v1/{{ xproto_unquote(xproto_first_non_empty([object.options.name, object.options.app_label, options.name, context.app_label])) }}/{{ xproto_pluralize(object) | lower }}/{id}"
+ };
+ }
+{%- endif %}
+{% endfor %}
+}
+
diff --git a/xos/genx/tool/generator.py b/xos/genx/tool/generator.py
index 9e78673..ca06ee8 100755
--- a/xos/genx/tool/generator.py
+++ b/xos/genx/tool/generator.py
@@ -89,6 +89,7 @@
rendered = template.render({"proto": {'message_table':v.models, 'messages':v.messages, 'message_names':[m['name'] for m in v.messages]},"context":context,"options":v.options})
lines = rendered.splitlines()
+
current_buffer = []
for l in lines:
if (l.startswith('+++')):
diff --git a/xos/genx/tool/lib.py b/xos/genx/tool/lib.py
index ed55134..43c1f65 100644
--- a/xos/genx/tool/lib.py
+++ b/xos/genx/tool/lib.py
@@ -23,6 +23,16 @@
return singular
+def xproto_singularize_pluralize(field):
+ try:
+ # The user has set a plural, as an exception that cannot be handled automatically
+ plural = field['options']['plural']
+ plural = unquote(plural)
+ except KeyError:
+ plural = en.pluralize(en.singularize(field['name']))
+
+ return plural
+
def xproto_pluralize(field):
try:
# The user has set a plural, as an exception that cannot be handled automatically
@@ -255,6 +265,20 @@
return fields
+def xproto_base_rlinks(m, table):
+ links = []
+
+ for base in m['bases']:
+ b = base['name']
+ if b in table:
+ base_rlinks = xproto_base_rlinks(table[b], table)
+
+ model_rlinks = table[b]['rlinks']
+ links.extend(base_rlinks)
+ links.extend(model_rlinks)
+
+ return links
+
def xproto_base_links(m, table):
links = []
@@ -278,7 +302,7 @@
for v0, v1 in bound_validators:
try:
- validators.append({'name':v1, 'int_value':f['options'][v0]})
+ validators.append({'name':v1, 'int_value':int(f['options'][v0])})
except KeyError:
pass
@@ -385,6 +409,23 @@
return components
+def xproto_api_opts(field):
+ options = []
+ if 'max_length' in field['options'] and field['type']=='string':
+ options.append('(val).maxLength = %s'%field['options']['max_length'])
+ try:
+ if field['options']['null'] == 'False':
+ options.append('(val).nonNull = true')
+ except KeyError:
+ pass
+ if 'link' in field and 'model' in field['options']:
+ options.append('(foreignKey).modelName = "%s"'%field['options']['model'])
+ if options:
+ options_str = '[' + ', '.join(options) + ']'
+ else:
+ options_str = ''
+
+ return options_str
diff --git a/xos/genx/tool/xos2jinja.py b/xos/genx/tool/xos2jinja.py
index 162293f..a798fec 100644
--- a/xos/genx/tool/xos2jinja.py
+++ b/xos/genx/tool/xos2jinja.py
@@ -37,7 +37,7 @@
count+=1
return count
-def compute_rlinks(messages):
+def compute_rlinks(messages, message_dict):
rev_links = {}
link_opposite = {
@@ -69,6 +69,7 @@
for m in messages:
try:
m['rlinks'] = rev_links[m['name']]
+ message_dict[m['name']]['rlinks'] = m['rlinks']
except KeyError:
pass
@@ -283,15 +284,16 @@
else:
model_name = obj.name.value.pval
- model_def = {'name':obj.name.value.pval,'fields':fields,'links':links, 'bases':obj.bases, 'options':self.message_options, 'package':self.package, 'fqn': model_name}
+ model_def = {'name':obj.name.value.pval,'fields':fields,'links':links, 'bases':obj.bases, 'options':self.message_options, 'package':self.package, 'fqn': model_name, 'rlinks': []}
self.stack.push(model_def)
+
self.models[model_name] = model_def
# Set message options
for k,v in self.options.iteritems():
try:
- if k not in self.message_options.setdefault(self.current_message_name,{}):
- self.message_options[self.current_message_name][k] = v
+ if k not in self.message_options:
+ self.message_options[k] = v
except KeyError:
pass
@@ -335,7 +337,8 @@
messages.insert(0,m)
- compute_rlinks(messages)
+ compute_rlinks(messages, self.models)
+
self.messages = messages
return True