location_client_metric_model, location_client_metric_to_csv, \ location_server_metric_model, location_server_metric_to_csv, \ location_client_server_metric_model, location_client_server_metric_to_csv, \ location_info_model, location_info_to_csv, \ location_children_model, location_children_to_csv, \ location_client_isp_info_model, location_client_isp_info_to_csv from mlab_api.url_utils import get_time_window, normalize_key, get_filter from mlab_api.decorators import format_response from mlab_api.rest_api import api from mlab_api.stats import analytics # this is the namespace that gets included elsewhere. locations_ns = api.namespace('locations', description='Location specific API') @locations_ns.route('/search') class LocationSearch(Resource): ''' Location Search Resource ''' @api.expect(search_arguments) @format_response(location_search_to_csv) @api.marshal_with(location_search_model) def get(self): """ Get all Locations matching a query """
from mlab_api.rest_api import api from mlab_api.parsers import date_arguments, search_arguments, include_data_arguments, top_arguments from mlab_api.url_utils import get_time_window, get_filter, normalize_key from mlab_api.models.location_models import location_server_list_model, location_server_list_to_csv from mlab_api.models.client_models import client_server_list_model, client_server_list_to_csv from mlab_api.models.server_models import server_search_model, server_search_to_csv, \ server_info_model, server_info_to_csv, \ server_metric_model,server_metric_to_csv from mlab_api.decorators import format_response from mlab_api.stats import analytics server_asn_ns = api.namespace('servers', description='Server ASN specific API') @server_asn_ns.route('/search') class ServerSearch(Resource): ''' Server Search ''' @api.expect(search_arguments) @format_response(server_search_to_csv) @api.marshal_with(server_search_model) def get(self): """ Search for Servers matching a query. """
from mlab_api.rest_api import api from mlab_api.parsers import date_arguments, search_arguments, include_data_arguments, top_arguments from mlab_api.url_utils import get_time_window, get_filter, normalize_key from mlab_api.models.location_models import location_client_list_model, location_client_list_to_csv from mlab_api.models.client_models import client_search_model, client_search_to_csv, \ client_info_model, client_info_to_csv, \ client_metric_model, client_metric_to_csv, \ client_server_metric_model, client_server_metric_to_csv, \ client_server_list_model, client_server_list_to_csv from mlab_api.decorators import format_response client_asn_ns = api.namespace('clients', description='Client ASN specific API') @client_asn_ns.route('/search') class ClientAsnSearch(Resource): ''' Client Search ''' @api.expect(search_arguments) @format_response(client_search_to_csv) @api.marshal_with(client_search_model) def get(self): """ Search clients for a given query """
# -*- coding: utf-8 -*- ''' Sample Raw Data ''' from mlab_api.rest_api import api from mlab_api.data.data import RAW_DATA as DATA from flask_restplus import Resource raw_ns = api.namespace('raw', description='') @raw_ns.route('/tests') class RawTests(Resource): ''' ''' def get(self): """ Returns a sample of raw upload/download data including lat/lon positions. """ results = DATA.get_raw_test_results() return results
# -*- coding: utf-8 -*- ''' Potentially helpful debugging routes. ''' from mlab_api.rest_api import api from mlab_api.data.data import LOCATION_DATA as DATA from flask_restplus import Resource debug_ns = api.namespace('debug', description='Debug Help') @debug_ns.route('/connection') class Connection(Resource): ''' Debug Connection Resource ''' def get(self): """ Lists BigTable Connection Details Indicate if a BigTable connection has been made \ and if so, what tables are accessible to the API. """ pool = DATA.get_pool() if pool: with pool.connection() as connection: return {"message": "Connection", "tables": connection.tables()} else: return {"error": 'No Connection', "tables": []}