You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
montpelliermaalsi2024/api/create_one_repo.py

55 lines
1.4 KiB
Python

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

"""
#  XXX TODO : fournir la bonne URL
#  XXX TODO : fournir le bon application token
sur la page du compte utilisateur de (admin)
la page de configuration **perso** /user/settings
> settings > application > générer un jeton d'authentification
http://forge:port/user/settings/applications
API doc swagger :
https://forge.gwenaelremond.fr/api/swagger/
https://<url>/api/swagger#/admin/adminCreateUser
il y a:
- créer un repo comme admin
- créer un repo comme user
https://forge.gwenaelremond.fr/api/v1/user/repos
"""
# ______________________________________________________________________________
import requests
# ______________________________________________________________________________
# configuration
"repo name"
name = "essai"
url = 'https://forge.gwenaelremond.fr/api/v1/user/repos'
token = 'XXX'
# ______________________________________________________________________________
headers = {
'accept': 'application/json',
'Content-Type': 'application/json; indent=4',
'Authorization': 'token {}'.format(token)
}
#{'Authorization': 'token myToken'}
#'X-Auth-Token': token
#{
# "default_branch": "string",
# "description": "string",
# "name": "string",
# "readme": "string",
#}
data = {
"description": name,
"default_branch": "main",
"name": name,
"private": False,
}
response = requests.post(url, headers=headers, json=data)
print("réponse : ", response.json())