← Back to team overview

launchpad-reviewers team mailing list archive

lp:~cody-somerville/launchpad/expose-authorized_size-attribute-via-api into lp:launchpad

 

Cody A.W. Somerville has proposed merging lp:~cody-somerville/launchpad/expose-authorized_size-attribute-via-api into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cody-somerville/launchpad/expose-authorized_size-attribute-via-api/+merge/93904

Expose the authorized_size attribute on archives via the webservice API.
-- 
https://code.launchpad.net/~cody-somerville/launchpad/expose-authorized_size-attribute-via-api/+merge/93904
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cody-somerville/launchpad/expose-authorized_size-attribute-via-api into lp:launchpad.
=== modified file 'lib/lp/soyuz/interfaces/archive.py'
--- lib/lp/soyuz/interfaces/archive.py	2012-01-18 14:30:52 +0000
+++ lib/lp/soyuz/interfaces/archive.py	2012-02-20 22:37:21 +0000
@@ -321,10 +321,11 @@
         description=_(
             "Create debug symbol packages for builds in the archive."))
 
-    authorized_size = Int(
-        title=_("Authorized size"), required=False,
-        max=2 ** 31 - 1,
-        description=_("Maximum size, in MiB, allowed for the archive."))
+    authorized_size = exported(
+        Int(
+            title=_("Authorized size"), required=False,
+            max=2 ** 31 - 1,
+            description=_("Maximum size, in MiB, allowed for the archive.")))
 
     purpose = Int(
         title=_("Purpose of archive."), required=True, readonly=True,

=== modified file 'lib/lp/soyuz/stories/webservice/xx-archive.txt'
--- lib/lp/soyuz/stories/webservice/xx-archive.txt	2012-01-06 11:08:30 +0000
+++ lib/lp/soyuz/stories/webservice/xx-archive.txt	2012-02-20 22:37:21 +0000
@@ -16,6 +16,7 @@
 
     >>> from lazr.restful.testing.webservice import pprint_entry
     >>> pprint_entry(cprov_archive)
+    authorized_size: 1024
     commercial: False
     dependencies_collection_link:
         u'http://.../~cprov/+archive/ppa/dependencies'
@@ -37,6 +38,7 @@
     >>> cprov_archive_devel = webservice.get(
     ...     "/~cprov/+archive/ppa", api_version='devel').jsonBody()
     >>> pprint_entry(cprov_archive_devel)
+    authorized_size: 1024
     commercial: False
     dependencies_collection_link: u'http://.../~cprov/+archive/ppa/dependencies'
     description: u'packages to help my friends.'
@@ -105,6 +107,7 @@
     >>> ubuntu_main_archive = webservice.get(
     ...     ubuntutest['main_archive_link']).jsonBody()
     >>> pprint_entry(ubuntu_main_archive)
+    authorized_size: None
     commercial: False
     dependencies_collection_link:
         u'http://.../ubuntutest/+archive/primary/dependencies'
@@ -917,6 +920,35 @@
     ...
     http_etag: You tried to modify a read-only attribute.
 
+Modifying authorized size
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Archives can have a quota to help moderate consumption of disk space
+resources. This quota is set via the authorized_size attribute which
+describes the maximum size, in MiB, allowed for the archive.
+
+    >>> mark_archive = webservice.get("/~mark/+archive/ppa").jsonBody()
+    >>> print mark_archive['authorized_size']
+    1024
+
+Modifying the authorized_size attribute through the API is not allowed except
+for admins and commercial admins.
+
+    >>> mark_archive['authorized_size'] = 4096
+    >>> response = modify_archive(admin_webservice, mark_archive)
+    >>> mark_archive = webservice.get("/~mark/+archive/ppa").jsonBody()
+    >>> print mark_archive['authorized_size']
+    4096
+
+Attempting to modify this flag without the necessary permissions will fail.
+
+    >>> mark_archive = webservice.get("/~mark/+archive/ppa").jsonBody()
+    >>> mark_archive['authorized_size'] = 1024
+    >>> print modify_archive(user_webservice, mark_archive)
+    HTTP/1.1 401 Unauthorized
+    ...
+    (<Archive at ...>, 'authorized_size', 'launchpad.Commercial')
+
 Private archives
 ~~~~~~~~~~~~~~~~
 
@@ -944,6 +976,7 @@
 the IArchive context, in this case only Celso has it.
 
     >>> pprint_entry(user_webservice.get("/~cprov/+archive/p3a").jsonBody())
+    authorized_size: 2048
     commercial: False
     dependencies_collection_link:
         u'http://.../~cprov/+archive/p3a/dependencies'
@@ -961,6 +994,7 @@
     web_link: u'http://launchpad.../~cprov/+archive/p3a'
 
     >>> pprint_entry(cprov_webservice.get("/~cprov/+archive/p3a").jsonBody())
+    authorized_size: 2048
     commercial: False
     dependencies_collection_link:
         u'http://.../~cprov/+archive/p3a/dependencies'


Follow ups