CloudEndpoints: what is the patch auto-generated API and how to use it?

After adding two methods to the annotated @Api class: get() and update() there are 3 methods created by Endpoints:

  • *.get , which is generated directly for the get() method
  • *.update , which is generated directly for the update() method
  • *.patch , which is apparently generated indirectly after inserting the get() and update() labels into the annotated class.

I see these three methods through the Explorer API on my local server. The code I used to create the endpoint is located at the end of this question.

My question is: why is the third patch method generated? Is it on purpose? If so, how to use this method? Is it used from external customers or is it serviced for internal use only?

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; } } } 
+4
source share
1 answer

The patch method is automatically generated when the update method is created. It is intended for partial updates and is available to external clients.

Usage: it takes the identifier of the object as a parameter, and you can send only the data fields that you want to change.

See patch description .

+4
source

Source: https://habr.com/ru/post/1493480/


All Articles