Commit af9ba32b authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic '8.14'

d094cad1 data: update readme
add15d75 test: add code to read in and validate example data
5469622a gitlab: remove Deserialize restriction
8f5f452c gitlab: remove TODO items
fefe6b87 data: add example results from API endpoints
92bdc929 data: add a script to fetch example data from gitlab
9cd1108a

 types: update for 8.14
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Brad King's avatarBrad King <brad.king@kitware.com>
Merge-request: !54
parents 34f16b0f d094cad1
......@@ -3,7 +3,7 @@
This library implements an interface to communicate with a Gitlab instance. Not
all API endpoints are implemented, but patches are welcome.
The API is based off of the 8.13.0 API and will likely aggressively track new
The API is based off of the 8.14.0 API and will likely aggressively track new
API additions, so the newest release may not support talking to older releases
where fields have been added..
......
......@@ -2,6 +2,3 @@
Store example Gitlab objects here. The filename should generally correlate with
what the object stored within it is.
All URLs in example objects should be rewritten to be underneath the
`example.com` domain.
{"awardable_type": "Note", "awardable_id": 177359, "name": "8ball", "created_at": "2016-12-07T11:23:46.742-05:00", "updated_at": "2016-12-07T11:23:46.742-05:00", "user": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "id": 335}
\ No newline at end of file
{"author": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "created_at": "2016-12-07T11:28:33.966-05:00", "note": "Example commit note for data fetching.", "line_type": null, "path": null, "line": null}
\ No newline at end of file
{"status": "success", "target_url": "https://buildbot.kitware.com/builders/rust-gitlab-megas-linux-debug/builds/41", "name": "rust-gitlab-megas-linux-debug", "author": {"username": "buildbot", "web_url": "https://gitlab.kitware.com/buildbot", "name": "buildbot", "state": "active", "avatar_url": "https://gitlab.kitware.com/uploads/user/avatar/35/buildbot-logo.png", "id": 35}, "finished_at": "2016-11-08T09:35:32.629-05:00", "created_at": "2016-11-08T09:35:32.627-05:00", "allow_failure": false, "sha": "de4ac3cf96cb8a0893be22b03f5171d934f9d392", "started_at": null, "ref": "master", "id": 931434, "description": "expected"}
\ No newline at end of file
#!/usr/bin/env python
import json
import requests
import sys
def fetch_from_gitlab(token, endpoint, **kwargs):
url = 'https://gitlab.kitware.com/api/v3' + endpoint
response = requests.get(url, headers={'PRIVATE-TOKEN': token}, params=kwargs)
return response.json()
def write_result(token, name, endpoint):
print('Writing out %s...' % name)
result = fetch_from_gitlab(token, endpoint)
if type(result) == list:
result = result[0]
# Remove any keys from the result.
result.pop('private_token', None)
result.pop('runners_token', None)
with open('%s.json' % name, 'w+') as fout:
json.dump(result, fout)
REPO = 'utils%2Frust-gitlab'
USER = 11 # kwrobot
COMMIT = 'de4ac3cf96cb8a0893be22b03f5171d934f9d392'
MR_ID = 20215 # https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/35
NOTE_ID = 177359
token = sys.argv[1]
write_result(token, 'user_full', '/user')
write_result(token, 'user', '/users/%d' % USER)
write_result(token, 'project', '/projects/%s' % REPO)
write_result(token, 'project_hook', '/projects/%s/hooks' % REPO)
write_result(token, 'member', '/groups/utils/members')
write_result(token, 'repo_branch', '/projects/%s/repository/branches/master' % REPO)
write_result(token, 'repo_commit_detail', '/projects/%s/repository/commits/%s' % (REPO, COMMIT))
write_result(token, 'commit_note', '/projects/%s/repository/commits/%s/comments' % (REPO, COMMIT))
write_result(token, 'commit_status', '/projects/%s/repository/commits/%s/statuses' % (REPO, COMMIT))
write_result(token, 'issue', '/projects/%s/issues' % REPO)
write_result(token, 'merge_request', '/projects/%s/merge_requests' % REPO)
write_result(token, 'issue_reference', '/projects/%s/merge_requests/%d/closes_issues' % (REPO, MR_ID))
write_result(token, 'note', '/projects/%s/merge_requests/%d/notes' % (REPO, MR_ID))
write_result(token, 'award_emoji', '/projects/%s/merge_requests/%d/notes/%d/award_emoji' % (REPO, MR_ID, NOTE_ID))
{"due_date": null, "downvotes": 0, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/issues/6", "description": "", "subscribed": true, "title": "fix documentation warnings", "created_at": "2016-10-30T14:54:28.954-04:00", "labels": [], "updated_at": "2016-10-30T14:54:29.242-04:00", "iid": 6, "state": "opened", "user_notes_count": 0, "assignee": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "author": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "milestone": null, "upvotes": 0, "project_id": 855, "confidential": false, "id": 69328}
\ No newline at end of file
{"due_date": null, "downvotes": 0, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/issues/5", "description": "The workflow currently requires that the robot be able to register itself as a webhook for new projects. An API needs added for this.\n\nCc: @brad.king", "subscribed": true, "title": "Add project hook APIs", "created_at": "2016-10-04T14:59:37.178-04:00", "labels": [], "updated_at": "2016-10-04T16:18:57.519-04:00", "iid": 5, "state": "closed", "user_notes_count": 0, "assignee": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "author": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "milestone": null, "upvotes": 0, "project_id": 855, "confidential": false, "id": 69075}
\ No newline at end of file
{"username": "kwrobot", "web_url": "https://gitlab.kitware.com/kwrobot", "name": "Kitware Robot", "expires_at": null, "access_level": 50, "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/9ddcd45fcb89d966aab95b1f1002f84c?s=80&d=identicon", "id": 11}
\ No newline at end of file
{"target_project_id": 855, "source_branch": "migrate-to-reqwest", "downvotes": 0, "labels": [], "updated_at": "2016-12-07T10:45:22.184-05:00", "work_in_progress": false, "assignee": null, "user_notes_count": 7, "id": 21211, "force_remove_source_branch": true, "target_branch": "master", "subscribed": true, "title": "Migrate to reqwest", "merge_commit_sha": null, "state": "opened", "upvotes": 0, "project_id": 855, "description": "Currently, we cannot use both `rust-gitlab` (depending on `hyper`'s SSL support) and `libgit2` in the same application, because they require different versions of `rust-openssl` (hyper: 0.7.x, libgit2: 0.9.x).\r\n(I want to use the both libraries in my GitLab helper application.)\r\n\r\nseanmonstar (hyper's author) recommends using reqwest for HTTP clients.\r\n\r\nhttps://github.com/hyperium/hyper/issues/907#issuecomment-255509020\r\n\r\n> reqwest: Be the convenient, higher level Client crate. This will release very soon, and depend on rust-native-tls. Everyone using hyper for a client should be able to easily switch the reqwest, getting better TLS support immediately, and a (as much as possible) not-breaking API, even as hyper v0.10 comes out with its async Client.\r\n\r\nthoughts?\r\n\r\n(This MR is based on !51 changes)", "iid": 52, "milestone": null, "source_project_id": 1154, "merge_when_build_succeeds": false, "merge_status": "can_be_merged", "should_remove_source_branch": null, "created_at": "2016-12-07T09:43:31.653-05:00", "author": {"username": "gifnksm", "web_url": "https://gitlab.kitware.com/gifnksm", "name": "NAKASHIMA, Makoto", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/4f544d7f9fc4ae2b04512317f1a06b6e?s=80&d=identicon", "id": 1489}, "sha": "f2784e0607d08e79b361ccf58a8379b04de2df35", "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/52"}
\ No newline at end of file
{"body": "Mentioned in commit 47d475d8625424bd37efd27f7097354306842b93", "downvote?": false, "author": {"username": "brad.king", "web_url": "https://gitlab.kitware.com/brad.king", "name": "Brad King", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/0617392a2f9fd505720d0c42cefc1a10?s=80&d=identicon", "id": 10}, "created_at": "2016-10-04T16:18:57.786-04:00", "updated_at": "2016-10-04T16:18:57.786-04:00", "noteable_type": "MergeRequest", "system": true, "attachment": null, "noteable_id": 20215, "id": 177371, "upvote?": false}
\ No newline at end of file
{"lfs_enabled": true, "request_access_enabled": true, "forks_count": 2, "only_allow_merge_if_all_discussions_are_resolved": null, "container_registry_enabled": true, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab", "wiki_enabled": true, "public_builds": true, "id": 855, "merge_requests_enabled": true, "archived": false, "snippets_enabled": false, "http_url_to_repo": "https://gitlab.kitware.com/utils/rust-gitlab.git", "namespace": {"request_access_enabled": true, "lfs_enabled": null, "share_with_group_lock": false, "deleted_at": null, "name": "Utils", "created_at": "2016-02-03T16:26:13.133-05:00", "description": "", "updated_at": "2016-02-03T16:27:05.284-05:00", "avatar": {"url": null}, "path": "utils", "visibility_level": 20, "id": 498, "owner_id": null}, "star_count": 0, "avatar_url": null, "issues_enabled": true, "path_with_namespace": "utils/rust-gitlab", "public": true, "shared_with_groups": [], "description": "Rust library for communicating with a Gitlab instance.", "default_branch": "master", "only_allow_merge_if_build_succeeds": false, "runners_token": "M3yGSHxyULoxbXoSbG1o", "ssh_url_to_repo": "git@gitlab.kitware.com:utils/rust-gitlab.git", "path": "rust-gitlab", "visibility_level": 20, "permissions": {"group_access": {"notification_level": 3, "access_level": 50}, "project_access": null}, "open_issues_count": 3, "last_activity_at": "2016-12-07T10:45:22.450-05:00", "name": "rust-gitlab", "name_with_namespace": "Utils / rust-gitlab", "created_at": "2016-06-29T13:35:12.495-04:00", "builds_enabled": false, "creator_id": 13, "shared_runners_enabled": true, "tag_list": []}
\ No newline at end of file
{"note_events": true, "tag_push_events": true, "url": "http://kwrobot02:8080/event", "created_at": "2016-06-29T13:35:15.771-04:00", "enable_ssl_verification": false, "pipeline_events": false, "issues_events": true, "push_events": true, "merge_requests_events": true, "build_events": false, "project_id": 855, "id": 887, "wiki_page_events": false}
\ No newline at end of file
{"commit": {"committer_email": "kwrobot@kitware.com", "author_email": "brad.king@kitware.com", "committer_name": "Kitware Robot", "author_name": "Brad King", "parent_ids": ["de4ac3cf96cb8a0893be22b03f5171d934f9d392", "370267d429821e0f4354cb43c52ee2053c2cb744"], "committed_date": "2016-11-11T09:59:37.000-05:00", "message": "Merge topic 'nullable-fields'\n\n370267d4 types: more nullable fields\n\nAcked-by: Kitware Robot <kwrobot@kitware.com>\nReviewed-by: Brad King <brad.king@kitware.com>\nMerge-request: !47\n", "authored_date": "2016-11-11T09:59:37.000-05:00", "id": "a418466df1c8b4e676e97d7d8d0d3cdfb1336558"}, "protected": true, "name": "master", "developers_can_push": false, "developers_can_merge": false}
\ No newline at end of file
{"status": "success", "stats": {"deletions": 0, "additions": 8, "total": 8}, "short_id": "de4ac3cf", "title": "Merge topic 'mr-awards'", "author_email": "brad.king@kitware.com", "created_at": "2016-11-08T09:30:13.000-05:00", "author_name": "Brad King", "parent_ids": ["559f5f4a2bfe1f48e9e95afa09c029deb655cf7d", "a222c5539569cda6999b8069f1e51a5202c30711"], "committed_date": "2016-11-08T09:30:13.000-05:00", "message": "Merge topic 'mr-awards'\n\na222c553 gitlab: add a method for MR award queries\n\nAcked-by: Kitware Robot <kwrobot@kitware.com>\nReviewed-by: Brad King <brad.king@kitware.com>\nMerge-request: !46\n", "authored_date": "2016-11-08T09:30:13.000-05:00", "id": "de4ac3cf96cb8a0893be22b03f5171d934f9d392"}
\ No newline at end of file
{
"username": "ben.boeckel",
"bio": null,
"web_url": "https://gitlab.example.com/u/ben.boeckel",
"name": "Ben Boeckel",
"twitter": "",
"created_at": "2015-02-26T12:23:28.730-05:00",
"linkedin": "",
"state": "active",
"avatar_url": "https://example.com/avatar.png",
"is_admin": false,
"location": null,
"skype": "",
"id": 13,
"website_url": ""
}
{"username": "kwrobot", "bio": "", "web_url": "https://gitlab.kitware.com/kwrobot", "name": "Kitware Robot", "twitter": "", "created_at": "2015-02-26T10:58:34.670-05:00", "linkedin": "", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/9ddcd45fcb89d966aab95b1f1002f84c?s=80&d=identicon", "is_admin": true, "location": null, "skype": "", "organization": null, "id": 11, "website_url": ""}
\ No newline at end of file
{
"username": "ben.boeckel",
"web_url": "https://gitlab.example.com/u/ben.boeckel",
"name": "Ben Boeckel",
"state": "active",
"avatar_url": "https://example.com/avatar.png",
"id": 13
}
{"two_factor_enabled": true, "can_create_project": true, "confirmed_at": "2015-02-26T12:23:28.693-05:00", "twitter": "", "linkedin": "", "color_scheme_id": 2, "web_url": "https://gitlab.kitware.com/ben.boeckel", "skype": "", "identities": [], "id": 13, "projects_limit": 50, "current_sign_in_at": "2016-12-07T11:15:50.720-05:00", "state": "active", "location": null, "email": "ben.boeckel@kitware.com", "website_url": "", "username": "ben.boeckel", "bio": null, "last_sign_in_at": "2016-12-07T10:05:56.167-05:00", "is_admin": false, "external": false, "organization": null, "name": "Ben Boeckel", "can_create_group": true, "created_at": "2015-02-26T12:23:28.730-05:00", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "theme_id": 2}
\ No newline at end of file
......@@ -23,9 +23,6 @@ use super::types::*;
use std::fmt::{self, Debug};
// TODO: Add system hook APIs
// TODO: Add webhook APIs
#[derive(Clone)]
/// A representation of the Gitlab API for a single user.
///
......@@ -45,7 +42,7 @@ impl Debug for Gitlab {
header!{ (GitlabPrivateToken, "PRIVATE-TOKEN") => [String] }
/// A JSON value return from Gitlab.
pub type GitlabResult<T: Deserialize> = Result<T, Error>;
pub type GitlabResult<T> = Result<T, Error>;
#[derive(Debug)]
/// Optional information for commit statuses.
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment