CloudEndpoints: what is autogenerated "patch" API method and how to use it?

google-app-engine, google-cloud-endpoints, java

Solution

The "patch" method is autogenerated when you create a method called "update". Its for partial updates and available for external clients.

Usage: It takes the id of the entity as parameter and you can send only the data fields which you want to change.

See patch explanation.

Problem

After adding two methods to an @Api annotaged class: `get()` and `update()`, there are 3 methods generated by Endpoints: - `*.get` which is generated directly for the `get()` method - `*.update` which is generated directly for the `update()` method - `*.patch` which seems to be generated indirectly, after inserting both the `get()` and the `update()` methods to the annotated class. I can see this three methods via APIs Explorer on my local server. Code I used to generate endpoint is posted at the end of this question. My question is: why the third method, `patch`, is being generated? Is it there on purpose? If yes, how to use this method? Is it usable from external clients or is served only for internal usage? Here is my endpoint api class: ``` @Api (name = "sample_endpoint") public class SampleEndpoint { public Entity get() { return new Entity(); } public Entity update(Entity entity) { return entity; } public class Entity { public String parameter = "Validated ok."; public String getParameter() { return parameter; } } } ```

Original source