#NEWLINE# def top_level( self , request , api_name = None ) : #NEWLINE# #INDENT# '\n        A view that returns a serialized list of all resources registers\n        to the ``Api``. Useful for discovery.\n        ' #NEWLINE# available_resources = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( api_name is None ) : #NEWLINE# #INDENT# api_name = self . api_name #NEWLINE# #UNINDENT# for name in sorted ( self . _registry . keys ( ) ) : #NEWLINE# #INDENT# available_resources [ name ] = { #NEWLINE# #INDENT# 'list_endpoint' : self . _build_reverse_url ( 'api_dispatch_list' , kwargs = { #NEWLINE# #INDENT# 'api_name' : api_name , #NEWLINE# 'resource_name' : name , #NEWLINE# #UNINDENT# } ) , #NEWLINE# 'schema' : self . _build_reverse_url ( 'api_get_schema' , kwargs = { #NEWLINE# #INDENT# 'api_name' : api_name , #NEWLINE# 'resource_name' : api_name , #NEWLINE# #UNINDENT# } ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# desired_format = determine_format ( request , self . serializer ) #NEWLINE# options = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( 'text/javascript' in desired_format ) : #NEWLINE# #INDENT# callback = request . GET . get ( 'callback' , 'callback' ) #NEWLINE# if ( not is_valid_jsonp_callback_value ( callback ) ) : #NEWLINE# #INDENT# raise BadRequest ( 'JSONP callback name is invalid.' ) #NEWLINE# #UNINDENT# options [ 'callback' ] = callback #NEWLINE# #UNINDENT# serialized = self . serializer . serialize ( available_resources , desired_format , options ) #NEWLINE# return self . response_generator . create ( HttpOK ( content = serialized , content_type = build_content_type ( desired_format ) ) )