Speaking to the gitlab API is actually quite simple.

The user has to create his own private token with API access. Then gbp
would require a new config parameter to fetch such a token from the
.gitconfig of the user, or a new option to the create-remote-repo command to
provide it.

Then, if the user wants to create the repo in a specific namespace (group,
subgroup, whatever), he has to fetch the appropriate namespace_id. I didn't
find a basic method so far, but some urls contain it, so I found 2781 for
DPMT subgroup.

Then, it's only about designing a POST request:

I made a simple json file: temp/test.json
{
    "name": "apiproject",
    "namespace_id": 2781
}

Then, I ran

# curl -X "POST" -H 'Private-Token: {{priv_token}}' -H "Content-Type: 
application/json; charset=utf-8" https://salsa.debian.org/api/v4/projects -d 
"$(cat temp/test.json)"

{
    "id":12590,
    "description":null,
    "name":"apiproject",
    "name_with_namespace":"Debian Python Team / DPMT / apiproject",
    "path":"apiproject",
    "path_with_namespace":"python-team/modules/apiproject",
    "created_at":"2018-02-12T16:54:58.691Z",
    "default_branch":null,
    "tag_list":[],
    
"ssh_url_to_repo":"g...@salsa.debian.org:python-team/modules/apiproject.git",
    
"http_url_to_repo":"https://salsa.debian.org/python-team/modules/apiproject.git";,
    "web_url":"https://salsa.debian.org/python-team/modules/apiproject";,
    "avatar_url":null,
    "star_count":0,
    "forks_count":0,
    "last_activity_at":"2018-02-12T16:54:58.691Z",
    "_links":{
        "self":"http://salsa.debian.org/api/v4/projects/12590";,
        
"merge_requests":"http://salsa.debian.org/api/v4/projects/12590/merge_requests";,
        
"repo_branches":"http://salsa.debian.org/api/v4/projects/12590/repository/branches";,
        "labels":"http://salsa.debian.org/api/v4/projects/12590/labels";,
        "events":"http://salsa.debian.org/api/v4/projects/12590/events";,
        "members":"http://salsa.debian.org/api/v4/projects/12590/members";
    },
    "archived":false,
    "visibility":"private",
    "resolve_outdated_diff_discussions":false,
    "container_registry_enabled":true,
    "issues_enabled":false,
    "merge_requests_enabled":true,
    "wiki_enabled":true,
    "jobs_enabled":true,
    "snippets_enabled":true,
    "shared_runners_enabled":true,
    "lfs_enabled":true,
    "creator_id":1983,
    "namespace":{
        "id":2781,
        "name":"DPMT",
        "path":"modules",
        "kind":"group",
        "full_path":"python-team/modules",
        "parent_id":2779
    },
    "import_status":"none",
    "import_error":null,
    "runners_token":"such_token_much_wow",
    "public_jobs":true,
    "ci_config_path":null,
    "shared_with_groups":[],
    "only_allow_merge_if_pipeline_succeeds":false,
    "request_access_enabled":false,
    "only_allow_merge_if_all_discussions_are_resolved":false,
    "printing_merge_request_link_enabled":true
}

So, there are some parameters that'd require a default:

I suggest this template json for creating a remote repo:

{
    "name": "%(name)s",
    "namespace_id": %(namespace_id)d (if provided),
    "issues_enabled": true,
    "visibility": "public",
    "only_allow_merge_if_all_discussions_are_resolved": true
}

Python has plenty json api packages to send such json, so it's a matter of
implementation.

I could take some time to code that, but I'd rather we agree on the "how"
and the "what" before spending any time in such work.

-- 
Pierre-Elliott Bécue
GPG: 9AE0 4D98 6400 E3B6 7528  F493 0D44 2664 1949 74E2

Attachment: signature.asc
Description: PGP signature

Reply via email to