Adil
Adil

Reputation: 582

Ignoring a ProtoRPC message field via Cloud Endpoints

I've been working on an AppEngine-based project and I wanted to know if it's possible to ignore a ProtoRPC message field.

With the Java SDK, you can use @ApiResourceProperty to ignore a property (this means it's not contained within the response returned to the browser). However, I have not come across a way of doing this using the Python SDK.

Is there anything like this in the Python SDK?

Thanks, Adil

Upvotes: 0

Views: 98

Answers (1)

Scarygami
Scarygami

Reputation: 15569

Nope, unfortunately not (at least not to my knowledge).

Two possible solutions depending on your use-case.

  1. Set field values to None before returning the message in your method. That way they will be skipped/not included in the JSON response.

  2. If your messages are hooked up to datastore models you can use the endpoints-proto-datastore library which allows you to use your ndb models directly in your API methods. Additionally it allows for request_fields and response_fields parameters in the method decorator which will limit the request or response to the specified subset of message/model fields. (internally it creates the necessary message classes for you)

Upvotes: 2

Related Questions