diff --git a/VERSION b/VERSION
index 7d2ed7c..cd57a8b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.1.4
+2.1.5
diff --git a/containers/chameleon/Dockerfile.chameleon b/containers/chameleon/Dockerfile.chameleon
index f7ba11b..09db322 100644
--- a/containers/chameleon/Dockerfile.chameleon
+++ b/containers/chameleon/Dockerfile.chameleon
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/chameleon
-FROM xosproject/xos-base:2.1.4
+FROM xosproject/xos-base:2.1.5
 
 # xos-base already has protoc and dependencies installed
 
diff --git a/containers/xos/Dockerfile.client b/containers/xos/Dockerfile.client
index 9aa9f1b..27c5d21 100644
--- a/containers/xos/Dockerfile.client
+++ b/containers/xos/Dockerfile.client
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-client
-FROM xosproject/xos-libraries:2.1.4
+FROM xosproject/xos-libraries:2.1.5
 
 # Install XOS client
 COPY xos/xos_client /tmp/xos_client
diff --git a/containers/xos/Dockerfile.libraries b/containers/xos/Dockerfile.libraries
index dfe651b..ff99c9a 100644
--- a/containers/xos/Dockerfile.libraries
+++ b/containers/xos/Dockerfile.libraries
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM xosproject/xos-base:2.1.4
+FROM xosproject/xos-base:2.1.5
 
 # Add libraries
 COPY lib /opt/xos/lib
diff --git a/containers/xos/Dockerfile.synchronizer-base b/containers/xos/Dockerfile.synchronizer-base
index fad65c4..fc3d417 100644
--- a/containers/xos/Dockerfile.synchronizer-base
+++ b/containers/xos/Dockerfile.synchronizer-base
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-synchronizer-base
-FROM xosproject/xos-client:2.1.4
+FROM xosproject/xos-client:2.1.5
 
 COPY xos/synchronizers/new_base /opt/xos/synchronizers/new_base
 COPY xos/xos/logger.py /opt/xos/xos/logger.py
diff --git a/containers/xos/Dockerfile.xos-core b/containers/xos/Dockerfile.xos-core
index 2d6909d..c7df46a 100644
--- a/containers/xos/Dockerfile.xos-core
+++ b/containers/xos/Dockerfile.xos-core
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-core
-FROM xosproject/xos-libraries:2.1.4
+FROM xosproject/xos-libraries:2.1.5
 
 # Install XOS
 ADD xos /opt/xos
diff --git a/lib/xos-config/xosconfig/default.py b/lib/xos-config/xosconfig/default.py
index 2c4e6d9..2c73b26 100644
--- a/lib/xos-config/xosconfig/default.py
+++ b/lib/xos-config/xosconfig/default.py
@@ -47,7 +47,6 @@
         'kind': 'grpcapi',
     },
     'keep_temp_files': False,
-    'enable_watchers': False,
     'dependency_graph': None,
     'error_map_path': '/opt/xos/error_map.txt',
     'feefie': {
diff --git a/lib/xos-config/xosconfig/synchronizer-config-schema.yaml b/lib/xos-config/xosconfig/synchronizer-config-schema.yaml
index a9ae095..532ca3c 100644
--- a/lib/xos-config/xosconfig/synchronizer-config-schema.yaml
+++ b/lib/xos-config/xosconfig/synchronizer-config-schema.yaml
@@ -105,8 +105,6 @@
         type: str
       user:
         type: str
-  enable_watchers:
-    type: bool
   model_policies_dir:
     type: str
   error_map_path:
diff --git a/xos/synchronizers/new_base/SyncInstanceUsingAnsible.py b/xos/synchronizers/new_base/SyncInstanceUsingAnsible.py
index 5690b93..2120e0e 100644
--- a/xos/synchronizers/new_base/SyncInstanceUsingAnsible.py
+++ b/xos/synchronizers/new_base/SyncInstanceUsingAnsible.py
@@ -293,92 +293,3 @@
         if hasattr(self, "map_delete_outputs"):
             self.map_delete_outputs(o, res)
 
-    # In order to enable the XOS watcher functionality for a synchronizer, define the 'watches' attribute
-    # in the derived class: eg. watches = [ModelLink(ServiceDependency,via='servicedependency')]
-    # This base class implements the notification handler for handling ServiceDependency model notifications
-    # If a synchronizer need to watch on multiple objects, the additional handlers need to be implemented
-    # in the derived class and override the below handle_watched_object() method to route the notifications
-    # accordingly
-    def handle_watched_object(self, o):
-        log.info("handle_watched_object is invoked for object",object = str(o), **o.tologdict())
-        if (model_accessor.is_type(o, "ServiceDependency")):
-            self.handle_service_composition_watch_notification(o)
-        elif (model_accessor.is_type(o, "ServiceMonitoringAgentInfo")):
-            self.handle_service_monitoringagentinfo_watch_notification(o)
-        pass
-
-    def handle_service_composition_watch_notification(self, coarse_tenant):
-        cls_obj = self.observes
-        if (type(cls_obj) is list):
-            cls_obj = cls_obj[0]
-        log.info("handle_watched_object observed model", model = cls_obj)
-
-        objs = cls_obj.objects.filter(kind=cls_obj.KIND)
-
-        for obj in objs:
-            self.handle_service_composition_for_object(obj, coarse_tenant)
-
-    def handle_service_monitoringagentinfo_watch_notification(self, monitoring_agent_info):
-        pass
-
-    def handle_service_composition_for_object(self, obj, coarse_tenant):
-        try:
-            instance = self.get_instance(obj)
-            valid_instance = True
-        except:
-            valid_instance = False
-
-        if not valid_instance:
-            log.warn("handle_watched_object: No valid instance found for object", object =str(obj))
-            return
-
-        provider_service = coarse_tenant.provider_service
-        subscriber_service = coarse_tenant.subscriber_service
-
-        if model_accessor.is_instance(obj, "Service"):
-            if obj.id == provider_service.id:
-                matched_service = provider_service
-                other_service = subscriber_service
-            elif obj.id == subscriber_service.id:
-                matched_service = subscriber_service
-                other_service = provider_service
-            else:
-                log.info("handle_watched_object: Service object does not match with any of composed services", 
-                object = str(obj))
-                return
-        elif model_accessor.is_instance(obj, "Tenant"):
-            if obj.provider_service.id == provider_service.id:
-                matched_service = provider_service
-                other_service = subscriber_service
-            elif obj.provider_service.id == subscriber_service.id:
-                matched_service = subscriber_service
-                other_service = provider_service
-            else:
-                log.info(
-                    "handle_watched_object: Tenant object does not match with any of composed services", object = str(obj))
-                return
-        else:
-            log.warn("handle_watched_object: Model object is of neither Service nor Tenant type", object = str(obj))
-
-        src_networks = matched_service.get_composable_networks()
-        target_networks = other_service.get_composable_networks()
-        if src_networks and target_networks:
-            src_network = src_networks[0]  # Only one composable network should present per service
-            target_network = target_networks[0]
-            src_ip = instance.get_network_ip(src_network.name)
-            target_subnet = target_network.controllernetworks.all()[0].subnet
-
-            # Run ansible playbook to update the routing table entries in the instance
-            fields = self.get_ansible_fields(instance)
-            fields["ansible_tag"] = getattr(obj, "ansible_tag",
-                                            obj.__class__.__name__ + "_" + str(obj.id)) + "_service_composition"
-            fields["src_intf_ip"] = src_ip
-            fields["target_subnet"] = target_subnet
-            # Template file is available under .../synchronizers/shared_templates
-            service_composition_template_name = "sync_service_composition.yaml"
-            log.info(
-                "handle_watched_object: Updating routing tables in the instance associated with object. target_subnet:%s src_ip:%s",
-                object = str(obj), subnet = target_subnet, ip = src_ip)
-            SyncInstanceUsingAnsible.run_playbook(self, obj, fields, service_composition_template_name)
-        else:
-            log.info("handle_watched_object: No intersection of composable networks between composed services", object = str(coarse_tenant))
diff --git a/xos/synchronizers/new_base/backend.py b/xos/synchronizers/new_base/backend.py
index dd312fb..1d8df0f 100644
--- a/xos/synchronizers/new_base/backend.py
+++ b/xos/synchronizers/new_base/backend.py
@@ -1,4 +1,3 @@
-
 # Copyright 2017-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 import os
 import inspect
 import imp
@@ -32,11 +30,6 @@
 
 log = create_logger(Config().get('logging'))
 
-watchers_enabled = Config.get("enable_watchers")
-
-if (watchers_enabled):
-    from synchronizers.new_base.watchers import XOSWatcher
-
 
 class Backend:
 
@@ -82,7 +75,6 @@
 
     def run(self):
         observer_thread = None
-        watcher_thread = None
         model_policy_thread = None
         event_engine = None
 
@@ -102,14 +94,8 @@
                 observer_thread = threading.Thread(target=observer.run,name='synchronizer')
                 observer_thread.start()
 
-                # start the watcher thread
-                if (watchers_enabled):
-                    self.log.info("Starting XOSWatcher", sync_steps=sync_steps)
-                    watcher = XOSWatcher(sync_steps)
-                    watcher_thread = threading.Thread(target=watcher.run,name='watcher')
-                    watcher_thread.start()
         else:
-            self.log.info("Skipping observer and watcher threads due to no steps dir.")
+            self.log.info("Skipping observer thread due to no steps dir.")
 
         pull_steps_dir = Config.get("pull_steps_dir")
         if pull_steps_dir:
@@ -140,7 +126,7 @@
         else:
             self.log.info("Skipping model policies thread due to no model_policies dir.")
 
-        if (not observer_thread) and (not watcher_thread) and (not model_policy_thread) and (not event_engine):
+        if (not observer_thread) and (not model_policy_thread) and (not event_engine):
             self.log.info("No sync steps, no policies, and no event steps. Synchronizer exiting.")
             # the caller will exit with status 0
             return
@@ -153,8 +139,6 @@
                 # TODO: See about setting the threads as daemons
                 if observer_thread:
                     observer_thread._Thread__stop()
-                if watcher_thread:
-                    watcher_thread._Thread__stop()
                 if model_policy_thread:
                     model_policy_thread._Thread__stop()
                 sys.exit(1)
diff --git a/xos/synchronizers/new_base/backend_modelpolicy.py b/xos/synchronizers/new_base/backend_modelpolicy.py
index 58ef32f..792730c 100644
--- a/xos/synchronizers/new_base/backend_modelpolicy.py
+++ b/xos/synchronizers/new_base/backend_modelpolicy.py
@@ -1,4 +1,3 @@
-
 # Copyright 2017-present Open Networking Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 import os
 import inspect
 import imp
@@ -28,11 +26,6 @@
 
 log = create_logger(Config().get('logging'))
 
-watchers_enabled = Config.get("enable_watchers")
-
-# NOTE is this used or can be removed?
-if (watchers_enabled):
-    from synchronizers.new_base.watchers import XOSWatcher
 
 class Backend:
     def run(self):
diff --git a/xos/synchronizers/new_base/watchers.py b/xos/synchronizers/new_base/watchers.py
deleted file mode 100644
index 5794f83..0000000
--- a/xos/synchronizers/new_base/watchers.py
+++ /dev/null
@@ -1,99 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-import os
-import inspect
-import imp
-import time
-import sys
-import traceback
-import commands
-import threading
-import json
-import pprint
-import traceback
-
-from datetime import datetime
-from collections import defaultdict
-
-from syncstep import SyncStep
-from synchronizers.new_base.error_mapper import *
-import redis
-
-from xosconfig import Config
-from multistructlog import create_logger
-
-log = create_logger(Config().get('logging'))
-
-class XOSWatcher:
-    def load_sync_step_modules(self, step_dir=None):
-        if step_dir is None:
-            step_dir = Config.get("steps_dir")
-
-        for fn in os.listdir(step_dir):
-            pathname = os.path.join(step_dir, fn)
-            if os.path.isfile(pathname) and fn.endswith(".py") and (fn != "__init__.py"):
-                module = imp.load_source(fn[:-3], pathname)
-                for classname in dir(module):
-                    c = getattr(module, classname, None)
-
-                    # make sure 'c' is a descendent of SyncStep and has a
-                    # provides field (this eliminates the abstract base classes
-                    # since they don't have a provides)
-
-                    if inspect.isclass(c) and issubclass(c, SyncStep) and hasattr(c, "provides") and (
-                        c not in self.sync_steps):
-                        self.sync_steps.append(c)
-
-    def load_sync_steps(self):
-        for s in self.sync_steps:
-            if hasattr(s, 'watches'):
-                for w in s.watches:
-                    w.source = s
-                    try:
-                        self.watch_map[w.dest.__name__].append(w)
-                    except:
-                        self.watch_map[w.dest.__name__] = [w]
-
-    def __init__(self, sync_steps):
-        self.watch_map = {}
-        self.sync_steps = sync_steps
-        # self.load_sync_step_modules()
-        self.load_sync_steps()
-        r = redis.Redis("redis")
-        channels = self.watch_map.keys()
-        self.redis = r
-        self.pubsub = self.redis.pubsub()
-        self.pubsub.subscribe(channels)
-        log.info("XOS watcher initialized")
-
-    def run(self):
-        for item in self.pubsub.listen():
-            channel = item['channel']
-            try:
-                entry = self.watch_map[channel]
-                data = json.loads(item['data'])
-                pk = data['pk']
-                changed_fields = data['changed_fields']
-                for w in entry:
-                    if w.into in changed_fields or not w.into:
-                        if (hasattr(w.source, 'handle_watched_object')):
-                            o = w.dest.objects.get(pk=data['pk'])
-                            step = w.source()
-                            step.handle_watched_object(o)
-            except Exception as e:
-                log.exception("XOS watcher: exception while processing object", e = e)
-                pass
diff --git a/xos/tools/wait_for_object_creation.py b/xos/tools/wait_for_object_creation.py
deleted file mode 100755
index f98f626..0000000
--- a/xos/tools/wait_for_object_creation.py
+++ /dev/null
@@ -1,51 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-import os
-import sys
-sys.path.append("/opt/xos")
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
-import django
-from core.models import *
-from services.hpc.models import *
-from services.volt.models import *
-from services.vsg.models import *
-import time
-django.setup()
-
-def main():
-    printed = False
-
-    if len(sys.argv)!=4:
-        print >> sys.stderr, "syntax: wait_for_object_creation.py <class> <filter_field_name> <filter_field_value>"
-        print >> sys.stderr, "example: wait_for_object_creation.py Image name vsg-1.0"
-        sys.exit(-1)
-
-    cls = globals()[sys.argv[1]]
-
-    while True:
-        objs = cls.objects.filter(**{sys.argv[2]: sys.argv[3]})
-        if objs:
-            print "Object", objs[0], "is ready"
-            return
-        if not printed:
-            print "Waiting for %s with field %s=%s to be created" % (sys.argv[1], sys.argv[2], sys.argv[3])
-            printed=True
-        time.sleep(1)
-
-if __name__ == "__main__":
-   main()
-
diff --git a/xos/xos/hpcapi.py b/xos/xos/hpcapi.py
deleted file mode 100644
index 3e10955..0000000
--- a/xos/xos/hpcapi.py
+++ /dev/null
@@ -1,873 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-from rest_framework.decorators import api_view
-from rest_framework.response import Response
-from rest_framework.reverse import reverse
-from rest_framework import serializers
-from rest_framework import generics
-from rest_framework import status
-from rest_framework.generics import GenericAPIView
-from services.hpc.models import *
-from django.forms import widgets
-from rest_framework import filters
-from django.conf.urls import patterns, url
-from rest_framework.exceptions import PermissionDenied as RestFrameworkPermissionDenied
-from django.core.exceptions import PermissionDenied as DjangoPermissionDenied
-from apibase import XOSRetrieveUpdateDestroyAPIView, XOSListCreateAPIView, XOSNotAuthenticated
-
-if hasattr(serializers, "ReadOnlyField"):
-    # rest_framework 3.x
-    IdField = serializers.ReadOnlyField
-else:
-    # rest_framework 2.x
-    IdField = serializers.Field
-
-"""
-    Schema of the generator object:
-        all: Set of all Model objects
-        all_if(regex): Set of Model objects that match regex
-
-    Model object:
-        plural: English plural of object name
-        camel: CamelCase version of object name
-        refs: list of references to other Model objects
-        props: list of properties minus refs
-
-    TODO: Deal with subnets
-"""
-
-def get_hpc_REST_patterns():
-    return patterns('',
-        url(r'^hpcapi/$', hpc_api_root_legacy),
-    # legacy - deprecated
-    
-        url(r'hpcapi/hpchealthchecks/$', HpcHealthCheckList.as_view(), name='hpchealthcheck-list-legacy'),
-        url(r'hpcapi/hpchealthchecks/(?P<pk>[a-zA-Z0-9\-]+)/$', HpcHealthCheckDetail.as_view(), name ='hpchealthcheck-detail-legacy'),
-    
-        url(r'hpcapi/hpcservices/$', HpcServiceList.as_view(), name='hpcservice-list-legacy'),
-        url(r'hpcapi/hpcservices/(?P<pk>[a-zA-Z0-9\-]+)/$', HpcServiceDetail.as_view(), name ='hpcservice-detail-legacy'),
-    
-        url(r'hpcapi/originservers/$', OriginServerList.as_view(), name='originserver-list-legacy'),
-        url(r'hpcapi/originservers/(?P<pk>[a-zA-Z0-9\-]+)/$', OriginServerDetail.as_view(), name ='originserver-detail-legacy'),
-    
-        url(r'hpcapi/cdnprefixs/$', CDNPrefixList.as_view(), name='cdnprefix-list-legacy'),
-        url(r'hpcapi/cdnprefixs/(?P<pk>[a-zA-Z0-9\-]+)/$', CDNPrefixDetail.as_view(), name ='cdnprefix-detail-legacy'),
-    
-        url(r'hpcapi/serviceproviders/$', ServiceProviderList.as_view(), name='serviceprovider-list-legacy'),
-        url(r'hpcapi/serviceproviders/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceProviderDetail.as_view(), name ='serviceprovider-detail-legacy'),
-    
-        url(r'hpcapi/contentproviders/$', ContentProviderList.as_view(), name='contentprovider-list-legacy'),
-        url(r'hpcapi/contentproviders/(?P<pk>[a-zA-Z0-9\-]+)/$', ContentProviderDetail.as_view(), name ='contentprovider-detail-legacy'),
-    
-        url(r'hpcapi/accessmaps/$', AccessMapList.as_view(), name='accessmap-list-legacy'),
-        url(r'hpcapi/accessmaps/(?P<pk>[a-zA-Z0-9\-]+)/$', AccessMapDetail.as_view(), name ='accessmap-detail-legacy'),
-    
-        url(r'hpcapi/sitemaps/$', SiteMapList.as_view(), name='sitemap-list-legacy'),
-        url(r'hpcapi/sitemaps/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteMapDetail.as_view(), name ='sitemap-detail-legacy'),
-    
-    # new api - use these
-        url(r'^api/service/hpc/$', hpc_api_root),
-    
-        url(r'api/service/hpc/hpchealthchecks/$', HpcHealthCheckList.as_view(), name='hpchealthcheck-list'),
-        url(r'api/service/hpc/hpchealthchecks/(?P<pk>[a-zA-Z0-9\-]+)/$', HpcHealthCheckDetail.as_view(), name ='hpchealthcheck-detail'),
-    
-        url(r'api/service/hpc/hpcservices/$', HpcServiceList.as_view(), name='hpcservice-list'),
-        url(r'api/service/hpc/hpcservices/(?P<pk>[a-zA-Z0-9\-]+)/$', HpcServiceDetail.as_view(), name ='hpcservice-detail'),
-    
-        url(r'api/service/hpc/originservers/$', OriginServerList.as_view(), name='originserver-list'),
-        url(r'api/service/hpc/originservers/(?P<pk>[a-zA-Z0-9\-]+)/$', OriginServerDetail.as_view(), name ='originserver-detail'),
-    
-        url(r'api/service/hpc/cdnprefixs/$', CDNPrefixList.as_view(), name='cdnprefix-list'),
-        url(r'api/service/hpc/cdnprefixs/(?P<pk>[a-zA-Z0-9\-]+)/$', CDNPrefixDetail.as_view(), name ='cdnprefix-detail'),
-    
-        url(r'api/service/hpc/serviceproviders/$', ServiceProviderList.as_view(), name='serviceprovider-list'),
-        url(r'api/service/hpc/serviceproviders/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceProviderDetail.as_view(), name ='serviceprovider-detail'),
-    
-        url(r'api/service/hpc/contentproviders/$', ContentProviderList.as_view(), name='contentprovider-list'),
-        url(r'api/service/hpc/contentproviders/(?P<pk>[a-zA-Z0-9\-]+)/$', ContentProviderDetail.as_view(), name ='contentprovider-detail'),
-    
-        url(r'api/service/hpc/accessmaps/$', AccessMapList.as_view(), name='accessmap-list'),
-        url(r'api/service/hpc/accessmaps/(?P<pk>[a-zA-Z0-9\-]+)/$', AccessMapDetail.as_view(), name ='accessmap-detail'),
-    
-        url(r'api/service/hpc/sitemaps/$', SiteMapList.as_view(), name='sitemap-list'),
-        url(r'api/service/hpc/sitemaps/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteMapDetail.as_view(), name ='sitemap-detail'),
-    
-    )
-
-@api_view(['GET'])
-def hpc_api_root_legacy(request, format=None):
-    return Response({
-        'hpchealthchecks': reverse('hpchealthcheck-list-legacy', request=request, format=format),
-        'hpcservices': reverse('hpcservice-list-legacy', request=request, format=format),
-        'originservers': reverse('originserver-list-legacy', request=request, format=format),
-        'cdnprefixs': reverse('cdnprefix-list-legacy', request=request, format=format),
-        'serviceproviders': reverse('serviceprovider-list-legacy', request=request, format=format),
-        'contentproviders': reverse('contentprovider-list-legacy', request=request, format=format),
-        'accessmaps': reverse('accessmap-list-legacy', request=request, format=format),
-        'sitemaps': reverse('sitemap-list-legacy', request=request, format=format),
-        
-    })
-
-@api_view(['GET'])
-def hpc_api_root(request, format=None):
-    return Response({
-        'hpchealthchecks': reverse('hpchealthcheck-list', request=request, format=format),
-        'hpcservices': reverse('hpcservice-list', request=request, format=format),
-        'originservers': reverse('originserver-list', request=request, format=format),
-        'cdnprefixs': reverse('cdnprefix-list', request=request, format=format),
-        'serviceproviders': reverse('serviceprovider-list', request=request, format=format),
-        'contentproviders': reverse('contentprovider-list', request=request, format=format),
-        'accessmaps': reverse('accessmap-list', request=request, format=format),
-        'sitemaps': reverse('sitemap-list', request=request, format=format),
-        
-    })
-
-# Based on serializers.py
-
-class XOSModelSerializer(serializers.ModelSerializer):
-    def save_object(self, obj, **kwargs):
-
-        """ rest_framework can't deal with ManyToMany relations that have a
-            through table. In xos, most of the through tables we have
-            use defaults or blank fields, so there's no reason why we shouldn't
-            be able to save these objects.
-
-            So, let's strip out these m2m relations, and deal with them ourself.
-        """
-        obj._complex_m2m_data={};
-        if getattr(obj, '_m2m_data', None):
-            for relatedObject in obj._meta.get_all_related_many_to_many_objects():
-                if (relatedObject.field.rel.through._meta.auto_created):
-                    # These are non-trough ManyToMany relations and
-                    # can be updated just fine
-                    continue
-                fieldName = relatedObject.get_accessor_name()
-                if fieldName in obj._m2m_data.keys():
-                    obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
-                    del obj._m2m_data[fieldName]
-
-        serializers.ModelSerializer.save_object(self, obj, **kwargs);
-
-        for (accessor, stuff) in obj._complex_m2m_data.items():
-            (relatedObject, data) = stuff
-            through = relatedObject.field.rel.through
-            local_fieldName = relatedObject.field.m2m_reverse_field_name()
-            remote_fieldName = relatedObject.field.m2m_field_name()
-
-            # get the current set of existing relations
-            existing = through.objects.filter(**{local_fieldName: obj});
-
-            data_ids = [item.id for item in data]
-            existing_ids = [getattr(item,remote_fieldName).id for item in existing]
-
-            #print "data_ids", data_ids
-            #print "existing_ids", existing_ids
-
-            # remove relations that are in 'existing' but not in 'data'
-            for item in list(existing):
-               if (getattr(item,remote_fieldName).id not in data_ids):
-                   print "delete", getattr(item,remote_fieldName)
-                   item.delete() #(purge=True)
-
-            # add relations that are in 'data' but not in 'existing'
-            for item in data:
-               if (item.id not in existing_ids):
-                   #print "add", item
-                   newModel = through(**{local_fieldName: obj, remote_fieldName: item})
-                   newModel.save()
-
-
-
-class HpcHealthCheckSerializer(serializers.HyperlinkedModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = HpcHealthCheck
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','hpcService','kind','resource_name','result_contains','result_min_size','result_max_size',)
-
-class HpcHealthCheckIdSerializer(XOSModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = HpcHealthCheck
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','hpcService','kind','resource_name','result_contains','result_min_size','result_max_size',)
-
-
-
-
-class HpcServiceSerializer(serializers.HyperlinkedModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = HpcService
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','description','enabled','kind','name','versionNumber','published','view_url','icon_url','public_key','private_key_fn','service_specific_id','service_specific_attribute','cmi_hostname','hpc_port80','watcher_hpc_network','watcher_dnsdemux_network','watcher_dnsredir_network',)
-
-class HpcServiceIdSerializer(XOSModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = HpcService
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','description','enabled','kind','name','versionNumber','published','view_url','icon_url','public_key','private_key_fn','service_specific_id','service_specific_attribute','cmi_hostname','hpc_port80','watcher_hpc_network','watcher_dnsdemux_network','watcher_dnsredir_network',)
-
-
-
-
-class OriginServerSerializer(serializers.HyperlinkedModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = OriginServer
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','origin_server_id','url','contentProvider','authenticated','enabled','protocol','redirects','description',)
-
-class OriginServerIdSerializer(XOSModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = OriginServer
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','origin_server_id','url','contentProvider','authenticated','enabled','protocol','redirects','description',)
-
-
-
-
-class CDNPrefixSerializer(serializers.HyperlinkedModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = CDNPrefix
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','cdn_prefix_id','prefix','contentProvider','description','defaultOriginServer','enabled',)
-
-class CDNPrefixIdSerializer(XOSModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = CDNPrefix
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','cdn_prefix_id','prefix','contentProvider','description','defaultOriginServer','enabled',)
-
-
-
-
-class ServiceProviderSerializer(serializers.HyperlinkedModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = ServiceProvider
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','hpcService','service_provider_id','name','description','enabled',)
-
-class ServiceProviderIdSerializer(XOSModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = ServiceProvider
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','hpcService','service_provider_id','name','description','enabled',)
-
-
-
-
-class ContentProviderSerializer(serializers.HyperlinkedModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = ContentProvider
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','content_provider_id','name','enabled','description','serviceProvider',)
-
-class ContentProviderIdSerializer(XOSModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = ContentProvider
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','content_provider_id','name','enabled','description','serviceProvider',)
-
-
-
-
-class AccessMapSerializer(serializers.HyperlinkedModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = AccessMap
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','contentProvider','name','description','map',)
-
-class AccessMapIdSerializer(XOSModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = AccessMap
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','contentProvider','name','description','map',)
-
-
-
-
-class SiteMapSerializer(serializers.HyperlinkedModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = SiteMap
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','contentProvider','serviceProvider','cdnPrefix','hpcService','name','description','map','map_id',)
-
-class SiteMapIdSerializer(XOSModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = SiteMap
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','contentProvider','serviceProvider','cdnPrefix','hpcService','name','description','map','map_id',)
-
-
-
-
-serializerLookUp = {
-
-                 HpcHealthCheck: HpcHealthCheckSerializer,
-
-                 HpcService: HpcServiceSerializer,
-
-                 OriginServer: OriginServerSerializer,
-
-                 CDNPrefix: CDNPrefixSerializer,
-
-                 ServiceProvider: ServiceProviderSerializer,
-
-                 ContentProvider: ContentProviderSerializer,
-
-                 AccessMap: AccessMapSerializer,
-
-                 SiteMap: SiteMapSerializer,
-
-                 None: None,
-                }
-
-# Based on core/views/*.py
-
-
-class HpcHealthCheckList(XOSListCreateAPIView):
-    queryset = HpcHealthCheck.objects.select_related().all()
-    serializer_class = HpcHealthCheckSerializer
-    id_serializer_class = HpcHealthCheckIdSerializer
-    filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','hpcService','kind','resource_name','result_contains','result_min_size','result_max_size',)
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return HpcHealthCheck.select_by_user(self.request.user)
-
-
-class HpcHealthCheckDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = HpcHealthCheck.objects.select_related().all()
-    serializer_class = HpcHealthCheckSerializer
-    id_serializer_class = HpcHealthCheckIdSerializer
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return HpcHealthCheck.select_by_user(self.request.user)
-
-    # update() is handled by XOSRetrieveUpdateDestroyAPIView
-
-    # destroy() is handled by XOSRetrieveUpdateDestroyAPIView
-
-
-
-class HpcServiceList(XOSListCreateAPIView):
-    queryset = HpcService.objects.select_related().all()
-    serializer_class = HpcServiceSerializer
-    id_serializer_class = HpcServiceIdSerializer
-    filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','description','enabled','kind','name','versionNumber','published','view_url','icon_url','public_key','private_key_fn','service_specific_id','service_specific_attribute','cmi_hostname','hpc_port80','watcher_hpc_network','watcher_dnsdemux_network','watcher_dnsredir_network',)
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return HpcService.select_by_user(self.request.user)
-
-
-class HpcServiceDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = HpcService.objects.select_related().all()
-    serializer_class = HpcServiceSerializer
-    id_serializer_class = HpcServiceIdSerializer
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return HpcService.select_by_user(self.request.user)
-
-    # update() is handled by XOSRetrieveUpdateDestroyAPIView
-
-    # destroy() is handled by XOSRetrieveUpdateDestroyAPIView
-
-
-
-class OriginServerList(XOSListCreateAPIView):
-    queryset = OriginServer.objects.select_related().all()
-    serializer_class = OriginServerSerializer
-    id_serializer_class = OriginServerIdSerializer
-    filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','origin_server_id','url','contentProvider','authenticated','enabled','protocol','redirects','description',)
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return OriginServer.select_by_user(self.request.user)
-
-
-class OriginServerDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = OriginServer.objects.select_related().all()
-    serializer_class = OriginServerSerializer
-    id_serializer_class = OriginServerIdSerializer
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return OriginServer.select_by_user(self.request.user)
-
-    # update() is handled by XOSRetrieveUpdateDestroyAPIView
-
-    # destroy() is handled by XOSRetrieveUpdateDestroyAPIView
-
-
-
-class CDNPrefixList(XOSListCreateAPIView):
-    queryset = CDNPrefix.objects.select_related().all()
-    serializer_class = CDNPrefixSerializer
-    id_serializer_class = CDNPrefixIdSerializer
-    filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','cdn_prefix_id','prefix','contentProvider','description','defaultOriginServer','enabled',)
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return CDNPrefix.select_by_user(self.request.user)
-
-
-class CDNPrefixDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = CDNPrefix.objects.select_related().all()
-    serializer_class = CDNPrefixSerializer
-    id_serializer_class = CDNPrefixIdSerializer
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return CDNPrefix.select_by_user(self.request.user)
-
-    # update() is handled by XOSRetrieveUpdateDestroyAPIView
-
-    # destroy() is handled by XOSRetrieveUpdateDestroyAPIView
-
-
-
-class ServiceProviderList(XOSListCreateAPIView):
-    queryset = ServiceProvider.objects.select_related().all()
-    serializer_class = ServiceProviderSerializer
-    id_serializer_class = ServiceProviderIdSerializer
-    filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','hpcService','service_provider_id','name','description','enabled',)
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return ServiceProvider.select_by_user(self.request.user)
-
-
-class ServiceProviderDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = ServiceProvider.objects.select_related().all()
-    serializer_class = ServiceProviderSerializer
-    id_serializer_class = ServiceProviderIdSerializer
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return ServiceProvider.select_by_user(self.request.user)
-
-    # update() is handled by XOSRetrieveUpdateDestroyAPIView
-
-    # destroy() is handled by XOSRetrieveUpdateDestroyAPIView
-
-
-
-class ContentProviderList(XOSListCreateAPIView):
-    queryset = ContentProvider.objects.select_related().all()
-    serializer_class = ContentProviderSerializer
-    id_serializer_class = ContentProviderIdSerializer
-    filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','content_provider_id','name','enabled','description','serviceProvider',)
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return ContentProvider.select_by_user(self.request.user)
-
-
-class ContentProviderDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = ContentProvider.objects.select_related().all()
-    serializer_class = ContentProviderSerializer
-    id_serializer_class = ContentProviderIdSerializer
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return ContentProvider.select_by_user(self.request.user)
-
-    # update() is handled by XOSRetrieveUpdateDestroyAPIView
-
-    # destroy() is handled by XOSRetrieveUpdateDestroyAPIView
-
-
-
-class AccessMapList(XOSListCreateAPIView):
-    queryset = AccessMap.objects.select_related().all()
-    serializer_class = AccessMapSerializer
-    id_serializer_class = AccessMapIdSerializer
-    filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','contentProvider','name','description','map',)
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return AccessMap.select_by_user(self.request.user)
-
-
-class AccessMapDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = AccessMap.objects.select_related().all()
-    serializer_class = AccessMapSerializer
-    id_serializer_class = AccessMapIdSerializer
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return AccessMap.select_by_user(self.request.user)
-
-    # update() is handled by XOSRetrieveUpdateDestroyAPIView
-
-    # destroy() is handled by XOSRetrieveUpdateDestroyAPIView
-
-
-
-class SiteMapList(XOSListCreateAPIView):
-    queryset = SiteMap.objects.select_related().all()
-    serializer_class = SiteMapSerializer
-    id_serializer_class = SiteMapIdSerializer
-    filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','contentProvider','serviceProvider','cdnPrefix','hpcService','name','description','map','map_id',)
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return SiteMap.select_by_user(self.request.user)
-
-
-class SiteMapDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = SiteMap.objects.select_related().all()
-    serializer_class = SiteMapSerializer
-    id_serializer_class = SiteMapIdSerializer
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return SiteMap.select_by_user(self.request.user)
-
-    # update() is handled by XOSRetrieveUpdateDestroyAPIView
-
-    # destroy() is handled by XOSRetrieveUpdateDestroyAPIView
-
-
