Beispiel #1
0
def get_record(domain_id, record_id):
    context = flask.request.environ.get('context')

    try:
        record = central_api.get_record(context, domain_id, record_id)
    except exceptions.Forbidden:
        return flask.Response(status=401)
    except (exceptions.RecordNotFound, exceptions.DomainNotFound):
        return flask.Response(status=404)
    except rpc_common.Timeout:
        return flask.Response(status=504)
    else:
        record = record_schema.filter(record)

        return flask.jsonify(record)
Beispiel #2
0
def get_record(domain_id, record_id):
    context = flask.request.environ.get('context')

    try:
        record = central_api.get_record(context, domain_id, record_id)
    except exceptions.Forbidden:
        return flask.Response(status=401)
    except exceptions.RecordNotFound:
        return flask.Response(status=404)
    else:
        record = _append_record_links(record, record['domain_id'],
                                      record['id'])
        record = record_schema.filter(record)

        return flask.jsonify(record)
Beispiel #3
0
def get_record(domain_id, record_id):
    context = flask.request.environ.get('context')

    try:
        record = central_api.get_record(context, domain_id, record_id)
    except exceptions.Forbidden:
        return flask.Response(status=401)
    except exceptions.RecordNotFound:
        return flask.Response(status=404)
    else:
        record = _append_record_links(record, record['domain_id'],
                                      record['id'])
        record = record_schema.filter(record)

        return flask.jsonify(record)
Beispiel #4
0
def update_record(domain_id, record_id):
    context = flask.request.environ.get('context')
    values = flask.request.json

    try:
        record = central_api.get_record(context, domain_id, record_id)
        record.update(values)

        record_schema.validate(record)
        record = central_api.update_record(context, domain_id, record_id,
                                           values)
    except exceptions.Forbidden:
        return flask.Response(status=401)
    except exceptions.InvalidObject, e:
        response_body = json.dumps({'errors': e.errors})
        return flask.Response(status=400, response=response_body)