def method(request_message=message_types.VoidMessage,
           response_message=message_types.VoidMessage,
           name=None,
           path=None,
           http_method='POST',
           scopes=None,
           audiences=None,
           allowed_client_ids=None,
           auth_level=None,
           api_key_required=None,
           metric_costs=None,
           use_request_uri=None):
  if auth_level is not None:
    _logger.warn(_AUTH_LEVEL_WARNING)
  DEFAULT_HTTP_METHOD = 'POST'
  def apiserving_method_decorator(api_method):
    request_body_class = None
    request_params_class = None
    if isinstance(request_message, resource_container.ResourceContainer):
      remote_decorator = remote.method(request_message.combined_message_class,
                                       response_message)
      request_body_class = request_message.body_message_class()
      request_params_class = request_message.parameters_message_class()
    else:
      remote_decorator = remote.method(request_message, response_message)
    remote_method = remote_decorator(api_method)
    def invoke_remote(service_instance, request):
      users_id_token._maybe_set_current_user_vars(
          invoke_remote, api_info=getattr(service_instance, 'api_info', None),
          request=request)
      return remote_method(service_instance, request)
    invoke_remote.remote = remote_method.remote
    if isinstance(request_message, resource_container.ResourceContainer):
      resource_container.ResourceContainer.add_to_cache(
          invoke_remote.remote, request_message)
    invoke_remote.method_info = _MethodInfo(
        name=name or api_method.__name__, path=path or api_method.__name__,
        http_method=http_method or DEFAULT_HTTP_METHOD,
        scopes=scopes, audiences=audiences,
        allowed_client_ids=allowed_client_ids, auth_level=auth_level,
        api_key_required=api_key_required, metric_costs=metric_costs,
        use_request_uri=use_request_uri,
        request_body_class=request_body_class,
        request_params_class=request_params_class)
    invoke_remote.__name__ = invoke_remote.method_info.name
    return invoke_remote
  endpoints_util.check_list_type(scopes, (basestring, endpoints_types.OAuth2Scope), 'scopes')
  endpoints_util.check_list_type(allowed_client_ids, basestring,
                                 'allowed_client_ids')
  _CheckEnum(auth_level, AUTH_LEVEL, 'auth_level')
  _CheckAudiences(audiences)
  _CheckType(metric_costs, dict, 'metric_costs')
  return apiserving_method_decorator