Confirmed users
1,927
edits
m (Link to finished API) |
(Changed most instances of "REST API" to "BzAPI"; updated intro) |
||
Line 1: | Line 1: | ||
This page attempts to list the differences between the Bugzilla [http://www.bugzilla.org/docs/tip/en/html/api/ XML-RPC/JSON-RPC API] (on the Bugzilla tip) and the [[Bugzilla:BzAPI|BzAPI REST API]] (on the BzAPI tip). The new [[Bugzilla:REST_API|native REST API]] is based very closely on the older RPC APIs. | |||
Please note that clients currently using BzAPI should migrate to BMO's native [[Bugzilla:BzAPI:CompatLayer|BzAPI compatibility layer]]. | |||
==High Level== | ==High Level== | ||
Line 9: | Line 9: | ||
{| border="1" | {| border="1" | ||
! Function | ! Function | ||
! | ! BzAPI | ||
! RPC | ! RPC | ||
|- | |- | ||
Line 37: | Line 37: | ||
|} | |} | ||
===RPC Calls Supplying Subsets of | ===RPC Calls Supplying Subsets of BzAPI /config Call=== | ||
{| border="1" | {| border="1" | ||
Line 52: | Line 52: | ||
|} | |} | ||
===RPC Calls Not In | ===RPC Calls Not In BzAPI=== | ||
====User==== | ====User==== | ||
Line 96: | Line 96: | ||
|} | |} | ||
====Not Needed For | ====Not Needed For BzAPI==== | ||
{| border="1" | {| border="1" | ||
Line 117: | Line 117: | ||
|} | |} | ||
=== | ===BzAPI Calls Not In RPC=== | ||
{| border="1" | {| border="1" | ||
! Function | ! Function | ||
! | ! BzAPI | ||
|- | |- | ||
| List flags for bug||/bug/<id>/flag GET (no specific call, although Bug.get returns the info) | | List flags for bug||/bug/<id>/flag GET (no specific call, although Bug.get returns the info) | ||
Line 140: | Line 140: | ||
Differences: | Differences: | ||
* | * BzAPI gives you the full power of the HTML query interface. The RPC API is a simple ANDed exact match search, covering only a limited number of fields. This is the major difference. | ||
The following differences are copied from the analysis of the call for returning a single bug. | The following differences are copied from the analysis of the call for returning a single bug. | ||
* | * BzAPI by default only returns those fields which can be returned by a Bugzilla search; the RPC returns a lot more fields by default. BzAPI can return the others, but it does an extra request under the covers. | ||
* | * BzAPI returns User objects instead of email addresses. | ||
* | * BzAPI does not return "creation_date" or "modification_date" on flags. | ||
* | * BzAPI returns Group objects (with name and ID) instead of group names. | ||
* | * BzAPI includes attachment metadata by default. The RPC API does not include any attachment data at all. | ||
* | * BzAPI includes comments if you ask for them using field control. The RPC API does not include comments. | ||
* | * BzAPI does not return the "is_open" field. | ||
* | * BzAPI returns a "ref" field. | ||
REST Unification Proposal: The semantics here are very different. I'm sure the Bugzilla team would like the RPC API to be a full search solution. So I propose that we do not implement this call in NATREST until we can implement it with full power, using the REST semantics - either separately or on top of full-power RPC. If we implement it on top of the current RPC implementation and then change it later, that will be a very big change from the current capabilities to the RPC ones, and then another very big change back later when we acquire full capabilities again. And when we implement it, we should make it return the full set of fields by default, not the limited set supported by the (default of the) current REST interface. | REST Unification Proposal: The semantics here are very different. I'm sure the Bugzilla team would like the RPC API to be a full search solution. So I propose that we do not implement this call in NATREST until we can implement it with full power, using the REST semantics - either separately or on top of full-power RPC. If we implement it on top of the current RPC implementation and then change it later, that will be a very big change from the current capabilities to the RPC ones, and then another very big change back later when we acquire full capabilities again. And when we implement it, we should make it return the full set of fields by default, not the limited set supported by the (default of the) current REST interface. | ||
Line 175: | Line 175: | ||
Differences: | Differences: | ||
* | * BzAPI returns only a single bug; the RPC API can return multiple bugs. | ||
* | * BzAPI does not support the experimental "permissive" boolean on requests. | ||
* The time tracking fields are defined as double in RPC, and Decimal in REST. | * The time tracking fields are defined as double in RPC, and Decimal in REST. | ||
* | * BzAPI returns User objects instead of email addresses. | ||
* | * BzAPI does not return "creation_date" or "modification_date" on flags. | ||
* | * BzAPI returns Group objects (with name and ID) instead of group names. | ||
* | * BzAPI includes attachment metadata by default. The RPC API does not include any attachment data at all. | ||
* | * BzAPI includes comments if you ask for them using field control. The RPC API does not include comments. | ||
* | * BzAPI does not return the "is_open" field. | ||
* | * BzAPI returns a "ref" field. | ||
Other than that, field name compatibility is very good. | Other than that, field name compatibility is very good. | ||
Line 196: | Line 196: | ||
Differences: | Differences: | ||
* | * BzAPI requires a valid "token" field. | ||
* | * BzAPI optionally does mid-air collision detection (by setting "last_change_time"). The RPC API does not. | ||
* | * BzAPI sends User objects instead of email addresses. | ||
* The RPC API has an "add/remove/set" model (with "set" sometimes not implemented) for some multi-valued fields where | * The RPC API has an "add/remove/set" model (with "set" sometimes not implemented) for some multi-valued fields where BzAPI simply has a "set" model. These are "blocks", "depends_on", "cc", "groups", "keywords" and "see_also". | ||
* Adding comments via REST involves adding a hash to an array; in RPC, it's a simple hash (with "body" and "is_private" members). | * Adding comments via REST involves adding a hash to an array; in RPC, it's a simple hash (with "body" and "is_private" members). | ||
* The RPC API has a mechanism for updating the privacy of existing comments - the comment_is_private hash. I'm not sure how | * The RPC API has a mechanism for updating the privacy of existing comments - the comment_is_private hash. I'm not sure how BzAPI handles that. | ||
* The RPC API permits the setting of "remaining_time", which is Read Only in | * The RPC API permits the setting of "remaining_time", which is Read Only in BzAPI. | ||
* | * BzAPI uses the JSON "null" value to "reset to default" for assignee and QA contact, whereas the RPC API has special boolean fields "reset_assigned_to" and "reset_qa_contact". | ||
* The RPC API returns much more info about the bug and the change than | * The RPC API returns much more info about the bug and the change than BzAPI does. | ||
REST Unification Proposal: We can abolish the need for a token; that is an artifact of the way the current REST implementation works on the back end. I would say we should keep the differences between RPC and REST relating to add/remove/set - that's a philosophical difference arising from the two different API types. The same is true in the smaller case of the methods of resetting assignee and QA contact to default. We should change | REST Unification Proposal: We can abolish the need for a token; that is an artifact of the way the current REST implementation works on the back end. I would say we should keep the differences between RPC and REST relating to add/remove/set - that's a philosophical difference arising from the two different API types. The same is true in the smaller case of the methods of resetting assignee and QA contact to default. We should change BzAPI to return change information. We should look at adding mid-air collision detection to the RPC API, as it's a useful feature. | ||
===List comments for bug=== | ===List comments for bug=== | ||
Line 224: | Line 224: | ||
* BzAPI does not return the (deprecated) "time" field; it returns "creation_time" (which RPC also returns). | * BzAPI does not return the (deprecated) "time" field; it returns "creation_time" (which RPC also returns). | ||
REST Unification Proposal: If we think it's worth it, we could add a /bug/<id>/comment/<id> call to return individual comments by ID, but I didn't add this to the API originally because I thought no-one would use it. And no-one has asked for it. So I suggest REST does not need that ability. Other than that, | REST Unification Proposal: If we think it's worth it, we could add a /bug/<id>/comment/<id> call to return individual comments by ID, but I didn't add this to the API originally because I thought no-one would use it. And no-one has asked for it. So I suggest REST does not need that ability. Other than that, BzAPI can start returning these missing fields, except for deprecated ones. | ||
===Add new comment to bug=== | ===Add new comment to bug=== | ||
Line 260: | Line 260: | ||
* The RPC API can take either a list of bug IDs or a list of attachment IDs, and returns different structures depending on which you give. This REST API takes a single bug ID only. | * The RPC API can take either a list of bug IDs or a list of attachment IDs, and returns different structures depending on which you give. This REST API takes a single bug ID only. | ||
* | * BzAPI returns "ref", "bug_ref", and "encoding" (only "base64" supported) fields which the RPC API does not. | ||
* | * BzAPI returns "description"; the RPC API also returns it, but is moving to call it "summary" | ||
* | * BzAPI returns "attacher"; the RPC API also returns it but is moving to call it "creator" | ||
* | * BzAPI does not have "creation_date" and "modification_date" for flags. | ||
* The RPC API returns a "last_change_time"; | * The RPC API returns a "last_change_time"; BzAPI does not. | ||
* | * BzAPI does not return attachment data by default. | ||
REST Unification Proposal: There are two REST APIs here mapping to a single RPC API. This REST API's URL structure is under /bug/<id> and so it makes sense for it to continue to return the attachments for that bug only. If there was demand (although I've not seen any), we could add a /attachment GET top-level attachment search call which could return attachments across multiple bugs. But the bug search interface already allows some searching by attachment data. The encoding field can be dropped if we are sure we'll never support anything other than base64, or if we have an API versioning scheme so we can add it back later if necessary. The REST field names could migrate to follow what RPC is doing, with a transition period. | REST Unification Proposal: There are two REST APIs here mapping to a single RPC API. This REST API's URL structure is under /bug/<id> and so it makes sense for it to continue to return the attachments for that bug only. If there was demand (although I've not seen any), we could add a /attachment GET top-level attachment search call which could return attachments across multiple bugs. But the bug search interface already allows some searching by attachment data. The encoding field can be dropped if we are sure we'll never support anything other than base64, or if we have an API versioning scheme so we can add it back later if necessary. The REST field names could migrate to follow what RPC is doing, with a transition period. BzAPI needs to return the missing fields. But I think it's wisest not to return attachment data by default - the principle of least surprise suggests you should opt in to a 15MB or more blob of data. | ||
===Retrieve attachment=== | ===Retrieve attachment=== | ||
Line 276: | Line 276: | ||
* The RPC API can take either a list of bug IDs or a list of attachment IDs, and returns different structures depending on which you give. This REST API takes a single attachment ID only. | * The RPC API can take either a list of bug IDs or a list of attachment IDs, and returns different structures depending on which you give. This REST API takes a single attachment ID only. | ||
* | * BzAPI returns "ref", "bug_ref", and "encoding" (only "base64" supported) fields which the RPC API does not. | ||
* | * BzAPI returns "description"; the RPC API also returns it, but is moving to call it "summary" | ||
* | * BzAPI returns "attacher"; the RPC API also returns it but is moving to call it "creator" | ||
* | * BzAPI does not have "creation_date" and "modification_date" for flags. | ||
* The RPC API returns a "last_change_time"; | * The RPC API returns a "last_change_time"; BzAPI does not. | ||
* | * BzAPI does not return attachment data by default. | ||
REST Unification Proposal: See above, as there are two REST APIs here mapping to a single RPC API. | REST Unification Proposal: See above, as there are two REST APIs here mapping to a single RPC API. | ||
Line 291: | Line 291: | ||
Differences: | Differences: | ||
* The RPC API allows a single uploaded attachment to be added to multiple bugs at once. | * The RPC API allows a single uploaded attachment to be added to multiple bugs at once. BzAPI does not. | ||
* The above also means the RPC API takes an "ids" array whereas | * The above also means the RPC API takes an "ids" array whereas BzAPI takes a "bug_id" parameter. | ||
* | * BzAPI allows you to add a comment at the same time; the RPC API does not. | ||
* | * BzAPI uses "description"; RPC is moving to use "summary". | ||
* | * BzAPI allows you to set flags on the attachment; the RPC API does not. | ||
REST Unification Proposal: | REST Unification Proposal: BzAPI could not add the ability to post to multiple bugs at once (who uses that?) because the URL structure indicates a single bug. The RPC API needs to grow BzAPI's other abilities here, but REST needs to migrate to "summary" from "description". | ||
===Search for users=== | ===Search for users=== | ||
Line 532: | Line 532: | ||
} | } | ||
REST Unification Proposal: Implement as PUT /group/15. (We need to discuss return values - | REST Unification Proposal: Implement as PUT /group/15. (We need to discuss return values - BzAPI currently does not return change information of the above form. -- Gerv) | ||
===Create a new product=== | ===Create a new product=== | ||
Line 590: | Line 590: | ||
} | } | ||
REST Unification Proposal: Implement as PUT /product/35. (We need to discuss return values - | REST Unification Proposal: Implement as PUT /product/35. (We need to discuss return values - BzAPI currently does not return change information of the above form. -- Gerv) | ||
===Offer account by email=== | ===Offer account by email=== | ||
Line 659: | Line 659: | ||
} | } | ||
REST Unification Proposal: Implement as PUT /user/<email>. (We need to discuss return values - | REST Unification Proposal: Implement as PUT /user/<email>. (We need to discuss return values - BzAPI currently does not return change information of the above form. -- Gerv) | ||
==REST Calls Not In RPC: Details== | ==REST Calls Not In RPC: Details== | ||
Line 697: | Line 697: | ||
An RPC API is "Remote Procedure Call" - the idea is that you call a function on the server which does what you want, and returns. A REST API is REpresentational State Transfer - the idea is that you transfer the full state of an object in either direction, which would be the entire new state if you are updating it. This difference means that a good RPC API and a good REST API will inevitably have different approaches on some points. So, for example, the RPC API has a Bug.update_see_also call, which only updates the See Also field. That makes perfect sense in an RPC world, but not in a REST world, where the appropriate way of updating a bug is to get a copy of it, modify it, and resend that modified copy back again. | An RPC API is "Remote Procedure Call" - the idea is that you call a function on the server which does what you want, and returns. A REST API is REpresentational State Transfer - the idea is that you transfer the full state of an object in either direction, which would be the entire new state if you are updating it. This difference means that a good RPC API and a good REST API will inevitably have different approaches on some points. So, for example, the RPC API has a Bug.update_see_also call, which only updates the See Also field. That makes perfect sense in an RPC world, but not in a REST world, where the appropriate way of updating a bug is to get a copy of it, modify it, and resend that modified copy back again. | ||
Another example is that REST URLs refer to individual objects - e.g. /bug/<id> GET refers to a single bug. Multiple bugs are retrieved using the /bug GET search API. In | Another example is that REST URLs refer to individual objects - e.g. /bug/<id> GET refers to a single bug. Multiple bugs are retrieved using the /bug GET search API. In BzAPI, it seems that both the search and the bug retrieval API have the ability to return multiple bugs. Again, this is fine for a remote procedure call, but is not REST-y. | ||
====Objects vs. IDs==== | ====Objects vs. IDs==== | ||
Line 705: | Line 705: | ||
====Multiple values for a field==== | ====Multiple values for a field==== | ||
The RPC API has an add/remove/set model for updating fields with multiple values, such as "blocks", "depends_on", "cc", "groups", "keywords" and "see_also". | The RPC API has an add/remove/set model for updating fields with multiple values, such as "blocks", "depends_on", "cc", "groups", "keywords" and "see_also". BzAPI has only a "set" model, because of the differences exampled above. | ||
===Config information=== | ===Config information=== | ||
BzAPI returns one single large config info JSON structure. The RPC API has a more fine-grained approach, and does not provide as much information even if you add it up from all the possible calls. This is an API design difference, although not one which comes directly from REST principles. The resolution of this difference one way or the other will be more pragmatic. | |||
===Error handling=== | ===Error handling=== | ||
BzAPI returns various different flavors of error depending on the underlying implementation, whereas the RPC API simply returns an error code and description. The REST errors need to be more standardized. | |||
REST also makes use of HTTP status codes to designate types of errors. RPC normally returns the same HTTP status code even in an error condition and the client checks the payload to see if an error occurred. | REST also makes use of HTTP status codes to designate types of errors. RPC normally returns the same HTTP status code even in an error condition and the client checks the payload to see if an error occurred. |