Last active
August 29, 2015 14:15
-
-
Save itsbenweeks/e1211dbeef29581e138b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
GHE_URI = "http://github.mit.edu/api/v3" | |
GHE_TOKEN = open('GHE_TOKEN', 'r').read()[:-1] | |
S = requests.Session() | |
S.headers.update({u'Authorization': u'token {0}'.format(GHE_TOKEN)}) | |
S.headers.update({u'Time-Zone': u'America/New_York'}) | |
def create_repo(org, repo_name, template=None): | |
post_url = u'{0}/orgs/{1}/repos'.format( | |
GHE_URI, | |
org) | |
post_data = { | |
"name": repo_name, | |
"description": "This is but a test", | |
"homepage": "https://staging.mitx.mit.edu/", | |
"private": True, | |
"has_wiki": False, | |
"has_downloads": False | |
} | |
response = S.post(post_url, data=json.dumps(post_data)) | |
print(response.json()) | |
def remove_hooks(org, repo_name): | |
hook_url = u'{0}/repos/{1}/{2}/hooks'.format( | |
GHE_URI, | |
org, | |
repo_name) | |
hooks = S.get(hook_url).json() | |
for hook in hooks: | |
S.delete(hook['url']) | |
def add_hook(org, repo_name, hook_url): | |
post_url = u'{0}/repos/{1}/{2}/hooks'.format( | |
GHE_URI, | |
org, | |
repo_name) | |
post_data = {"name": "web", | |
"active": True, | |
"events": [ | |
"push"], | |
"config": { | |
"url": hook_url, | |
"content_type": "form"} | |
} | |
S.post(post_url, data=json.dumps(post_data)) | |
def find_teams(org, search_term=None): | |
if search_term: | |
search_term | |
def add_team(org, repo, team_name): | |
S.post(u'') | |
def move_teams(org, source_repo, dest_repo): | |
S.post(u'') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment