old_contents: from __future__ import absolute_import, unicode_literals
  import os
  from django.http import HttpResponse, JsonResponse
  from django.utils.decorators import method_decorator
  from django.views import View
  
  from corehq import toggles
  from corehq.apps.domain.decorators import api_auth
  from corehq.util.view_utils import absolute_reverse
  from io import open
  
  
  class ODataServiceView(View):
  
      @method_decorator(api_auth)
      @method_decorator(toggles.ODATA.required_decorator())
      def get(self, request, domain):
          data = {
              '@odata.context': absolute_reverse('odata_meta', args=[domain]),
              'value': [
                  {
                      'name': 'Cases',
                      'kind': 'EntitySet',
                      'url': 'Cases',
                  }
              ]
          }
          return add_odata_headers(JsonResponse(data))
  
  
  class ODataMetadataView(View):
  
      @method_decorator(api_auth)
      @method_decorator(toggles.ODATA.required_decorator())
      def get(self, request, domain):
          # todo: should generate this dynamically based on the domain / case schema / data dictionary
          data_file = os.path.join(os.path.dirname(__file__), 'metadata.xml')
          with open(data_file, 'r') as f:
              return add_odata_headers(HttpResponse(f.read(), content_type='application/xml'))
  
  
  def add_odata_headers(response):
      response['OData-Version'] = '4.0'
      return response
  
new_contents: from __future__ import absolute_import, unicode_literals
  import os
  from django.http import HttpResponse, JsonResponse
  from django.utils.decorators import method_decorator
  from django.views import View
  
  from corehq import toggles
  from corehq.apps.domain.decorators import api_auth
  from corehq.apps.reports.analytics.esaccessors import get_case_types_for_domain_es
  from corehq.util.view_utils import absolute_reverse
  from io import open
  
  
  class ODataServiceView(View):
  
      @method_decorator(api_auth)
      @method_decorator(toggles.ODATA.required_decorator())
      def get(self, request, domain):
          data = {
              '@odata.context': absolute_reverse('odata_meta', args=[domain]),
              'value': [
                  {
                      'name': case_type,
                      'kind': 'EntitySet',
                      'url': case_type,
                  }
                  for case_type in get_case_types_for_domain_es(domain)
              ]
          }
          return add_odata_headers(JsonResponse(data))
  
  
  class ODataMetadataView(View):
  
      @method_decorator(api_auth)
      @method_decorator(toggles.ODATA.required_decorator())
      def get(self, request, domain):
          # todo: should generate this dynamically based on the domain / case schema / data dictionary
          data_file = os.path.join(os.path.dirname(__file__), 'metadata.xml')
          with open(data_file, 'r') as f:
              return add_odata_headers(HttpResponse(f.read(), content_type='application/xml'))
  
  
  def add_odata_headers(response):
      response['OData-Version'] = '4.0'
      return response
  
subject: include case types in service response