User:Clouserw/AMO/API: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
mNo edit summary
Line 1: Line 1:
* '''GET'''
We'll be using the [http://bitbucket.org/jespern/django-piston/wiki/Documentation#piston-documentation django-piston] library as a foundation so requests correspond to what piston defines.
** All GETs return ''Accept: application/json''
 
** data is returned as XML for legacy reasons, but adding a /format:rss switch is appealing.
* ''GET'' == ''READ''
* '''POST'''
* ''POST'' == ''CREATE''
** A POST will update data for an object.  If a field isn't specified in a POST its value is unchanged.
* ''PUT'' == ''UPDATE''
** Accepts JSON or multipart JSON + Files
* ''DELETE'' == ''REMOVE''
** A POST will accept data and return an appropriate response code.  In the body of the response it will return the new state of the resource.
 
* '''PUT'''
PUT and POST accept JSON and multipart JSON + Files (depending on the URL it's submitting to).  All URLs should send ''Accept: application/json'' headers.
** A PUT will replace all data for an object.  If a field isn't specified in a PUT, it is reset to the default.  We'll encourage PUTs on specific URLs, eg. ''/api/addon/:id/properties/description''
 
* '''DELETE'''
* '''OPTIONS'''
* '''OPTIONS'''
** Every URL should return a list of what it can accept with OPTIONS. Unknown requests will get a ''405 Method Not Allowed''
** If we have the opportunity (and maybe piston already does this?) but every URL should return a list of what it can accept with OPTIONS.


<span style="color:red">open questions are in red</span>
<span style="color:red">open questions are in red</span>
Line 26: Line 25:
   <tr>
   <tr>
       <td> </td>  
       <td> </td>  
      <td>Creates a new add-on with provided data (json+files)</td>
       <td></td>  
       <td></td>  
      <td>Creates a new add-on with provided data (json+files)</td>
       <td> </td>  
       <td> </td>  
   </tr>
   </tr>
Line 41: Line 40:
   </tr>  
   </tr>  
   <tr>
   <tr>
       <td style="background-color: #beb">Display add-on details ([https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/1865 done])</td>  
       <td style="background-color: #beb">Display add-on details ([https://services.addons.mozilla.org/en-US/firefox/api/1.5/addon/1865 done])</td>
      <td>Update the add-on details</td> 
       <td>(<span style="color:red">In theory we should replace everything about the add-on, but that's a scary thought.</span>)</td>  
       <td>(<span style="color:red">In theory we should replace everything about the add-on, but that's a scary thought.</span>)</td>  
      <td>Update the add-on details</td>
       <td>Remove the add-on. (<span style="color:red">also scary</span>)</td>  
       <td>Remove the add-on. (<span style="color:red">also scary</span>)</td>  
   </tr>
   </tr>
Line 104: Line 103:
   <tr>
   <tr>
       <td> </td>  
       <td> </td>  
      <td>Creates a new version.  301s to version detail page.</td>
       <td> </td>  
       <td> </td>  
      <td>Creates a new version.  301s to version detail page.</td>
       <td> </td>  
       <td> </td>  
   </tr>
   </tr>
Line 120: Line 119:
   <tr>
   <tr>
       <td>Returns version details</td>  
       <td>Returns version details</td>  
      <td>Updates the version details+file</td>
       <td>Replaces the version details+file</td>  
       <td>Replaces the version details+file</td>  
      <td>Updates the version details+file</td>
       <td>Removes the version</td>  
       <td>Removes the version</td>  
   </tr>
   </tr>
Line 146: Line 145:
   <tr>
   <tr>
       <td> </td>  
       <td> </td>  
      <td>Returns an .xpi file from submitted data.</td>
       <td> </td>  
       <td> </td>  
      <td>Returns an .xpi file from submitted data.</td>
       <td> </td>  
       <td> </td>  
   </tr>
   </tr>
Line 162: Line 161:
   <tr>
   <tr>
       <td> </td>  
       <td> </td>  
      <td>Validates the uploaded file and returns the results.</td>
       <td> </td>  
       <td> </td>  
      <td>Validates the uploaded file and returns the results.</td>
       <td> </td>  
       <td> </td>  
   </tr>
   </tr>
</table>
</table>


* <span style="color:red">TODO: Schema for each PUT/POST</span>
* <span style="color:red">TODO: Schema for partial updates</span>
* <span style="color:red">TODO: Schema for queue responses</span>
* <span style="color:red">TODO: Contributions stuff (backend isn't determined yet)</span>
* <span style="color:red">TODO: Contributions stuff (backend isn't determined yet)</span>
* Acknowledge HATEOAS
* Acknowledge HATEOAS
Line 176: Line 172:
== Notes ==
== Notes ==
==== Offline Processing ====
==== Offline Processing ====
One proposal for how to handle offline processing is to expose the queue via the API and UUIDs.  An example is probably the best explanation:
We'll handle offline processing by exposing the queue via the API and UUIDs.  An example is probably the best explanation:


# POST /api/addons
# POST /api/addons
Line 189: Line 185:
* http://bitbucket.org/jespern/django-piston/wiki/Documentation#piston-documentation
* http://bitbucket.org/jespern/django-piston/wiki/Documentation#piston-documentation
* http://github.com/fastsoft/djata#readme
* http://github.com/fastsoft/djata#readme
* http://code.google.com/p/django-rest-interface/
* http://code.google.com/p/django-rest-interface/ (too simple)
Confirmed users, Bureaucrats and Sysops emeriti
1,737

edits

Navigation menu