예제 #1
0
def bulk_create_org_timeseries(user, org_id_slug):

    # fetch org
    org = fetch_by_id_or_field(Org, "slug", org_id_slug)

    # if it still doesn't exist, raise an error.
    if not org:
        raise NotFoundError("This Org does not exist.")

    # ensure the active user can edit this Org
    if user.id not in org.user_ids:
        raise ForbiddenError("You are not allowed to access this Org")

    req_data = request_data()

    job_id = load.org_timeseries(req_data, org_id=org.id, metrics_lookup=org.timeseries_metrics, queued=True)
    ret = url_for_job_status(apikey=user.apikey, job_id=job_id, queue="bulk")
    return jsonify(ret)
예제 #2
0
def create_org_timeseries(user, org_id_slug):

    # fetch org
    org = fetch_by_id_or_field(Org, "slug", org_id_slug)

    # if it still doesn't exist, raise an error.
    if not org:
        raise NotFoundError("This Org does not exist.")

    # ensure the active user can edit this Org
    if user.id not in org.user_ids:
        raise ForbiddenError("You are not allowed to access this Org")

    # localize
    localize(org)

    req_data = request_data()

    ret = load.org_timeseries(req_data, org_id=org.id, metrics_lookup=org.timeseries_metrics, queued=False, commit=True)
    return jsonify(ret)
예제 #3
0
def bulk_create_org_timeseries(user, org_id_slug):

    # fetch org
    org = fetch_by_id_or_field(Org, 'slug', org_id_slug)

    # if it still doesn't exist, raise an error.
    if not org:
        raise NotFoundError('This Org does not exist.')

    # ensure the active user can edit this Org
    if user.id not in org.user_ids:
        raise ForbiddenError('You are not allowed to access this Org')

    req_data = request_data()

    job_id = load.org_timeseries(req_data,
                                 org_id=org.id,
                                 metrics_lookup=org.timeseries_metrics,
                                 queued=True)
    ret = url_for_job_status(apikey=user.apikey, job_id=job_id, queue='bulk')
    return jsonify(ret)
예제 #4
0
def create_org_timeseries(user, org_id_slug):

    # fetch org
    org = fetch_by_id_or_field(Org, 'slug', org_id_slug)

    # if it still doesn't exist, raise an error.
    if not org:
        raise NotFoundError('This Org does not exist.')

    # ensure the active user can edit this Org
    if user.id not in org.user_ids:
        raise ForbiddenError('You are not allowed to access this Org')

    # localize
    localize(org)

    req_data = request_data()

    ret = load.org_timeseries(req_data,
                              org_id=org.id,
                              metrics_lookup=org.timeseries_metrics,
                              queued=False,
                              commit=True)
    return jsonify(ret)