#!/bin/python # simple remote repository creation test # https://git.acc.gsi.de/api/swagger#/organization/createOrgRepo import requests import json project='TODO' user='TODO' password='TODO' #url = 'https://git.acc.gsi.de/api/v1/org/fesa-deploy-units/repos' url = 'https://git.acc.gsi.de/api/v1/org/fesa-classes/repos' payload = { "auto_init":True, "description": "Software Repository of " + project, "gitignores":"C++", "name":project, "private":True, "readme":"Default" } header = {"Content-type": "application/json", "Accept": "application/json"} print("Pushing project " + project + " to url " + str(url)) response = requests.post(url, json=payload, headers=header, auth=requests.auth.HTTPBasicAuth(user, password)) print ("Return code: " + str(response)) if response.ok: data = response.content print ("Data returned: " + str(data) + " " + str(len(data))) if data is not None and len(data)>0: jData = json.loads(data) print("The response contains {0} objects.".format(len(jData))) print("\n") for key in jData: print (key + " : " + str(jData[key])) else: print ("Return code: " + str(response.content)) print ("Return code: " + str(response.text)) print ("Error. Nothing done.")