def device_version(device_type): """Get latest version for app on (`device_type`) in webstore. :param device_type: device we support :resjson version: Object of version (see below) The versions `version` is a json object list below. :json string device: query device. :json string version: latest version for device. **Request** .. sourcecode:: http GET /latest/versions/android HTTP/1.1 Host: kuas.grd.idv.tw:14769 .. sourcecode:: shell curl -X GET https://kuas.grd.idv.tw:14769/v2/versions/android **Response** .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json { "version": { "device": "android", "version": "1.5.4" } } """ if device_type in const.device_version: result = { "version": { "device": device_type, "version": const.device_version[device_type] } } return jsonify(result) return error.error_handle(status=404, developer_message="Device not found.", user_message="Device not found.")
def auth_error(): """Return Authroized Error to users. :return: error json :rtype: json """ user_message = ("Your token has been expired or " "using wrong username and password to login") return error.error_handle( status=401, developer_message="Token expired or Unauthorized Access", user_message=user_message)
def auth_error(): """Return Authroized Error to users. :return: error json :rtype: json """ user_message = ("Your token has been expired or " "using wrong username and password to login") return error.error_handle( status=401, developer_message="Token expired or Unauthorized Access", user_message=user_message )
def ap_semester(): semester_list = ap.get_semester_list() default_yms = list( filter(lambda x: x['selected'] == 1, semester_list))[0] # Check default args if request.args.get("default") == "1": return jsonify(default=default_yms) # Check limit args limit = request.args.get("limit") if limit: try: semester_list = semester_list[: int(limit)] except ValueError: return error.error_handle( status=400, developer_message="Error value for limit.", user_message="You type a wrong value for limit.") return jsonify( semester=semester_list, default=default_yms )
def unauthorized_error(err): return error.error_handle(status=401, developer_message="token expired", user_message="token expired", error_code=401)
def servers_status(): """Get KUAS API status for service :resjson list status: Status list (see below) Servers status list :json service: service name. :json status: HTTP status code. **Request** .. sourcecode:: http GET /v2/servers/status HTTP/1.1 Host: kuas.grd.idv.tw:14769 .. sourcecode:: shell curl -X GET https://kuas.grd.idv.tw:14769/v2/servers/status **Response** .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json { "status": [ { "service": "ap", "status": 200 }, { "service": "bus", "status": 200 }, { "service": "leave", "status": 200 } ] } """ try: original_status = cache.server_status() except Exception as err: return error.error_handle(status=404, developer_message=str(err), user_message="Something wrong.") status = { "status": [{ "service": "ap", "status": original_status[0] }, { "service": "bus", "status": original_status[1] }, { "service": "leave", "status": original_status[2] }] } return jsonify(status)
def servers_status(): """Get KUAS API status for service :resjson list status: Status list (see below) Servers status list :json service: service name. :json status: HTTP status code. **Request** .. sourcecode:: http GET /v2/servers/status HTTP/1.1 Host: kuas.grd.idv.tw:14769 .. sourcecode:: shell curl -X GET https://kuas.grd.idv.tw:14769/v2/servers/status **Response** .. sourcecode:: http HTTP/1.1 200 OK Content-Type: application/json { "status": [ { "service": "ap", "status": 200 }, { "service": "bus", "status": 200 }, { "service": "leave", "status": 200 } ] } """ try: original_status = cache.server_status() except Exception as err: return error.error_handle(status=404, developer_message=str(err), user_message="Something wrong.") status = { "status": [ {"service": "ap", "status": original_status[0]}, {"service": "bus", "status": original_status[1]}, {"service": "leave", "status": original_status[2]} ] } return jsonify(status)
def unauthorized_error(err): return error.error_handle(status=401, developer_message="token expired", user_message="token expired", error_code=401 )