Closed
Bug 896066
Opened 11 years ago
Closed 11 years ago
Allow REST WebService API to for GET /product to allow retrieval of multiple product objects instead of ids
Categories
(Bugzilla :: WebService, enhancement)
Tracking
()
RESOLVED
FIXED
Bugzilla 5.0
People
(Reporter: dkl, Assigned: dkl)
References
Details
Attachments
(1 file, 4 obsolete files)
11.52 KB,
patch
|
glob
:
review+
|
Details | Diff | Splinter Review |
Currently the REST API for GET /product you have to specify type={accessible,selectable,enterable} to get a list of product ids. accessible being the default if type is undefined. With these changes, I will improve Product.get to accept 'type' as well and return the appropriate list of product ids similar to the current behavior of GET /product. This will allow for simplifying the REST handler code as well as allow for a user to also use GET /product?ids=1&ids=2 to retrieve a list of specific product objects in a single call instead of doing GET /product/<id> for each one individually. Patch coming dkl
Assignee | ||
Comment 1•11 years ago
|
||
This patch updates the following: - Changes the REST API in several ways -- Adds GET /product_accessible GET /product_enterable and GET /product_selectable - Updates GET /product to allow for specifying a group of products instead of having to specify exact ids and/or names. The valid types accepted are 'accessible' (default), 'selectable', and 'enterable'. One or more of 'type', 'ids', or 'names' is still required as before. - This also updates Product.get as well since GET /product uses that directly.
Attachment #778993 -
Flags: review?(glob)
Comment 2•11 years ago
|
||
Comment on attachment 778993 [details] [diff] [review] Allow REST /product to return multiple products based on type, ids, or names (v1) >=== modified file 'Bugzilla/Install/Requirements.pm' >--- Bugzilla/Install/Requirements.pm 2013-07-12 20:39:50 +0000 >+++ Bugzilla/Install/Requirements.pm 2013-07-19 21:46:21 +0000 >@@ -104,7 +104,7 @@ > { > package => 'TimeDate', > module => 'Date::Format', >- version => '2.23' >+ version => '2.22' > }, > # 0.28 fixed some important bugs in DateTime. > { > >=== modified file 'Bugzilla/Mailer.pm' >--- Bugzilla/Mailer.pm 2013-07-12 20:39:50 +0000 >+++ Bugzilla/Mailer.pm 2013-07-21 20:13:41 +0000 >@@ -136,8 +136,6 @@ > Bugzilla::Hook::process('mailer_before_send', > { email => $email, mailer_args => \@args }); > >- return if $email->header('to') eq ''; >- These changes have nothing to do with this bug.
Assignee | ||
Comment 3•11 years ago
|
||
Ugh. Gotta fix my devel environment. Fixed patch.
Attachment #778993 -
Attachment is obsolete: true
Attachment #778993 -
Flags: review?(glob)
Attachment #779022 -
Flags: review?(glob)
Comment on attachment 779022 [details] [diff] [review] Allow REST /product to return multiple products based on type, ids, or names (v1) Review of attachment 779022 [details] [diff] [review]: ----------------------------------------------------------------- ::: Bugzilla/WebService/Product.pm @@ +79,5 @@ > + if (defined $params->{type}) { > + my %product_hash; > + my $found = 0; > + foreach my $type (@{ $params->{type} }) { > + my $method = "get_${type}_products"; you shouldn't take using user input and use it unfiltered to create method names. as there's only three options, make this an if/then/else statement. ::: template/en/default/global/user-error.html.tmpl @@ +1077,5 @@ > A REST API resource was not found for '[% method FILTER html +%] [%+ path FILTER html %]'. > > + [% ELSIF error == "get_products_invalid_type" %] > + The product selection types were invalid. Valid choices > + are 'accessible', 'selectable', and 'enterable'. nit: "The product selection type was invalid"; you only pass in one type, so the error message should be singular.
Attachment #779022 -
Flags: review?(glob) → review-
Assignee | ||
Comment 5•11 years ago
|
||
(In reply to Byron Jones ‹:glob› from comment #4) > ::: template/en/default/global/user-error.html.tmpl > @@ +1077,5 @@ > > A REST API resource was not found for '[% method FILTER html +%] [%+ path FILTER html %]'. > > > > + [% ELSIF error == "get_products_invalid_type" %] > > + The product selection types were invalid. Valid choices > > + are 'accessible', 'selectable', and 'enterable'. > > nit: "The product selection type was invalid"; you only pass in one type, so > the error message should be singular. I worded it that way cause I thought it would be OK to make the param cumulative in that people could pass in one or more of the types and the %product_hash would weed out duplicates. So updated the doc appropriately. Of course if you feel we should only always allow one at a time, then I can update the patch and go that route. dkl
Attachment #779022 -
Attachment is obsolete: true
Attachment #779210 -
Flags: review?(glob)
Comment on attachment 779210 [details] [diff] [review] 896066_2.patch Review of attachment 779210 [details] [diff] [review]: ----------------------------------------------------------------- > I worded it that way cause I thought it would be OK to make the param > cumulative in that people could pass in one or more of the types and the > %product_hash would weed out duplicates. So updated the doc appropriately. > Of course if you feel we should only always allow one at a time, then I can > update the patch and go that route. this makes sense, however you also need to update the documentation for the webservice call to indicate that this is possible. ::: Bugzilla/WebService/Product.pm @@ +81,5 @@ > + my $found = 0; > + foreach my $type (@{ $params->{type} }) { > + next if !grep($type eq $_, qw(accessible enterable selectable)); > + my $method = "get_${type}_products"; > + my $result = $user->$method(); calling methods via a generated string is overkill when there are only three choices, and this approach won't generate an error if someone passes in a valid _and_ an invalid type.
Attachment #779210 -
Flags: review?(glob) → review-
Summary: Allow REST WebService API to for GET /product to allow retrieval of multiple product objects nstead of ids → Allow REST WebService API to for GET /product to allow retrieval of multiple product objects instead of ids
Assignee | ||
Comment 8•11 years ago
|
||
Attachment #779210 -
Attachment is obsolete: true
Attachment #779827 -
Flags: review?(glob)
Assignee | ||
Comment 9•11 years ago
|
||
Sorry. Missed the point about the error change. This should hopefully be it.
Attachment #779827 -
Attachment is obsolete: true
Attachment #779827 -
Flags: review?(glob)
Attachment #779832 -
Flags: review?(glob)
Comment 10•11 years ago
|
||
Comment on attachment 779832 [details] [diff] [review] Allow REST /product to return multiple products based on type, ids, or names (v4) Review of attachment 779832 [details] [diff] [review]: ----------------------------------------------------------------- r=glob ::: Bugzilla/WebService/Product.pm @@ +77,5 @@ > > + my $products = []; > + if (defined $params->{type}) { > + my %product_hash; > + my $found = 0; $found is unused can should be removed on commit
Attachment #779832 -
Flags: review?(glob) → review+
Assignee | ||
Comment 11•11 years ago
|
||
Committing to: bzr+ssh://dlawrence%40mozilla.com@bzr.mozilla.org/bugzilla/trunk modified Bugzilla/WebService/Product.pm modified Bugzilla/WebService/Server/REST/Resources/Product.pm modified template/en/default/global/user-error.html.tmpl Committed revision 8656.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•