def request_tenant() -> Response: """Get the tenant.""" config = request_params(request.args) tenant = config.get('tenant') if not tenant: abort(make_response(), 404) results = query.get_tenant(tenant) return make_response(jsonify(results=results), 200)
def namespaces_total_rating(tenant: AnyStr) -> Response: """ Get namespaces aggregated rating. :tenant (AnyStr) A string representing the tenant. Return a response or nothing. """ config = request_params(request.args) rows = query.get_namespaces_total_rating(start=config['start'], end=config['end'], tenant_id=tenant) return {'total': len(rows), 'results': rows}
def metrics_rating(tenant: AnyStr) -> Response: """ Get the rating per metrics. :tenant (AnyStr) A string representing the namespace. Return a response or nothing. """ config = request_params(request.args) rows = query.get_metrics_rating(start=config['start'], end=config['end'], tenant_id=tenant) return {'total': len(rows), 'results': rows}
def namespace_rating(namespace: AnyStr, tenant: AnyStr) -> Response: """ Get the rating of a namespace. :namespace (AnyStr) A string representing the tenant. :tenant (AnyStr) A string representing the tenant. Return a response or nothing. """ config = request_params(request.args) rows = query.get_namespace_rating(namespace=namespace, start=config['start'], end=config['end'], tenant_id=tenant) return {'total': len(rows), 'results': rows}
def nodes_metric_rating(metric: AnyStr, tenant: AnyStr) -> Response: """ Get the rating for a given metric. :metric (AnyStr) A string representing the namespace. :tenant (AnyStr) A string representing the tenant. Return a response or nothing. """ config = request_params(request.args) rows = query.get_nodes_metric_rating(metric=metric, start=config['start'], end=config['end'], tenant_id=tenant) return {'total': len(rows), 'results': rows}
def node_total_rating(node: AnyStr, tenant: AnyStr) -> Response: """ Get the agglomerated rating for the nodes. :node (AnyStr) A string representing the node. :tenant (AnyStr) A string representing the tenant. Return a response or nothing. """ config = request_params(request.args) rows = query.get_node_total_rating(node=node, start=config['start'], end=config['end'], tenant_id=tenant) return {'total': len(rows), 'results': rows}
def unrated_frames(table: AnyStr) -> Response: """ Get unrated frames from presto. :table (AnyStr) A string representing the table. Return a response or nothing. """ config = request_params(request.args) rows = query.get_unrated_frames(table=table, column=config['column'], labels=config['labels'], start=config['start'], end=config['end']) return {'total': len(rows), 'results': rows}
def pods(tenant: AnyStr) -> Response: """ Get pods. :tenant (AnyStr) A string representing the tenant. Return a response or nothing. """ config = request_params(request.args) rows = query.get_pods(start=config['start'], end=config['end'], tenant_id=tenant) return { 'total': len(rows), 'results': rows }
def pod_total_rating(pod: AnyStr, tenant: AnyStr) -> Response: """ Get a pod's aggregated rating. :pod (AnyStr) A string representing the pod. :tenant (AnyStr) A string representing the tenant. Return a response or nothing. """ config = request_params(request.args) rows = query.get_pod_total_rating(pod=pod, start=config['start'], end=config['end'], tenant_id=tenant) return { 'total': len(rows), 'results': rows }
def pod_metric_rating(pod: AnyStr, metric: AnyStr, tenant: AnyStr) -> Response: """ Get the rating for a given pod and metric. :pod (AnyStr) A string representing the pod. :tenant (AnyStr) A string representing the tenant. Return a response or nothing. """ config = request_params(request.args) rows = query.get_pod_metric_rating(pod=pod, metric=metric, start=config['start'], end=config['end'], tenant_id=tenant) return { 'total': len(rows), 'results': rows }