Merge branch 'main' into avm99963-monorail
Merged commit 3779da353b36d43cf778e7d4f468097714dd4540
GitOrigin-RevId: 6451a5c6b75afb0fd1f37b3f14521148d0722ea8
diff --git a/api/monorail_servicer.py b/api/monorail_servicer.py
index 8968ec4..7dfdf0c 100644
--- a/api/monorail_servicer.py
+++ b/api/monorail_servicer.py
@@ -9,6 +9,7 @@
import cgi
import functools
+import httplib
import logging
import sys
import time
@@ -17,12 +18,10 @@
from google.appengine.api import users
from google.protobuf import json_format
from components.prpc import codes
-from components.prpc import server
import settings
from framework import authdata
from framework import exceptions
-from framework import framework_bizobj
from framework import framework_constants
from framework import monitoring
from framework import monorailcontext
@@ -43,10 +42,27 @@
# Optional header to help prevent double updates.
REQUEST_ID_HEADER = 'x-request-id'
+# TODO(https://crbug.com/1346473)
+_PRPC_TO_HTTP_STATUS = {
+ codes.StatusCode.OK: httplib.OK,
+ codes.StatusCode.CANCELLED: httplib.NO_CONTENT,
+ codes.StatusCode.INVALID_ARGUMENT: httplib.BAD_REQUEST,
+ codes.StatusCode.DEADLINE_EXCEEDED: httplib.SERVICE_UNAVAILABLE,
+ codes.StatusCode.NOT_FOUND: httplib.NOT_FOUND,
+ codes.StatusCode.ALREADY_EXISTS: httplib.CONFLICT,
+ codes.StatusCode.PERMISSION_DENIED: httplib.FORBIDDEN,
+ codes.StatusCode.RESOURCE_EXHAUSTED: httplib.SERVICE_UNAVAILABLE,
+ codes.StatusCode.FAILED_PRECONDITION: httplib.PRECONDITION_FAILED,
+ codes.StatusCode.OUT_OF_RANGE: httplib.BAD_REQUEST,
+ codes.StatusCode.UNIMPLEMENTED: httplib.NOT_IMPLEMENTED,
+ codes.StatusCode.INTERNAL: httplib.INTERNAL_SERVER_ERROR,
+ codes.StatusCode.UNAVAILABLE: httplib.SERVICE_UNAVAILABLE,
+ codes.StatusCode.UNAUTHENTICATED: httplib.UNAUTHORIZED,
+}
def ConvertPRPCStatusToHTTPStatus(context):
"""pRPC uses internal codes 0..16, but we want to report HTTP codes."""
- return server._PRPC_TO_HTTP_STATUS.get(context._code, 500)
+ return _PRPC_TO_HTTP_STATUS.get(context._code, 500)
def PRPCMethod(func):