basyura's blog

あしたになったらほんきだす。

GitLab - コマンドラインから API を叩いてユーザを登録する

GitLab の API をコマンドラインで叩けるツール。

gitlab user create --email [email] --username [username] --name [name] --password [password] --confirm no
  • —confirm = no を指定すると認証をスキップする
  • update 時に指定すると変更されないっぽい (gitlab の引数リストには出てくるけど API ドキュメントには乗ってない)

Install

pip install python-gitlab

Config

~/.python-gitlab.cfg に設定を記述

[global]
default = somewhere
ssl_verify = true
timeout = 5

[somewhere]
url = https://some.whe.re
private_token = vTbFeqJYCY3sibBP7BZM

[elsewhere]
url = http://else.whe.re:8080
private_token = CkqsjqcQSFH5FQKDccu4
timeout = 1

User creation

Creates a new user. Note only administrators can create new users.

POST /users

Parameters:

  • email (required) - Email
  • password (required) - Password
  • username (required) - Username
  • name (required) - Name
  • skype (optional) - Skype ID
  • linkedin (optional) - LinkedIn
  • twitter (optional) - Twitter account
  • website_url (optional) - Website URL
  • projects_limit (optional) - Number of projects user can create
  • extern_uid (optional) - External UID
  • provider (optional) - External provider name
  • bio (optional) - User's biography
  • admin (optional) - User is admin - true or false (default)
  • can_create_group (optional) - User can create groups - true or false
  • confirm (optional) - Require confirmation - true (default) or false
User creation

User modification

Modifies an existing user. Only administrators can change attributes of a user.

PUT /users/:id

Parameters:

  • email - Email
  • username - Username
  • name - Name
  • password - Password
  • skype - Skype ID
  • linkedin - LinkedIn
  • twitter - Twitter account
  • website_url - Website URL
  • projects_limit - Limit projects each user can create
  • extern_uid - External UID
  • provider - External provider name
  • bio - User's biography
  • admin (optional) - User is admin - true or false (default)
  • can_create_group (optional) - User can create groups - true or false
User modification