def get_domain(domain_id): context = flask.request.environ.get('context') try: domain = central_api.get_domain(context, domain_id) except exceptions.Forbidden: return flask.Response(status=401) except exceptions.DomainNotFound: return flask.Response(status=404) except rpc_common.Timeout: return flask.Response(status=504) else: domain = domain_schema.filter(domain) return flask.jsonify(domain)
def get_domain(domain_id): context = flask.request.environ.get('context') try: domain = central_api.get_domain(context, domain_id) except exceptions.Forbidden: return flask.Response(status=401) except exceptions.DomainNotFound: return flask.Response(status=404) else: domain = _append_domain_links(domain, domain['id']) domain = domain_schema.filter(domain) return flask.jsonify(domain)
def update_domain(domain_id): context = flask.request.environ.get('context') values = flask.request.json try: domain = central_api.get_domain(context, domain_id) domain.update(values) domain_schema.validate(domain) domain = central_api.update_domain(context, domain_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)