Confirmed users
920
edits
LesOrchard (talk | contribs) No edit summary |
LesOrchard (talk | contribs) No edit summary |
||
Line 155: | Line 155: | ||
** Status: <tt>200 OK</tt> | ** Status: <tt>200 OK</tt> | ||
** Content-Type: [[#Addon Collection]] | ** Content-Type: [[#Addon Collection]] | ||
===== PUT - Update collection details ===== | |||
Note that this update is limited to collection-specific details, and cannot | |||
modify any of the other data that makes up an addon document. | |||
* Request | |||
** Content-Type: <tt>application/x-www-form-urlencoded</tt> | |||
** Parameters: | |||
*** <tt>name</tt> - human readable name for the collection | |||
*** <tt>description</tt> - human readable longer description for the collection | |||
*** <tt>nickname</tt> - unique nickname for collection usable in URLs | |||
*** <tt>listed</tt> - whether the collection should be listed in the directory (<tt>1</tt>) or not (<tt>0</tt>) | |||
* Response (on success) | |||
** Status: <tt>200 OK</tt> | |||
** Content-Type: [[#Addon Collection]] | |||
** Response content reflects changes to collection | |||
===== DELETE - Delete a collection ===== | ===== DELETE - Delete a collection ===== | ||
Line 192: | Line 210: | ||
A concrete URL for this kind of resource can be acquired from an [[#Addon Collection]]. | A concrete URL for this kind of resource can be acquired from an [[#Addon Collection]]. | ||
===== GET - Fetch details on an addon ===== | |||
* Response (on success) | |||
** Status: <tt>200 OK</tt> | |||
** Content-Type: [[#Addon]] | |||
===== PUT - Update addon details ===== | |||
Note that this update is limited to collection-specific details, and cannot | |||
modify any of the other data that makes up an addon document. | |||
* Request | * Request | ||
Line 553: | Line 576: | ||
Note the <tt>xml:base</tt> attribute on <tt>sharing</tt> and the <tt>href</tt> | Note the <tt>xml:base</tt> attribute on <tt>sharing</tt> and the <tt>href</tt> | ||
attribute on <tt>collections</tt>. Use those together to | attribute on <tt>collections</tt>. Use those together to resolve an | ||
absolute URL, and that's the collections resource URL: | absolute URL, and that's the collections resource URL: | ||
Line 569: | Line 592: | ||
X-Powered-By: PHP/5.2.6 | X-Powered-By: PHP/5.2.6 | ||
X-AMO-ServedBy: quadshot-2.local | X-AMO-ServedBy: quadshot-2.local | ||
Location: http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109 | Location: http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/ | ||
Content-Length: 0 | Content-Length: 0 | ||
Content-Type: text/html | Content-Type: text/html | ||
Line 599: | Line 622: | ||
creator="Sancus" | creator="Sancus" | ||
listed="yes" writable="yes" subscribed="no" | listed="yes" writable="yes" subscribed="no" | ||
lastmodified="2009-02- | lastmodified="2009-02-19T19:05:55-05:00"> | ||
<addons href="addons/"> | |||
</addons> | |||
</collection> | </collection> | ||
==== Adding an addon to a collection ==== | ==== Adding an addon to a collection ==== | ||
Notice that the new collection offers an <tt>addon</tt> element with an | |||
<tt>href</tt> attribute. Once resolved using <tt>xml:base</tt>, you can POST | |||
to this URL to add an addon: | |||
$ curl -sD - -u "$USER:$PASSWD" -XPOST \ | $ curl -sD - -u "$USER:$PASSWD" -XPOST \ | ||
-d 'guid=farming%40microfarmer.org&comments=I+really+like+this+addon' \ | -d 'guid=farming%40microfarmer.org&comments=I+really+like+this+addon' \ | ||
'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/' | 'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/' | ||
HTTP/1.1 201 Created | HTTP/1.1 201 Created | ||
Line 620: | Line 649: | ||
Content-Type: text/html | Content-Type: text/html | ||
And you can | And you can GET the URL in the <tt>Location:</tt> header: | ||
$ curl -sD - -u "$USER:$PASSWD" -XGET \ | $ curl -sD - -u "$USER:$PASSWD" -XGET \ | ||
Line 654: | Line 683: | ||
<!-- details omitted... --> | <!-- details omitted... --> | ||
</addon> | </addon> | ||
A GET request to the collection will show that the addon has been added: | |||
$ curl -sD - -u "$USER:$PASSWD" -XGET \ | $ curl -sD - -u "$USER:$PASSWD" -XGET \ | ||
Line 665: | Line 690: | ||
HTTP/1.1 200 OK | HTTP/1.1 200 OK | ||
Date: Thu, 19 Feb 2009 22: | Date: Thu, 19 Feb 2009 22:12:15 GMT | ||
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6 | Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6 | ||
X-Powered-By: PHP/5.2.6 | X-Powered-By: PHP/5.2.6 | ||
X-AMO-ServedBy: quadshot-2.local | X-AMO-ServedBy: quadshot-2.local | ||
Cache-Control: public, max-age=3600 | Cache-Control: public, max-age=3600 | ||
Last-modified: Thu, 19 Feb 2009 22: | Last-modified: Thu, 19 Feb 2009 22:12:15 GMT | ||
Expires: Thu, 19 Feb 2009 23: | Expires: Thu, 19 Feb 2009 23:12:15 GMT | ||
Transfer-Encoding: chunked | Transfer-Encoding: chunked | ||
Content-Type: text/xml | Content-Type: text/xml | ||
<?xml version="1.0" encoding="utf-8" ?> | <?xml version="1.0" encoding="utf-8" ?> | ||
<collection xmlns="http://addons.mozilla.org/" | <collection xmlns="http://addons.mozilla.org/" | ||
xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109 | xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/" | ||
name="Foo Bar" | name="Foo Bar" | ||
description="collection of foobar addons" | description="collection of foobar addons" | ||
creator="Sancus" | creator="Sancus" | ||
listed="yes" writable="yes" subscribed="no" | listed="yes" writable="yes" subscribed="no" | ||
lastmodified="2009-02-19T17: | lastmodified="2009-02-19T19:05:55-05:00"> | ||
<addons href="addons/"> | |||
<addon href="addons/farming%40microfarmer.org"> | |||
<meta> | |||
<added>2009-02-19T17:10:50-05:00</added> | |||
<addedby>Sancus</addedby> | |||
<comments>I really like this addon</comments> | |||
</meta> | |||
<categories> | |||
<category id="12">Organizer</category> | |||
<category id="13">Web Data</category> | |||
</categories> | |||
<name>MicroFarmer</name> | |||
<type id='1'>Extension</type> | |||
<guid>farming@microfarmer.org</guid> | |||
<version>9</version> | |||
<!-- details omitted... --> | |||
</addon> | |||
</addons> | |||
</collection> | |||
==== Updating an addon in a collection ==== | |||
Later, if you want to make an update to this addon in the collection, you | |||
can make a PUT request to the addon URL: | |||
$ curl -sD - -u "$USER:$PASSWD" -XPUT \ | |||
-d 'comments=This+addon+is+really+swell' \ | |||
'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org' | |||
HTTP/1.1 200 OK | |||
Date: Fri, 20 Feb 2009 00:10:32 GMT | |||
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6 | |||
X-Powered-By: PHP/5.2.6 | |||
X-AMO-ServedBy: quadshot-2.local | |||
Cache-Control: public, max-age=3600 | |||
Last-modified: Fri, 20 Feb 2009 00:10:32 GMT | |||
Expires: Fri, 20 Feb 2009 01:10:32 GMT | |||
Transfer-Encoding: chunked | |||
Content-Type: text/xml | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<addon xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org"> | |||
<meta> | |||
<added>2009-02-19T17:10:50-05:00</added> | |||
<addedby>Sancus</addedby> | |||
</meta> | <comments>This addon is really swell</comments> | ||
<collection href=".." /> | |||
</meta> | |||
<categories> | |||
<category id="12">Organizer</category> | |||
<category id="13">Web Data</category> | |||
</categories> | |||
<name>MicroFarmer</name> | |||
<type id='1'>Extension</type> | |||
<guid>farming@microfarmer.org</guid> | |||
<version>9</version> | |||
<!-- details omitted... --> | |||
</addon> | |||
==== Deleting an addon from a collection ==== | |||
Finally, if you want to remove this addon from the collection, make a DELETE | |||
request to the addon URL: | |||
$ curl -sD - -u "$USER:$PASSWD" -XDELETE \ | |||
'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/129/addons/farming%40microfarmer.org' | |||
HTTP/1.1 410 Gone | |||
Date: Fri, 20 Feb 2009 00:12:18 GMT | |||
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6 | |||
X-Powered-By: PHP/5.2.6 | |||
X-AMO-ServedBy: quadshot-2.local | |||
Content-Length: 0 | |||
Content-Type: text/html | |||
The addon URL can no longer be found: | |||
$ curl -sD - -u "$USER:$PASSWD" -XGET \ | |||
'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/addons/farming%40microfarmer.org' | |||
HTTP/1.1 404 Not Found | |||
Date: Fri, 20 Feb 2009 00:12:57 GMT | |||
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6 | |||
X-Powered-By: PHP/5.2.6 | |||
X-AMO-ServedBy: quadshot-2.local | |||
Cache-Control: public, max-age=3600 | |||
Last-modified: Fri, 20 Feb 2009 00:12:58 GMT | |||
Expires: Fri, 20 Feb 2009 01:12:58 GMT | |||
Content-Length: 120 | |||
Content-Type: text/xml | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<error xmlns="http://addons.mozilla.org/" reason="addon_not_in_collection" /> | |||
And, the addon no longer appears in the collection: | |||
$ curl -sD - -u "$USER:$PASSWD" -XGET \ | |||
'http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/' | |||
HTTP/1.1 200 OK | |||
Date: Fri, 20 Feb 2009 00:13:55 GMT | |||
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.6 | |||
X-Powered-By: PHP/5.2.6 | |||
X-AMO-ServedBy: quadshot-2.local | |||
Cache-Control: public, max-age=3600 | |||
Last-modified: Fri, 20 Feb 2009 00:13:55 GMT | |||
Expires: Fri, 20 Feb 2009 01:13:55 GMT | |||
Content-Length: 440 | |||
Content-Type: text/xml | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<collection xmlns="http://addons.mozilla.org/" | |||
xml:base="http://dev-bandwagon.addons.mozilla.org/en-US/firefox/api/1.3/sharing/collections/109/" | |||
name="Foo Bar" | |||
description="collection of foobar addons" | |||
creator="Sancus" | |||
listed="yes" writable="yes" subscribed="no" | |||
lastmodified="2009-02-19T19:05:55-05:00"> | |||
<addons href="addons/"> | |||
</addons> | |||
</collection> |