-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathAppVeyor.py
More file actions
49 lines (40 loc) · 1.63 KB
/
AppVeyor.py
File metadata and controls
49 lines (40 loc) · 1.63 KB
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
# Copyright 2012-2017 Jonathan Paugh and contributors
# See COPYING for license details
# AppVeyor REST API: https://www.appveyor.com/docs/api/
# Version 1.0 (2017-02-13) by topic2k@atlogger.de
from arestclient.base import API, ConnectionProperties, Client
class AppVeyor(API):
"""
The agnostic AppVeyor API. It doesn't know, and you don't care.
>>> from arestclient.AppVeyor import AppVeyor
>>> ci = AppVeyor('<your AppVeyor API token>')
>>> status, data = ci.api.projects.get()
>>> data
... [ list_, of, stuff ]
>>> status, data = ci.api.projects.topic2k.eventghost.get()
>>> data
... { 'project': <project data>, }
>>> account_name = 'topic2k'
>>> project_slug = 'eventghost'
>>> status, data = ci.api.projects[account_name][project_slug].get()
... same as above
>>> status, data = ci.api.projects.topic2k.eventghost.buildcache.delete()
>>> status
... 204
That's all there is to it. (blah.post() should work, too.)
NOTE: It is up to you to spell things correctly. An AppVeyor object
doesn't even try to validate the url you feed it. On the other hand,
it automatically supports the full API--so why should you care?
"""
def __init__(self, token, accept='application/json', *args, **kwargs):
extra_headers = dict(
Accept=accept,
Authorization='Bearer {0}'.format(token)
)
props = ConnectionProperties(
api_url='ci.appveyor.com',
secure_http=True,
extra_headers=extra_headers
)
self.setClient(Client(*args, **kwargs))
self.setConnectionProperties(props)