Calling API by SSH or by CURL
When requesting data by http, use POST not GET.
Request fields:
'cmd' - what command to execute
'opaque' - it is passed back in the answer, unaltered.
'user/uid' - the target user; if missing, it is the login user.
Possible commands:
user_info
user_rights_list
user_ssh_keys_list
user_wh_list
repo_list
repo_info
repo_bug_list
repo_bug_info
repo_mr_list
Example of error:
$ curl --header 'Authorization: bla this_is_your_api_key' \
--data '{"cmd": "invalid_cmd", "user": "bla"}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api invalid_cmd
{
"cmd": "invalid_cmd",
"error": "invalid command"
}
user_info
Description: List information about a user
Parameters: user/uid [optional]
Example:
$ curl --header 'Authorization: bla this_is_your_api_key' \
--data '{"cmd": "user_info", "user": "bla"}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api user_info user=bla
{
"cmd": "user_info",
"ok": 1,
"exists": 1,
"uid": "846",
"is_admin": "0",
"rights": "C",
"homepage": "\/user\/bla",
"username": "bla",
"email": "bla@example.com",
"itime": "1440834245",
"suspended": null,
"session_time": "3600",
"last_seen": "1464805192",
"disk_used_mb": "0",
"git_mb": "0",
"artifacts_mb": "0",
"confirmed": "1468297652",
"organization": "0",
"realname": "my real name",
"plan_id": "0",
"last_ip": "192.168.79.154",
"itime_nice": "2015-08-29",
"email_md5": "60b725f10c9c85c70d97880dfe8191b3",
"HTML:gravatar": "<img src=\"https:\/\/www.gravatar.com\/avatar\/60...b3?s=64&r=g\" alt=\"avatar\" width=\"64\" height=\"64\" \/>"
}
user_rights_list
Description: Lists user defined rights
Parameters: user/uid [optional]
Example:
$ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
--data '{"cmd": "user_rights_list", "user": "bla"}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api user_rights_list user=bla
{
"cmd": "user_rights_list",
"list": [
{
"type": "repo_path",
"obj_id": "831",
"uid": "0",
"rights": "P",
"itime": "1450417938",
"misc": "",
"prio": "100",
"who": "846",
"right_id": "79",
"ip": "",
"misc2": "",
"description": "dfdsfds",
"username": "*",
"who_name": "catab",
"rights_text": "Push",
"itime_text": "2015-12-18 05:52",
"ip_nice": "Any",
"HTML:description_nlbr": "dfdsfds",
"can_be_deleted": 1
},
...
]
}
user_ssh_keys_list
Description: Lists SSH keys of a user
Parameters: user/uid [optional]
Example:
$ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
--data '{"cmd": "user_ssh_keys_list", "user": "bla"}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api user_ssh_keys_list user=bla
{
"cmd": "user_ssh_keys_list",
"list": [
{
"ok": 1,
"type": "ssh-rsa",
"comment": "Key for rocketgit - r1i",
"key": "AAAAB3NzaC1yc2...yTRiD8gFdg9UT1bw==",
"bits": 4096,
"fingerprint_md5": "b1:fd:5f:f0:53:f5:9c:31:b2:de:ff:00:1c:f1:c5:61",
"fingerprint_sha256": "SNPwFw0Snaz7pdUAFV4Lrf8LFHqx93I7VmW5LsjTlLS0",
"key_id": "438",
"itime": "2016-01-27 21:11",
"first_use": "2016-01-27 21:13",
"last_ip": "192.168.79.154",
"last_use": "2016-01-29 18:27",
"last_cmd": "git-receive-pack '\/user\/catab\/delme10'",
"count": "27"
},
...
]
}
user_wh_list
Description: Lists webhooks of a user
Parameters: user/uid [optional]
Example:
$ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
--data '{"cmd": "user_wh_list", "user": "bla"}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api user_wh_list user=bla
{
"cmd": "user_wh_list",
"list": [
{
"id": "648",
"uid": "846",
"itime": "1454001110",
"description": "Test Slack integration",
"add_ip": "192.168.79.154",
"last_output": "* Trying ...H5pQ==\r\n\r\nok",
"idata": {
"debug": "0",
"events": "P",
"url": "https:\/\/hooks.slack.com\/services\/ID1\/ID2\/ID3",
"itype": "2",
"client_cert": "",
"client_ca_cert": "",
"opaque": "",
"key": "",
"custom_body": "{\n \"cha...host:\"\n}",
"events_text": "Push",
"itype_text": "Custom (use custom body field)",
"HTML:client_cert_short": "n\/a",
"HTML:client_ca_cert_short": "n\/a",
"HTML:custom_body_nlbr": "{<br \/>... \/>\n}",
"HTML:private": "<table ...<\/table>\n"
},
"htype": "http",
"hsubtype": "slack",
"flags": "",
"refname": "(test1|main)",
"repo": ".*10",
"itime_nice": "2016-01-28 17:11",
"HTML:flags_text": "",
"HTML:description_nice": "Test Slack integration",
"HTML:last_output_nice": "* Try...\r\nok"
},
...
]
}
repo_list
Parameters: user/uid [optional]
Example:
$ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
--data '{"cmd": "repo_list"}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api repo_list
[
"repo1",
"repo2",
"repo3"
]
repo_info
Description: Shows info about a repository
Parameters: user/uid [optional], repo/repo_id
Example:
$ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
--data '{"cmd": "repo_info", "repo": "repo1"}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api repo_info repo=repo1
{
"repo_id": "769",
"name": "repo1",
"uid": "846",
"itime": "1447874006",
"disk_quota_mb": null,
"max_commit_size": "0",
"master": "0",
"description": "here is a description",
"git_dir_done": "1",
"deleted": "0",
"disk_used_mb": "0",
"git_mb": "0",
"artifacts_mb": "0",
"public": "1",
"last_bug_id": "1",
"license": "GPLv3",
"template": "OS type(s) and version(s)?\n\nApplication version(s) affected?\n\nSteps to reproduce?",
"last_mr_id": "0",
"ok": 1,
"exists": 1,
"HTML:description_nlbr": "here is a description",
"HTML:itime_nice": "2015-11-18",
"owner": "bla",
"url_user": "\/user\/bla",
"url_repo": "\/user\/bla\/repo1",
"clone_url_ssh": "ssh:\/\/rocketgit@rocketgit.com\/user\/bla\/repo1",
"clone_url_git": "git:\/\/rocketgit.com\/user\/bla\/repo1",
"clone_url_http": "http:\/\/rocketgit.com\/user\/bla\/repo1",
"master_name": "-",
"disk_used": "0B"
}
repo_bug_list
Description: Lists the bugs
Parameters: user/uid [optional], repo/repo_id
Example:
$ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
--data '{"cmd": "repo_bug_list", "repo": "repo1"}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api repo_bug_list repo=repo1
{
"cmd": "repo_bug_list",
"repo_id": "100",
"list": [
"1",
"2",
"3"
]
}
repo_bug_info
Description: Shows information about a bug
Parameters: user/uid [optional], repo/repo_id, bug_id
Example:
$ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
--data '{"cmd": "repo_bug_info", "repo": "repo1", "bug_id": 2}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api repo_bug_info repo=repo1 bug_id=2
{
"cmd": "repo_bug_info",
"bug_id": "2",
"title": "dsdasds",
"body": "OS type(s) and version(s)?",
"state": "1",
"labels": "",
"assigned_to": "bla",
"assigned_uid": "846",
"itime": 1464812804,
"utime": 1464812804,
"ip": "192.168.79.154",
"repo_id": "1088",
"uid": "846",
"deleted": 0,
"ok": 1,
"exists": 1,
"owner": "catab",
"HTML:body_nlbr": "OS type(s) and version(s)?",
"creation": "2016-06-01 20:26",
"updated": "2016-06-01 20:26",
"deleted_text": "",
"deleted_who_name": "",
"state_text": "Open"
}
repo_mr_list
Description: Lists the merge requests
Parameters: user/uid [optional], repo/repo_id
Example:
$ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
--data '{"cmd": "repo_mr_list", "repo": "repo1"}' \
https://rocketgit.com/op/api
$ ssh rocketgit@rocketgit.com api repo_mr_list repo=repo1
{
"cmd": "repo_mr_list",
"repo_id": "100",
"list": [
{
"itime": "1330296541",
"namespace": "rg_b21751c3",
"refname": "refs\/heads\/main",
"old_rev": "afd1df2940fe440cde9b8ede988ff24c051a10d6",
"new_rev": "f919c9bf863471aeb97da6aa2380319a1bee6eda",
"done": "0",
"ip": "2002:2e66:5950::1",
"id": "5",
"who": "0"
},
...
]
}