results = None try: results = DiscoveryApi.search('article', None, search_query, page, psize, sort) except DiscoveryException as e: raise Api400Error(e.message) return jsonify_models(results) ######################################### # Application CRUD API @blueprint.route("/applications", methods=["POST"]) @api_key_required @write_required(api=True) @swag(swag_summary='Create an application <span class="red">[Authenticated, not public]</span>', swag_spec=ApplicationsCrudApi.create_swag()) # must be applied after @api_key_(optional|required) decorators. They don't preserve func attributes. def create_application(): # get the data from the request try: data = json.loads(request.data) except: raise Api400Error("Supplied data was not valid JSON") # delegate to the API implementation a = ApplicationsCrudApi.create(data, current_user._get_current_object()) # respond with a suitable Created response return created(a, url_for("api_v1.retrieve_application", application_id=a.id)) @blueprint.route("/applications/<application_id>", methods=["GET"])
results = None try: results = DiscoveryApi.search('article', None, search_query, page, psize, sort) except DiscoveryException as e: raise Api400Error(str(e)) return jsonify_models(results) ######################################### # Application CRUD API @blueprint.route("/applications", methods=["POST"]) @api_key_required @write_required(api=True) @swag(swag_summary='Create an application <span class="red">[Authenticated, not public]</span>', swag_spec=ApplicationsCrudApi.create_swag()) # must be applied after @api_key_(optional|required) decorators. They don't preserve func attributes. @analytics.sends_ga_event(GA_CATEGORY, GA_ACTIONS.get('create_application', 'Create application')) def create_application(): # get the data from the request try: data = json.loads(request.data.decode("utf-8")) except: raise Api400Error("Supplied data was not valid JSON") # delegate to the API implementation a = ApplicationsCrudApi.create(data, current_user._get_current_object()) # respond with a suitable Created response return created(a, url_for("api_v1.retrieve_application", application_id=a.id))
raise Api400Error(e.message) return jsonify_models(results) ######################################### # Application CRUD API @blueprint.route("/applications", methods=["POST"]) @api_key_required @write_required(api=True) @swag( swag_summary= 'Create an application <span class="red">[Authenticated, not public]</span>', swag_spec=ApplicationsCrudApi.create_swag() ) # must be applied after @api_key_(optional|required) decorators. They don't preserve func attributes. def create_application(): # get the data from the request try: data = json.loads(request.data) except: raise Api400Error("Supplied data was not valid JSON") # delegate to the API implementation a = ApplicationsCrudApi.create(data, current_user._get_current_object()) # respond with a suitable Created response return created(a, url_for("api_v1.retrieve_application", application_id=a.id))