<s> from __future__ import unicode_literals <EOL> from collections import namedtuple , OrderedDict <EOL> import logging <EOL> from django . conf import settings <EOL> from django . contrib . auth import get_user_model <EOL> from rest_framework import mixins , viewsets <EOL> from rest_framework . views import APIView <EOL> from rest_framework . decorators import detail_route , list_route <EOL> from rest_framework . response import Response <EOL> from rest_framework_bulk import mixins as bulk_mixins <EOL> from rest_framework_extensions . cache . decorators import cache_response <EOL> from . import auth , filters , serializers <EOL> from . . import exc , models <EOL> from . . util import cache , qpbool , cidr_to_dict <EOL> log = logging . getLogger ( __name__ ) <EOL> class BaseNsotViewSet ( viewsets . ReadOnlyModelViewSet ) : <EOL> """<STR_LIT>""" <EOL> natural_key = None <EOL> @ property <EOL> def model_name ( self ) : <EOL> return self . queryset . model . __name__ <EOL> def get_natural_key_kwargs ( self , filter_value ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( '<STR_LIT>' ) <EOL> def not_found ( self , pk = None , site_pk = None , msg = None ) : <EOL> """<STR_LIT>""" <EOL> if msg is None : <EOL> msg = '<STR_LIT>' . format ( <EOL> self . model_name , site_pk , pk <EOL> ) <EOL> raise exc . NotFound ( msg ) <EOL> def success ( self , data , status = <NUM_LIT:200> , headers = None ) : <EOL> return Response ( data , status = status , headers = headers ) <EOL> def list ( self , request , site_pk = None , queryset = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if queryset is None : <EOL> queryset = self . filter_queryset ( self . get_queryset ( ) ) <EOL> if site_pk is not None : <EOL> queryset = queryset . filter ( site = site_pk ) <EOL> page = self . paginate_queryset ( queryset ) <EOL> if page is not None : <EOL> serializer = self . get_serializer ( page , many = True ) <EOL> return super ( BaseNsotViewSet , self ) . get_paginated_response ( <EOL> serializer . data <EOL> ) <EOL> serializer = self . get_serializer ( queryset , many = True ) <EOL> return self . success ( serializer . data ) <EOL> def retrieve ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in self . kwargs : <EOL> self . kwargs [ '<STR_LIT>' ] = pk <EOL> if '<STR_LIT>' in self . kwargs : <EOL> self . kwargs [ '<STR_LIT>' ] = site_pk <EOL> obj = self . get_object ( ) <EOL> serializer = self . get_serializer ( obj , * args , ** kwargs ) <EOL> return self . success ( serializer . data ) <EOL> def get_object ( self ) : <EOL> """<STR_LIT>""" <EOL> queryset = self . queryset <EOL> site_pk = self . kwargs . get ( '<STR_LIT>' ) <EOL> pk = self . kwargs . get ( '<STR_LIT>' ) <EOL> if isinstance ( pk , ( int , long ) ) : <EOL> pk = str ( pk ) <EOL> lookup_kwargs = { } <EOL> if site_pk is not None : <EOL> lookup_kwargs [ '<STR_LIT>' ] = site_pk <EOL> if pk is None or pk . isdigit ( ) or self . natural_key is None : <EOL> lookup_kwargs [ '<STR_LIT>' ] = pk <EOL> else : <EOL> natural_kwargs = self . get_natural_key_kwargs ( pk ) <EOL> lookup_kwargs . update ( natural_kwargs ) <EOL> try : <EOL> obj = queryset . get ( ** lookup_kwargs ) <EOL> except exc . ObjectDoesNotExist : <EOL> self . not_found ( pk , site_pk ) <EOL> except exc . MultipleObjectsReturned : <EOL> raise exc . ValidationError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( <EOL> self . model_name , self . natural_key , pk <EOL> ) <EOL> ) <EOL> self . check_object_permissions ( self . request , obj ) <EOL> return obj <EOL> class ChangeViewSet ( BaseNsotViewSet ) : <EOL> """<STR_LIT>""" <EOL> queryset = models . Change . objects . order_by ( '<STR_LIT>' ) <EOL> serializer_class = serializers . ChangeSerializer <EOL> filter_fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class NsotViewSet ( BaseNsotViewSet , viewsets . ModelViewSet ) : <EOL> """<STR_LIT>""" <EOL> def perform_create ( self , serializer ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> objects = serializer . save ( ) <EOL> except exc . DjangoValidationError as err : <EOL> raise exc . ValidationError ( err . message_dict ) <EOL> except exc . IntegrityError as err : <EOL> raise exc . Conflict ( err . message ) <EOL> else : <EOL> if not isinstance ( objects , list ) : <EOL> objects = [ objects ] <EOL> log . debug ( '<STR_LIT>' , objects ) <EOL> for obj in objects : <EOL> models . Change . objects . create ( <EOL> obj = obj , user = self . request . user , event = '<STR_LIT>' <EOL> ) <EOL> def get_success_headers ( self , data ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> location = '<STR_LIT>' % ( self . request . path_info , data [ '<STR_LIT:id>' ] ) <EOL> return { '<STR_LIT>' : location } <EOL> except ( TypeError , KeyError ) : <EOL> return { } <EOL> def perform_update ( self , serializer ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> objects = serializer . save ( ) <EOL> except exc . DjangoValidationError as err : <EOL> raise exc . ValidationError ( err . message_dict ) <EOL> except exc . IntegrityError as err : <EOL> raise exc . Conflict ( err . message ) <EOL> else : <EOL> if not isinstance ( objects , list ) : <EOL> objects = [ objects ] <EOL> log . debug ( '<STR_LIT>' , objects ) <EOL> for obj in objects : <EOL> models . Change . objects . create ( <EOL> obj = obj , user = self . request . user , event = '<STR_LIT>' <EOL> ) <EOL> def perform_destroy ( self , instance ) : <EOL> """<STR_LIT>""" <EOL> log . debug ( '<STR_LIT>' , instance ) <EOL> change = models . Change . objects . create ( <EOL> obj = instance , user = self . request . user , event = '<STR_LIT>' <EOL> ) <EOL> try : <EOL> instance . delete ( ) <EOL> except exc . ProtectedError as err : <EOL> change . delete ( ) <EOL> raise exc . Conflict ( err . args [ <NUM_LIT:0> ] ) <EOL> class SiteViewSet ( NsotViewSet ) : <EOL> """<STR_LIT>""" <EOL> queryset = models . Site . objects . all ( ) <EOL> serializer_class = serializers . SiteSerializer <EOL> filter_fields = ( '<STR_LIT:name>' , ) <EOL> class ValueViewSet ( NsotViewSet ) : <EOL> """<STR_LIT>""" <EOL> queryset = models . Value . objects . all ( ) <EOL> serializer_class = serializers . ValueSerializer <EOL> filter_fields = ( '<STR_LIT:name>' , '<STR_LIT:value>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def get_serializer_class ( self ) : <EOL> if self . request . method == '<STR_LIT:POST>' : <EOL> return serializers . ValueCreateSerializer <EOL> return self . serializer_class <EOL> class NsotBulkUpdateModelMixin ( bulk_mixins . BulkUpdateModelMixin ) : <EOL> """<STR_LIT>""" <EOL> def perform_update ( self , serializer ) : <EOL> super ( bulk_mixins . BulkUpdateModelMixin , self ) . perform_update ( <EOL> serializer <EOL> ) <EOL> class ResourceViewSet ( NsotBulkUpdateModelMixin , NsotViewSet , <EOL> bulk_mixins . BulkCreateModelMixin ) : <EOL> """<STR_LIT>""" <EOL> @ list_route ( methods = [ '<STR_LIT>' ] ) <EOL> def query ( self , request , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> query = request . query_params . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> qs = self . queryset . set_query ( query , site_id = site_pk ) <EOL> objects = self . filter_queryset ( qs ) <EOL> return self . list ( request , queryset = objects , * args , ** kwargs ) <EOL> def get_resource_object ( self , pk , site_pk ) : <EOL> """<STR_LIT>""" <EOL> orig_kwargs = self . kwargs . copy ( ) <EOL> self . kwargs [ '<STR_LIT>' ] = pk <EOL> self . kwargs [ '<STR_LIT>' ] = site_pk <EOL> obj = self . get_object ( ) <EOL> self . kwargs = orig_kwargs <EOL> return obj <EOL> class AttributeViewSet ( ResourceViewSet ) : <EOL> """<STR_LIT>""" <EOL> queryset = models . Attribute . objects . all ( ) <EOL> serializer_class = serializers . AttributeSerializer <EOL> filter_fields = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def get_serializer_class ( self ) : <EOL> if self . request . method == '<STR_LIT:POST>' : <EOL> return serializers . AttributeCreateSerializer <EOL> if self . request . method in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> return serializers . AttributeUpdateSerializer <EOL> return self . serializer_class <EOL> class DeviceViewSet ( ResourceViewSet ) : <EOL> """<STR_LIT>""" <EOL> queryset = models . Device . objects . all ( ) <EOL> serializer_class = serializers . DeviceSerializer <EOL> filter_class = filters . DeviceFilter <EOL> natural_key = '<STR_LIT>' <EOL> def get_serializer_class ( self ) : <EOL> if self . request . method == '<STR_LIT:POST>' : <EOL> return serializers . DeviceCreateSerializer <EOL> if self . request . method == '<STR_LIT>' : <EOL> return serializers . DeviceUpdateSerializer <EOL> if self . request . method == '<STR_LIT>' : <EOL> return serializers . DevicePartialUpdateSerializer <EOL> return self . serializer_class <EOL> def get_natural_key_kwargs ( self , filter_value ) : <EOL> """<STR_LIT>""" <EOL> return { self . natural_key : filter_value } <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def interfaces ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> device = self . get_resource_object ( pk , site_pk ) <EOL> interfaces = device . interfaces . all ( ) <EOL> return self . list ( request , queryset = interfaces , * args , ** kwargs ) <EOL> class NetworkViewSet ( ResourceViewSet ) : <EOL> """<STR_LIT>""" <EOL> queryset = models . Network . objects . all ( ) <EOL> serializer_class = serializers . NetworkSerializer <EOL> filter_class = filters . NetworkFilter <EOL> lookup_value_regex = '<STR_LIT>' <EOL> natural_key = '<STR_LIT>' <EOL> def get_serializer_class ( self ) : <EOL> if self . request . method == '<STR_LIT:POST>' : <EOL> return serializers . NetworkCreateSerializer <EOL> if self . request . method == '<STR_LIT>' : <EOL> return serializers . NetworkUpdateSerializer <EOL> if self . request . method == '<STR_LIT>' : <EOL> return serializers . NetworkPartialUpdateSerializer <EOL> return self . serializer_class <EOL> def get_natural_key_kwargs ( self , filter_value ) : <EOL> """<STR_LIT>""" <EOL> return cidr_to_dict ( filter_value ) <EOL> @ list_route ( methods = [ '<STR_LIT>' ] ) <EOL> def query ( self , request , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . queryset = self . get_queryset ( ) <EOL> return super ( NetworkViewSet , self ) . query ( <EOL> request , site_pk , * args , ** kwargs <EOL> ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def closest_parent ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> prefix_length = request . query_params . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> try : <EOL> network = models . Network . objects . get_closest_parent ( <EOL> pk , prefix_length = prefix_length , site = site_pk <EOL> ) <EOL> except models . Network . DoesNotExist : <EOL> self . not_found ( pk , site_pk ) <EOL> else : <EOL> pk = network . id <EOL> return self . retrieve ( request , pk , site_pk , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def subnets ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> params = request . query_params <EOL> include_networks = qpbool ( params . get ( '<STR_LIT>' , True ) ) <EOL> include_ips = qpbool ( params . get ( '<STR_LIT>' , True ) ) <EOL> direct = qpbool ( params . get ( '<STR_LIT>' , False ) ) <EOL> networks = network . subnets ( <EOL> include_networks = include_networks , <EOL> include_ips = include_ips , direct = direct <EOL> ) <EOL> return self . list ( request , queryset = networks , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def supernets ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> params = request . query_params <EOL> direct = qpbool ( params . get ( '<STR_LIT>' , False ) ) <EOL> networks = network . supernets ( direct = direct ) <EOL> return self . list ( request , queryset = networks , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def next_network ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> params = request . query_params <EOL> prefix_length = params . get ( '<STR_LIT>' ) <EOL> num = params . get ( '<STR_LIT>' ) <EOL> networks = network . get_next_network ( <EOL> prefix_length , num , as_objects = False <EOL> ) <EOL> return self . success ( networks ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def next_address ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> num = request . query_params . get ( '<STR_LIT>' ) <EOL> addresses = network . get_next_address ( num , as_objects = False ) <EOL> return self . success ( addresses ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def ancestors ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> ascending = qpbool ( request . query_params . get ( '<STR_LIT>' , False ) ) <EOL> ancestors = network . get_ancestors ( ascending = ascending ) <EOL> return self . list ( request , queryset = ancestors , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def children ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> children = network . get_children ( ) <EOL> return self . list ( request , queryset = children , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def descendents ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> descendents = network . get_descendents ( ) <EOL> return self . list ( request , queryset = descendents , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def parent ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> parent = network . parent <EOL> if parent is not None : <EOL> pk = network . parent_id <EOL> else : <EOL> pk = None <EOL> return self . retrieve ( request , pk , site_pk , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def root ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> root = network . get_root ( ) <EOL> if root is not None : <EOL> pk = root . id <EOL> else : <EOL> pk = None <EOL> return self . retrieve ( request , pk , site_pk , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def siblings ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> include_self = qpbool ( request . query_params . get ( '<STR_LIT>' , False ) ) <EOL> descendents = network . get_siblings ( include_self = include_self ) <EOL> return self . list ( request , queryset = descendents , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def assignments ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> network = self . get_resource_object ( pk , site_pk ) <EOL> assignments = network . assignments . all ( ) <EOL> return self . list ( request , queryset = assignments , * args , ** kwargs ) <EOL> @ list_route ( methods = [ '<STR_LIT>' ] ) <EOL> def reserved ( self , request , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> objects = models . Network . objects . reserved ( ) <EOL> return self . list ( request , queryset = objects , * args , ** kwargs ) <EOL> class InterfaceViewSet ( ResourceViewSet ) : <EOL> """<STR_LIT>""" <EOL> queryset = models . Interface . objects . all ( ) <EOL> serializer_class = serializers . InterfaceSerializer <EOL> filter_class = filters . InterfaceFilter <EOL> @ cache_response ( cache_errors = False , key_func = cache . list_key_func ) <EOL> def list ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return super ( InterfaceViewSet , self ) . list ( * args , ** kwargs ) <EOL> @ cache_response ( cache_errors = False , key_func = cache . object_key_func ) <EOL> def retrieve ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return super ( InterfaceViewSet , self ) . retrieve ( * args , ** kwargs ) <EOL> def get_serializer_class ( self ) : <EOL> if self . request . method == '<STR_LIT:POST>' : <EOL> return serializers . InterfaceCreateSerializer <EOL> if self . request . method == '<STR_LIT>' : <EOL> return serializers . InterfaceUpdateSerializer <EOL> if self . request . method == '<STR_LIT>' : <EOL> return serializers . InterfacePartialUpdateSerializer <EOL> return self . serializer_class <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def addresses ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> interface = self . get_resource_object ( pk , site_pk ) <EOL> addresses = interface . addresses . all ( ) <EOL> return self . list ( request , queryset = addresses , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def assignments ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> interface = self . get_resource_object ( pk , site_pk ) <EOL> assignments = interface . assignments . all ( ) <EOL> return self . list ( request , queryset = assignments , * args , ** kwargs ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def networks ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> interface = self . get_resource_object ( pk , site_pk ) <EOL> return self . list ( request , queryset = interface . networks , * args , ** kwargs ) <EOL> UserPkInfo = namedtuple ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class UserViewSet ( BaseNsotViewSet , mixins . CreateModelMixin ) : <EOL> """<STR_LIT>""" <EOL> queryset = get_user_model ( ) . objects . all ( ) <EOL> serializer_class = serializers . UserSerializer <EOL> filter_fields = ( '<STR_LIT:email>' , ) <EOL> def get_user_and_pk ( self , request , pk = None , site_pk = None ) : <EOL> if int ( pk ) == <NUM_LIT:0> : <EOL> pk = request . user . pk <EOL> try : <EOL> user = self . queryset . get ( pk = pk ) <EOL> except exc . ObjectDoesNotExist : <EOL> self . not_found ( pk , site_pk ) <EOL> return UserPkInfo ( user , pk ) <EOL> def retrieve ( self , request , pk = None , site_pk = None , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> user , pk = self . get_user_and_pk ( request , pk , site_pk ) <EOL> params = request . query_params <EOL> with_secret_key = params . get ( '<STR_LIT>' , None ) <EOL> if with_secret_key is not None : <EOL> if user != request . user : <EOL> raise exc . Forbidden ( <EOL> "<STR_LIT>" <EOL> ) <EOL> kwargs [ '<STR_LIT>' ] = qpbool ( with_secret_key ) <EOL> return super ( UserViewSet , self ) . retrieve ( <EOL> request , pk , site_pk , * args , ** kwargs <EOL> ) <EOL> @ detail_route ( methods = [ '<STR_LIT>' ] ) <EOL> def rotate_secret_key ( self , request , pk = None , * args , ** kwargs ) : <EOL> user , pk = self . get_user_and_pk ( request , pk ) <EOL> if user != request . user : <EOL> raise exc . Forbidden ( <EOL> "<STR_LIT>" <EOL> ) <EOL> user . rotate_secret_key ( ) <EOL> return self . success ( user . secret_key ) <EOL> class NotFoundViewSet ( viewsets . GenericViewSet ) : <EOL> """<STR_LIT>""" <EOL> def get ( self , * args , ** kwargs ) : <EOL> raise exc . NotFound ( ) <EOL> def list ( self , * args , ** kwargs ) : <EOL> raise exc . NotFound ( ) <EOL> def get_serializer_class ( self ) : <EOL> return None <EOL> class AuthTokenLoginView ( APIView ) : <EOL> permission_classes = ( ) <EOL> def post ( self , request , * args , ** kwargs ) : <EOL> serializer = serializers . AuthTokenSerializer ( data = request . data ) <EOL> if serializer . is_valid ( ) : <EOL> user = serializer . validated_data [ '<STR_LIT:user>' ] <EOL> data = { '<STR_LIT>' : user . generate_auth_token ( ) } <EOL> if request . version == settings . NSOT_API_VERSION : <EOL> return Response ( data ) <EOL> return Response ( <EOL> OrderedDict ( [ <EOL> ( '<STR_LIT:status>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:data>' , data ) , <EOL> ] ) <EOL> ) <EOL> raise exc . Unauthorized ( serializer . errors ) <EOL> class AuthTokenVerifyView ( APIView ) : <EOL> authentication_classes = ( auth . AuthTokenAuthentication , ) <EOL> permission_classes = ( ) <EOL> def post ( self , request , * args , ** kwargs ) : <EOL> if request . version == settings . NSOT_API_VERSION : <EOL> return Response ( True ) <EOL> return Response ( <EOL> OrderedDict ( [ <EOL> ( '<STR_LIT:status>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:data>' , True ) , <EOL> ] ) <EOL> ) </s>
