1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
= Creating a PPA =
>>> from zope.component import getUtility
>>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
>>> from lp.testing import celebrity_logged_in
>>> from lp.testing.sampledata import ADMIN_EMAIL
>>> login(ADMIN_EMAIL)
>>> owner = factory.makePerson()
>>> url = "/~%s" % owner.name
>>> logout()
>>> ppa_owner = webservice.get(url).jsonBody()
>>> from canonical.launchpad.testing.pages import webservice_for_person
>>> from canonical.launchpad.webapp.interfaces import OAuthPermission
>>> ppa_owner_webservice = webservice_for_person(
... owner, permission=OAuthPermission.WRITE_PRIVATE)
>>> print ppa_owner_webservice.named_post(
... ppa_owner['self_link'], 'createPPA', {}, name=None,
... displayname='My shiny new PPA', description='Shinyness!',
... )
HTTP/1.1 201 Created
Status: 201
...
Location: http://api.launchpad.dev/.../+archive/ppa
...
>>> print ppa_owner_webservice.named_post(
... ppa_owner['self_link'], 'createPPA', {}, name='ubuntu',
... displayname='My shiny new PPA', description='Shinyness!',
... )
HTTP/1.1 400 Bad Request
Status: 400 Bad Request
...
A PPA cannot have the same name as its distribution.
== Creating private PPAs ==
Our PPA owner now has a single PPA.
>>> print_self_link_of_entries(webservice.get(
... ppa_owner['ppas_collection_link']).jsonBody())
http://api.launchpad.dev/beta/~.../+archive/ppa
They aren't a commercial admin, so they cannot create private PPAs.
>>> print ppa_owner_webservice.named_post(
... ppa_owner['self_link'], 'createPPA', {}, name='whatever',
... displayname='My secret new PPA', description='Secretness!',
... private=True,
... )
HTTP/1.1 400 Bad Request
Status: 400
...
... is not allowed to make private PPAs
After attempting and failing to create a private PPA, they still have the same
single PPA they had at the beginning:
>>> print_self_link_of_entries(webservice.get(
... ppa_owner['ppas_collection_link']).jsonBody())
http://api.launchpad.dev/beta/~.../+archive/ppa
However, we can grant them commercial admin access:
>>> with celebrity_logged_in('admin'):
... comm = getUtility(ILaunchpadCelebrities).commercial_admin
... comm.addMember(owner, comm.teamowner)
(True, <DBItem TeamMembershipStatus.APPROVED, (2) Approved>)
Once they have commercial access, they can create private PPAs:
>>> print ppa_owner_webservice.named_post(
... ppa_owner['self_link'], 'createPPA', {}, name='secret',
... displayname='My secret new PPA', description='Secretness!',
... private=True,
... )
HTTP/1.1 201 Created
Status: 201
...
Location: http://api.launchpad.dev/.../+archive/secret
...
And the PPA appears in their list of PPAs:
>>> print_self_link_of_entries(webservice.get(
... ppa_owner['ppas_collection_link']).jsonBody())
http://api.launchpad.dev/.../+archive/ppa
http://api.launchpad.dev/.../+archive/secret
And the PPA is, of course, private:
>>> ppa = ppa_owner_webservice.named_get(
... ppa_owner['self_link'], 'getPPAByName', name='secret').jsonBody()
>>> ppa['private']
True
|