abujehad139 / google-api-go-client

Automatically exported from code.google.com/p/google-api-go-client
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Support nested methods in the API generator #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to generate a client library for an API with nested resources and 
methods (e.g books/v1)
2. Generated client only contains methods for first level resource: 
books.volumes.list, etc.
3. Generated client does not contain methods for deeper level resources: 
books.bookshelves.volumes.list

What is the expected output? What do you see instead?

The generated client should contain methods for all the API methods, instead, 
it only contains method for first level resources.

What version of the product are you using? On what operating system?

Latest version from the repo.

Please provide any additional information below.

Example discovery doc available at: 
https://www.googleapis.com/discovery/v1/apis/books/v1/rest

Original issue reported on code.google.com by ala...@google.com on 11 Apr 2013 at 11:50

GoogleCodeExporter commented 9 years ago
This is also an issue with the Google Mirror API:
  https://www.googleapis.com/discovery/v1/apis/mirror/v1/rest

The affected methods are:
  * mirror.timeline.attachments.get
  * mirror.timeline.attachments.list
  * mirror.timeline.attachments.insert
  * mirror.timeline.attachments.delete

Thanks!
Alain

Original comment by ala...@google.com on 16 Apr 2013 at 5:55

GoogleCodeExporter commented 9 years ago
I attached a patch for a simple implementation supporting nested resource; it's 
not optimal but does the job:

type TimelineAttachmentsService struct {
    s *Service
}

I would rather have this Service be an attribute in the TimelineService so that 
invocation would look like:

  t, err := g.Timeline.Attachments.Get(itemId, attachmentId).Do()

Instead of the proposed implementation that looks like:

  t, err := g.TimelineAttachments.Get(itemId, attachmentId).Do()

Unfortunately, doing the optimal implementation would require a refactoring of 
the generator which I can't do right now.

Please let me know what you think and if you'd like me to upload this patch on 
codereview.appspot.com

Thanks!
Alain

Original comment by ala...@google.com on 19 Apr 2013 at 12:16

Attachments:

GoogleCodeExporter commented 9 years ago
New patch of some bug fixes, this new generator now generates the "optimal" 
design:

  t, err := g.Timeline.Attachments.Get(itemId, attachmentId).Do()

It also fixes a bug when a method supports mediaUpload without a requestBody.

Patches:
  * gen.diff: only contains diff for the new generator.
  * nested_resources.diff: contains diff for the new generator and re-generated dependencies.

Original comment by ala...@google.com on 19 Apr 2013 at 8:25

Attachments:

GoogleCodeExporter commented 9 years ago
Submitted. Thanks again!
https://code.google.com/p/google-api-go-client/source/detail?r=14c8effb3ed7

Original comment by bradfitz@google.com on 29 Apr 2013 at 5:06