"""
#  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())
