luongbs94 / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Add setIfMatchHeader and setIfNoneMatchHeader to generated API methods #635

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
There is already a getRequestHeaders() method on AbstractGoogleClientRequest.  
If you need to specify a header, you have to assign the request class to a 
local variable, e.g.

Calendar.Calendars.Delete deleteRequest = 
client.calendars().delete(calendar.getId())'
deleteRequest.getRequestHeaders().setIfMatch("someEtag");
deleteRequest.execute()

With setRequestHeader I might be able to chain methods like this:

client.calendars().delete(calendar.getId())
    .setRequestHeader("If-Match", "someEtag")
    .execute()

Original issue reported on code.google.com by yan...@google.com on 16 Oct 2012 at 10:08

GoogleCodeExporter commented 9 years ago
Nah, let's drop this general-purpose header setting idea.  If there are headers 
that are commonly set, we should just add utility methods to help set this.

So in this case, to solve the etag case we should add setIfMatchHeader:

client.calendars().delete(calendar.getId())
    .setIfMatchHeader("someEtag")
    .execute()

So we should generate setIfMatchHeader to all PUT, PATCH, & DELETE API methods.

Similarly, we should generate setIfNoneMatchHeader to all GET API methods.

Note that POST API methods do not have ETag.  I'm guessing other HTTP methods 
don't have it either.  Regardless, this is just a convenience, since you can 
always access getRequestHeaders().

Original comment by yan...@google.com on 16 Nov 2012 at 12:30

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 16 Nov 2012 at 1:40

GoogleCodeExporter commented 9 years ago
We are working on a more general purpose design for headers in client 
libraries.  Will wait for that.

Original comment by yan...@google.com on 10 Dec 2012 at 9:32

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 9 Jan 2013 at 10:45

GoogleCodeExporter commented 9 years ago
waiting for a feature in discovery

Original comment by yan...@google.com on 14 Jan 2013 at 7:43

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 18 Jan 2013 at 3:18

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 7 Feb 2013 at 12:05

GoogleCodeExporter commented 9 years ago
This feature is blocked on having this information in the Discovery document.

Original comment by yan...@google.com on 10 Jun 2013 at 1:28

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 26 Jul 2013 at 10:19

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 27 Sep 2013 at 11:59