@classmethod
  @utils.positional(1)
  def method(cls,
             request_fields=None,
             response_fields=None,
             user_required=False,
             **kwargs):
    request_message = kwargs.get(REQUEST_MESSAGE)
    if request_fields is not None and request_message is not None:
      raise TypeError('Received both a request message class and a field list '
                      'for creating a request message class.')

    proto_message = request_message
    if proto_message is None:
      proto_message = cls.ProtoModel(fields=request_fields)

    path = kwargs.get(PATH)
    query_fields = []
    if path is not None:
      query_fields = re.findall("{(.*?)}", path)
    if len(query_fields) > 0:
      kwargs[REQUEST_MESSAGE] = cls.ResourceContainer(
          message=proto_message, fields=query_fields)
    else:
      kwargs[REQUEST_MESSAGE] = proto_message

    response_message = kwargs.get(RESPONSE_MESSAGE)
    if response_fields is not None and response_message is not None:
      raise TypeError('Received both a response message class and a field list '
                      'for creating a response message class.')
    if response_message is None:
      kwargs[RESPONSE_MESSAGE] = cls.ProtoModel(fields=response_fields)

    apiserving_method_decorator = endpoints.method(**kwargs)

    def RequestToEntityDecorator(api_method):
      """A decorator that uses the metadata passed to the enclosing method.

      Args:
        api_method: A method to be decorated. Expected signature is two
            positional arguments, an instance object of an API service and a
            variable containing a deserialized API request object, most likely
            as a ProtoRPC message or as an instance of the current
            EndpointsModel class.

      Returns:
        A decorated method that uses the metadata of the enclosing method to
            verify the service instance, convert the arguments to ones that can
            be consumed by the decorated method and serialize the method output
            back to a ProtoRPC message.
      """

      @functools.wraps(api_method)
      def EntityToRequestMethod(service_instance, request):
        """Stub method to be decorated.

        After creation, will be passed to the standard endpoints.method
        decorator to preserve the necessary method attributes needed for
        endpoints API methods.

        Args:
          service_instance: A ProtoRPC remove service instance.
          request: A ProtoRPC message.

        Returns:
          A ProtoRPC message, potentially serialized after being returned from a
              method which returns a class instance.

        Raises:
          endpoints.UnauthorizedException: if the user required boolean from
             the metadata is True and if there is no current endpoints user.
        """
        if user_required and endpoints.get_current_user() is None:
          raise endpoints.UnauthorizedException('Invalid token.')

        if request_message is None:
          # If we are using a fields list, we can convert the message to an
          # instance of the current class
          request = cls.FromMessage(request)

        # If developers are using request_fields to create a request message
        # class for them, their method should expect to receive an instance of
        # the current EndpointsModel class, and if it fails for some reason
        # their API users will receive a 503 from an uncaught exception.
        response = api_method(service_instance, request)

        if response_message is None:
          # If developers using a custom request message class with
          # response_fields to create a response message class for them, it is
          # up to them to return an instance of the current EndpointsModel
          # class. If not, their API users will receive a 503 from an uncaught
          # exception.
          response = response.ToMessage(fields=response_fields)

        return response

      return apiserving_method_decorator(EntityToRequestMethod)

    return RequestToEntityDecorator
The type of content as provided by the `Content-Type` header field.
dataset/ETHPy150Open GoogleDeveloperExperts/experts-app-backend/endpoints_proto_datastore/ndb/model.py/EndpointsModel.method--crossover with--dataset/ETHPy150Open nigelsmall/httpstream/httpstream/http.py/Response.content_type