forked from allisson/python-simple-rest-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.py
More file actions
28 lines (24 loc) · 1.43 KB
/
github.py
File metadata and controls
28 lines (24 loc) · 1.43 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
from simple_rest_client.api import API
from simple_rest_client.resource import Resource
class EventResource(Resource):
actions = {
'public_events': {'method': 'GET', 'url': 'events'},
'repository_events': {'method': 'GET', 'url': '/repos/{}/{}/events'},
'repository_issues_events': {'method': 'GET', 'url': '/repos/{}/{}/issues/events'},
'public_network_events': {'method': 'GET', 'url': '/networks/{}/{}/events'},
'public_organization_events': {'method': 'GET', 'url': '/orgs/{}/events'},
'user_received_events': {'method': 'GET', 'url': '/users/{}/received_events'},
'public_user_received_events': {'method': 'GET', 'url': '/users/{}/received_events/public'},
'user_events': {'method': 'GET', 'url': '/users/{}/events'},
'public_user_events': {'method': 'GET', 'url': '/users/{}/events/public'},
'organization_events': {'method': 'GET', 'url': '/users/{}/events/orgs/{}'},
}
# https://github.com/settings/tokens
default_params = {'access_token': 'valid-token'}
github_api = API(
api_root_url='https://api.github.com', params=default_params,
json_encode_body=True
)
github_api.add_resource(resource_name='events', resource_class=EventResource)
print('github_api.events.public_events={!r}'.format(github_api.events.public_events()))
print('github_api.events.repository_events={!r}'.format(github_api.events.repository_events('allisson', 'python-simple-rest-client')))