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

Merge topic 'gitlab-api-v4'

6c7cbdd9 gitlab: use api v4
b0519926

 types: update to api v4
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !96
parents a869be24 6c7cbdd9
{"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", "coverage": null, "started_at": null, "ref": "master", "id": 931434, "description": "expected"}
{"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/system/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", "coverage": null, "started_at": null, "ref": "master", "id": 931434, "description": "expected"}
......@@ -5,7 +5,7 @@ import requests
def fetch_from_gitlab(token, endpoint, **kwargs):
url = 'https://gitlab.kitware.com/api/v3' + endpoint
url = 'https://gitlab.kitware.com/api/v4' + endpoint
response = requests.get(url, headers={'PRIVATE-TOKEN': token}, params=kwargs)
return response.json()
......@@ -26,8 +26,8 @@ def write_result(token, name, endpoint):
REPO = 'utils%2Frust-gitlab'
USER = 11 # kwrobot
COMMIT = 'de4ac3cf96cb8a0893be22b03f5171d934f9d392'
ISSUE_ID = 69328 # https://gitlab.kitware.com/utils/rust-gitlab/issues/6
MR_ID = 20215 # https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/35
ISSUE_ID = 6 # https://gitlab.kitware.com/utils/rust-gitlab/issues/6
MR_ID = 35 # https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/35
NOTE_ID = 177359
......
{"due_date": null, "downvotes": 0, "subscribed": true, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/issues/6", "description": "", "confidential": false, "title": "fix documentation warnings", "created_at": "2016-10-30T14:54:28.954-04:00", "labels": [], "updated_at": "2017-01-13T16:45:20.901-05:00", "iid": 6, "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, "id": 69328}
{"due_date": null, "downvotes": 0, "subscribed": true, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/issues/6", "description": "", "confidential": false, "title": "fix documentation warnings", "created_at": "2016-10-30T14:54:28.954-04:00", "labels": [], "updated_at": "2017-01-13T16:45:20.901-05:00", "iid": 6, "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, "assignees": [{"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}], "project_id": 855, "id": 69328}
{"due_date": null, "downvotes": 0, "subscribed": false, "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", "confidential": false, "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, "id": 69075}
{"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", "confidential": false, "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, "assignees": [{"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}], "project_id": 855, "id": 69075}
{"target_project_id": 855, "source_branch": "add_hook-api", "downvotes": 0, "labels": [], "updated_at": "2016-10-04T16:18:57.940-04:00", "work_in_progress": false, "assignee": {"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}, "user_notes_count": 3, "id": 20215, "force_remove_source_branch": true, "target_branch": "master", "subscribed": true, "title": "gitlab: expose hook addition API", "merge_commit_sha": null, "state": "merged", "upvotes": 0, "project_id": 855, "description": "Fixes #5.", "iid": 35, "milestone": null, "source_project_id": 856, "merge_when_build_succeeds": false, "merge_status": "can_be_merged", "should_remove_source_branch": null, "created_at": "2016-10-04T15:56:43.276-04:00", "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}, "sha": "04e94ae667024a62a90179f395bfdc2b35f3efd2", "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/35"}
{"target_project_id": 855, "source_branch": "add_hook-api", "downvotes": 0, "labels": [], "updated_at": "2016-10-04T16:18:57.940-04:00", "work_in_progress": false, "assignee": {"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}, "user_notes_count": 3, "id": 20215, "force_remove_source_branch": true, "target_branch": "master", "subscribed": true, "title": "gitlab: expose hook addition API", "merge_commit_sha": null, "merge_when_pipeline_succeeds": false, "state": "merged", "upvotes": 0, "project_id": 855, "description": "Fixes #5.", "iid": 35, "milestone": null, "source_project_id": 856, "merge_status": "can_be_merged", "should_remove_source_branch": null, "created_at": "2016-10-04T15:56:43.276-04:00", "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}, "sha": "04e94ae667024a62a90179f395bfdc2b35f3efd2", "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/35"}
{"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}
{"body": "Mentioned in commit 47d475d8625424bd37efd27f7097354306842b93", "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}
{"lfs_enabled": true, "request_access_enabled": true, "forks_count": 4, "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": {"path": "utils", "kind": "group", "id": 498, "full_path": "utils", "name": "Utils"}, "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, "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": 0, "last_activity_at": "2017-05-24T15:40:09.941-04: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": []}
{"lfs_enabled": true, "request_access_enabled": true, "forks_count": 5, "only_allow_merge_if_all_discussions_are_resolved": null, "container_registry_enabled": true, "shared_runners_enabled": true, "wiki_enabled": 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": {"path": "utils", "kind": "group", "id": 498, "full_path": "utils", "name": "Utils"}, "star_count": 0, "avatar_url": null, "issues_enabled": true, "path_with_namespace": "utils/rust-gitlab", "shared_with_groups": [], "description": "Rust library for communicating with a Gitlab instance.", "default_branch": "master", "visibility": "public", "ssh_url_to_repo": "git@gitlab.kitware.com:utils/rust-gitlab.git", "path": "rust-gitlab", "only_allow_merge_if_pipeline_succeeds": false, "open_issues_count": 3, "last_activity_at": "2017-06-19T10:17:18.412-04:00", "name": "rust-gitlab", "name_with_namespace": "Utils / rust-gitlab", "created_at": "2016-06-29T13:35:12.495-04:00", "creator_id": 13, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab", "permissions": {"group_access": {"notification_level": 3, "access_level": 50}, "project_access": null}, "tag_list": [], "jobs_enabled": false, "public_jobs": true}
{"note_events": true, "tag_push_events": true, "url": "http://kwrobot02:8082/gitlab.kitware.com", "created_at": "2016-12-16T11:37:24.589-05:00", "enable_ssl_verification": true, "pipeline_events": true, "issues_events": true, "push_events": true, "merge_requests_events": true, "build_events": true, "project_id": 855, "id": 1262, "wiki_page_events": true}
{"note_events": true, "job_events": true, "tag_push_events": true, "url": "http://kwrobot02:8082/gitlab.kitware.com", "created_at": "2016-12-16T11:37:24.589-05:00", "enable_ssl_verification": true, "pipeline_events": true, "issues_events": true, "push_events": true, "merge_requests_events": true, "project_id": 855, "id": 1262, "wiki_page_events": true}
{"name": "master", "developers_can_merge": false, "protected": true, "developers_can_push": false, "commit": {"committer_email": "kwrobot@kitware.com", "short_id": "936709be", "title": "Merge topic 'gitlab-9.2-update'", "author_email": "ben.boeckel@kitware.com", "committer_name": "Kitware Robot", "created_at": "2017-05-24T15:40:14.000-04:00", "author_name": "Ben Boeckel", "parent_ids": ["b67a5f29bccd11ce94c267538c93c519dae0a1ed", "861eb484822c41220ff7adfee3b95aa10353414f"], "committed_date": "2017-05-24T15:40:14.000-04:00", "message": "Merge topic 'gitlab-9.2-update'\n\n861eb484 types: update for 9.2 changes\n\nAcked-by: Kitware Robot <kwrobot@kitware.com>\nReviewed-by: Ben Boeckel <ben.boeckel@kitware.com>\nMerge-request: !91\n", "authored_date": "2017-05-24T19:40:09.000+00:00", "id": "936709be30f9b51bb7be316187641068efa765a9"}, "merged": false}
{"name": "master", "developers_can_merge": false, "protected": true, "developers_can_push": false, "commit": {"committer_email": "brad.king@kitware.com", "short_id": "b2bcc6ae", "title": " cargo: prep for 0.902.1", "author_email": "brad.king@kitware.com", "committer_name": "Brad King", "created_at": "2017-06-07T19:55:39.000-04:00", "author_name": "Brad King", "parent_ids": ["2853b2549d433c638a895dd487add365930797d9"], "committed_date": "2017-06-07T19:55:39.000-04:00", "message": " cargo: prep for 0.902.1\n", "authored_date": "2017-06-07T19:55:39.000-04:00", "id": "b2bcc6ae59863b6c8e186ebe1de67df8ba7647ba"}, "merged": false}
{"two_factor_enabled": true, "can_create_project": true, "confirmed_at": "2015-02-26T10:58:34.660-05:00", "twitter": "", "linkedin": "", "color_scheme_id": 4, "web_url": "https://gitlab.kitware.com/kwrobot", "skype": "", "identities": [], "id": 11, "projects_limit": 50, "current_sign_in_at": "2017-06-05T14:46:29.512-04:00", "state": "active", "location": null, "email": "kwrobot@kitware.com", "website_url": "", "username": "kwrobot", "bio": "", "last_sign_in_at": "2017-04-27T10:59:16.823-04:00", "last_activity_on": "2017-06-06", "external": false, "name": "Kitware Robot", "can_create_group": true, "created_at": "2015-02-26T10:58:34.670-05:00", "avatar_url": "https://secure.gravatar.com/avatar/9ddcd45fcb89d966aab95b1f1002f84c?s=80&d=identicon", "organization": null}
{"two_factor_enabled": true, "can_create_project": true, "confirmed_at": "2015-02-26T10:58:34.660-05:00", "twitter": "", "linkedin": "", "color_scheme_id": 4, "web_url": "https://gitlab.kitware.com/kwrobot", "skype": "", "identities": [], "id": 11, "projects_limit": 50, "current_sign_in_at": "2017-06-05T14:46:29.512-04:00", "state": "active", "location": null, "email": "kwrobot@kitware.com", "website_url": "", "username": "kwrobot", "bio": "", "last_sign_in_at": "2017-04-27T10:59:16.823-04:00", "last_activity_on": "2017-06-30", "external": false, "name": "Kitware Robot", "can_create_group": true, "created_at": "2015-02-26T10:58:34.670-05:00", "avatar_url": "https://secure.gravatar.com/avatar/9ddcd45fcb89d966aab95b1f1002f84c?s=80&d=identicon", "organization": null}
{"two_factor_enabled": true, "can_create_project": true, "confirmed_at": "2015-02-26T10:58:34.660-05:00", "twitter": "", "linkedin": "", "color_scheme_id": 4, "web_url": "https://gitlab.kitware.com/kwrobot", "skype": "", "identities": [], "id": 11, "projects_limit": 50, "current_sign_in_at": "2017-06-05T14:46:29.512-04:00", "state": "active", "location": null, "email": "kwrobot@kitware.com", "website_url": "", "username": "kwrobot", "bio": "", "last_sign_in_at": "2017-04-27T10:59:16.823-04:00", "last_activity_on": "2017-06-06", "external": false, "name": "Kitware Robot", "can_create_group": true, "created_at": "2015-02-26T10:58:34.670-05:00", "avatar_url": "https://secure.gravatar.com/avatar/9ddcd45fcb89d966aab95b1f1002f84c?s=80&d=identicon", "organization": null}
{"two_factor_enabled": true, "can_create_project": true, "confirmed_at": "2015-02-26T10:58:34.660-05:00", "twitter": "", "linkedin": "", "color_scheme_id": 4, "web_url": "https://gitlab.kitware.com/kwrobot", "skype": "", "identities": [], "id": 11, "projects_limit": 50, "current_sign_in_at": "2017-06-05T14:46:29.512-04:00", "state": "active", "location": null, "email": "kwrobot@kitware.com", "website_url": "", "username": "kwrobot", "bio": "", "last_sign_in_at": "2017-04-27T10:59:16.823-04:00", "last_activity_on": "2017-06-30", "external": false, "name": "Kitware Robot", "can_create_group": true, "created_at": "2015-02-26T10:58:34.670-05:00", "avatar_url": "https://secure.gravatar.com/avatar/9ddcd45fcb89d966aab95b1f1002f84c?s=80&d=identicon", "organization": null}
......@@ -89,7 +89,7 @@ impl Gitlab {
/// Internal method to create a new Gitlab client.
fn _new(protocol: &str, host: &str, token: String) -> Result<Self> {
let base_url = Url::parse(&format!("{}://{}/api/v3/", protocol, host))
let base_url = Url::parse(&format!("{}://{}/api/v4/", protocol, host))
.chain_err(|| ErrorKind::UrlParse)?;
let api = Gitlab {
......@@ -174,7 +174,7 @@ impl Gitlab {
/// HTTP parameters required to register to a project.
fn event_flags(events: WebhookEvents) -> Vec<(&'static str, &'static str)> {
vec![("build_events", Self::bool_param_value(events.build())),
vec![("job_events", Self::bool_param_value(events.job())),
("issues_events", Self::bool_param_value(events.issues())),
("merge_requests_events", Self::bool_param_value(events.merge_requests())),
("note_events", Self::bool_param_value(events.note())),
......@@ -288,12 +288,12 @@ impl Gitlab {
}
/// Get the latest builds of a commit.
pub fn commit_latest_builds(&self, project: ProjectId, commit: &str) -> Result<Vec<Build>> {
pub fn commit_latest_builds(&self, project: ProjectId, commit: &str) -> Result<Vec<Job>> {
self._get_paged(&format!("projects/{}/repository/commits/{}/builds", project, commit))
}
/// Get the all builds of a commit.
pub fn commit_all_builds(&self, project: ProjectId, commit: &str) -> Result<Vec<Build>> {
pub fn commit_all_builds(&self, project: ProjectId, commit: &str) -> Result<Vec<Job>> {
self._get_paged_with_param(&format!("projects/{}/repository/commits/{}/builds",
project,
commit),
......@@ -322,17 +322,17 @@ impl Gitlab {
}
/// Get issues.
pub fn issue(&self, project: ProjectId, issue: IssueId) -> Result<Issue> {
pub fn issue(&self, project: ProjectId, issue: IssueInternalId) -> Result<Issue> {
self._get(&format!("projects/{}/issues/{}", project, issue))
}
/// Get the notes from a issue.
pub fn issue_notes(&self, project: ProjectId, issue: IssueId) -> Result<Vec<Note>> {
pub fn issue_notes(&self, project: ProjectId, issue: IssueInternalId) -> Result<Vec<Note>> {
self._get_paged(&format!("projects/{}/issues/{}/notes", project, issue))
}
/// Create a note on a issue.
pub fn create_issue_note(&self, project: ProjectId, issue: IssueId, content: &str)
pub fn create_issue_note(&self, project: ProjectId, issue: IssueInternalId, content: &str)
-> Result<Note> {
let path = &format!("projects/{}/issues/{}/notes", project, issue);
......@@ -352,13 +352,13 @@ impl Gitlab {
}
/// Get merge requests.
pub fn merge_request(&self, project: ProjectId, merge_request: MergeRequestId)
pub fn merge_request(&self, project: ProjectId, merge_request: MergeRequestInternalId)
-> Result<MergeRequest> {
self._get(&format!("projects/{}/merge_requests/{}", project, merge_request))
}
/// Get the issues that will be closed when a merge request is merged.
pub fn merge_request_closes_issues(&self, project: ProjectId, merge_request: MergeRequestId)
pub fn merge_request_closes_issues(&self, project: ProjectId, merge_request: MergeRequestInternalId)
-> Result<Vec<IssueReference>> {
self._get_paged(&format!("projects/{}/merge_requests/{}/closes_issues",
project,
......@@ -366,7 +366,7 @@ impl Gitlab {
}
/// Get the notes from a merge request.
pub fn merge_request_notes(&self, project: ProjectId, merge_request: MergeRequestId)
pub fn merge_request_notes(&self, project: ProjectId, merge_request: MergeRequestInternalId)
-> Result<Vec<Note>> {
self._get_paged(&format!("projects/{}/merge_requests/{}/notes",
project,
......@@ -374,7 +374,7 @@ impl Gitlab {
}
/// Award a merge request note with an award.
pub fn award_merge_request_note(&self, project: ProjectId, merge_request: MergeRequestId,
pub fn award_merge_request_note(&self, project: ProjectId, merge_request: MergeRequestInternalId,
note: NoteId, award: &str)
-> Result<AwardEmoji> {
let path = &format!("projects/{}/merge_requests/{}/notes/{}/award_emoji",
......@@ -385,7 +385,7 @@ impl Gitlab {
}
/// Get the awards for a merge request.
pub fn merge_request_awards(&self, project: ProjectId, merge_request: MergeRequestId)
pub fn merge_request_awards(&self, project: ProjectId, merge_request: MergeRequestInternalId)
-> Result<Vec<AwardEmoji>> {
self._get_paged(&format!("projects/{}/merge_requests/{}/award_emoji",
project,
......@@ -393,7 +393,7 @@ impl Gitlab {
}
/// Get the awards for a merge request note.
pub fn merge_request_note_awards(&self, project: ProjectId, merge_request: MergeRequestId,
pub fn merge_request_note_awards(&self, project: ProjectId, merge_request: MergeRequestInternalId,
note: NoteId)
-> Result<Vec<AwardEmoji>> {
self._get_paged(&format!("projects/{}/merge_requests/{}/notes/{}/award_emoji",
......@@ -403,7 +403,7 @@ impl Gitlab {
}
/// Create a note on a merge request.
pub fn create_merge_request_note(&self, project: ProjectId, merge_request: MergeRequestId,
pub fn create_merge_request_note(&self, project: ProjectId, merge_request: MergeRequestInternalId,
content: &str)
-> Result<Note> {
let path = &format!("projects/{}/merge_requests/{}/notes",
......@@ -414,7 +414,7 @@ impl Gitlab {
/// Get issues closed by a merge request.
pub fn get_issues_closed_by_merge_request(&self, project: ProjectId,
merge_request: MergeRequestId)
merge_request: MergeRequestInternalId)
-> Result<Vec<Issue>> {
let path = &format!("projects/{}/merge_requests/{}/closes_issues",
project,
......@@ -423,7 +423,7 @@ impl Gitlab {
}
/// Set the labels on an issue.
pub fn set_issue_labels<I, L>(&self, project: ProjectId, issue: IssueId, labels: I)
pub fn set_issue_labels<I, L>(&self, project: ProjectId, issue: IssueInternalId, labels: I)
-> Result<Issue>
where I: IntoIterator<Item = L>,
L: Display,
......
......@@ -95,7 +95,7 @@ fn test_read_commit_status() {
assert_eq!(commit_status.author.name, "buildbot");
assert_eq!(commit_status.author.state, UserState::Active);
assert_eq!(commit_status.author.avatar_url,
"https://gitlab.kitware.com/uploads/user/avatar/35/buildbot-logo.png");
"https://gitlab.kitware.com/uploads/system/user/avatar/35/buildbot-logo.png");
assert_eq!(commit_status.author.id, UserId::new(35));
assert_eq!(commit_status.coverage, None);
}
......@@ -105,7 +105,7 @@ fn test_read_issue() {
let issue: Issue = read_test_file("issue");
assert_eq!(issue.id, IssueId::new(69328));
assert_eq!(issue.iid, 6);
assert_eq!(issue.iid, IssueInternalId::new(6));
assert_eq!(issue.project_id, ProjectId::new(855));
assert_eq!(issue.title, "fix documentation warnings");
assert_eq!(issue.description, Some("".to_string()));
......@@ -137,7 +137,20 @@ fn test_read_issue() {
} else {
panic!("expected to have an assignee for the issue");
}
assert_eq!(issue.subscribed, true);
if let Some(ref assignees) = issue.assignees {
assert_eq!(assignees.len(), 1);
let assignee = &assignees[0];
assert_eq!(assignee.username, "ben.boeckel");
assert_eq!(assignee.web_url, "https://gitlab.kitware.com/ben.boeckel");
assert_eq!(assignee.name, "Ben Boeckel");
assert_eq!(assignee.state, UserState::Active);
assert_eq!(assignee.avatar_url,
"https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon");
assert_eq!(assignee.id, UserId::new(13));
} else {
panic!("expected to have assignees for the issue");
}
assert_eq!(issue.subscribed, Some(true));
assert_eq!(issue.user_notes_count, 0);
assert_eq!(issue.upvotes, 0);
assert_eq!(issue.downvotes, 0);
......@@ -153,7 +166,7 @@ fn test_read_issue_reference() {
if let IssueReference::Internal(issue) = issue_reference {
assert_eq!(issue.id, IssueId::new(69075));
assert_eq!(issue.iid, 5);
assert_eq!(issue.iid, IssueInternalId::new(5));
assert_eq!(issue.project_id, ProjectId::new(855));
assert_eq!(issue.title, "Add project hook APIs");
assert_eq!(issue.description,
......@@ -187,7 +200,7 @@ fn test_read_issue_reference() {
} else {
panic!("expected to have an assignee for the issue");
}
assert_eq!(issue.subscribed, false);
assert_eq!(issue.subscribed, None);
assert_eq!(issue.user_notes_count, 0);
assert_eq!(issue.upvotes, 0);
assert_eq!(issue.downvotes, 0);
......@@ -220,7 +233,7 @@ fn test_read_merge_request() {
let merge_request: MergeRequest = read_test_file("merge_request");
assert_eq!(merge_request.id, MergeRequestId::new(20215));
assert_eq!(merge_request.iid, 35);
assert_eq!(merge_request.iid, MergeRequestInternalId::new(35));
assert_eq!(merge_request.project_id, ProjectId::new(855));
assert_eq!(merge_request.title, "gitlab: expose hook addition API");
assert_eq!(merge_request.description, Some("Fixes #5.".to_string()));
......@@ -259,12 +272,12 @@ fn test_read_merge_request() {
assert!(merge_request.labels.is_empty());
assert_eq!(merge_request.work_in_progress, false);
assert!(merge_request.milestone.is_none());
assert_eq!(merge_request.merge_when_build_succeeds, false);
assert_eq!(merge_request.merge_when_pipeline_succeeds, false);
assert_eq!(merge_request.merge_status, MergeStatus::CanBeMerged);
assert_eq!(merge_request.sha,
Some(ObjectId::new("04e94ae667024a62a90179f395bfdc2b35f3efd2")));
assert_eq!(merge_request.merge_commit_sha, None);
assert_eq!(merge_request.subscribed, true);
assert_eq!(merge_request.subscribed, Some(true));
assert_eq!(merge_request.user_notes_count, 3);
assert_eq!(merge_request.should_remove_source_branch, None);
assert_eq!(merge_request.force_remove_source_branch, Some(true));
......@@ -308,9 +321,8 @@ fn test_read_project() {
Some("Rust library for communicating with a Gitlab instance.".to_string()));
assert_eq!(project.default_branch, Some("master".to_string()));
assert!(project.tag_list.is_empty());
assert_eq!(project.public, true);
assert_eq!(project.archived, false);
assert_eq!(project.visibility_level, 20);
assert_eq!(project.visibility, VisibilityLevel::Public);
assert_eq!(project.ssh_url_to_repo,
"git@gitlab.kitware.com:utils/rust-gitlab.git");
assert_eq!(project.http_url_to_repo,
......@@ -327,8 +339,8 @@ fn test_read_project() {
Utc.ymd(2016, 6, 29)
.and_hms_milli(17, 35, 12, 495));
assert_eq!(project.last_activity_at,
Utc.ymd(2017, 5, 24)
.and_hms_milli(19, 40, 9, 941));
Utc.ymd(2017, 6, 19)
.and_hms_milli(14, 17, 18, 412));
assert_eq!(project.shared_runners_enabled, true);
assert_eq!(project.lfs_enabled, true);
assert_eq!(project.creator_id, UserId::new(13));
......@@ -341,15 +353,15 @@ fn test_read_project() {
assert!(project.forked_from_project.is_none());
assert_eq!(project.avatar_url, None);
assert_eq!(project.star_count, 0);
assert_eq!(project.forks_count, 4);
assert_eq!(project.open_issues_count, Some(0));
assert_eq!(project.public_builds, true);
assert_eq!(project.forks_count, 5);
assert_eq!(project.open_issues_count, Some(3));
assert_eq!(project.public_jobs, true);
assert!(project.shared_with_groups.is_empty());
assert_eq!(project.only_allow_merge_if_build_succeeds, Some(false));
assert_eq!(project.only_allow_merge_if_pipeline_succeeds, Some(false));
assert_eq!(project.only_allow_merge_if_all_discussions_are_resolved,
None);
assert_eq!(project.request_access_enabled, true);
assert_eq!(project.builds_enabled, false);
assert_eq!(project.jobs_enabled, false);
assert_eq!(project.issues_enabled, true);
assert_eq!(project.merge_requests_enabled, true);
assert_eq!(project.snippets_enabled, false);
......@@ -382,7 +394,7 @@ fn test_read_project_hook() {
assert_eq!(project_hook.merge_requests_events, true);
assert_eq!(project_hook.note_events, true);
assert_eq!(project_hook.enable_ssl_verification, true);
assert_eq!(project_hook.build_events, true);
assert_eq!(project_hook.job_events, true);
assert_eq!(project_hook.pipeline_events, true);
assert_eq!(project_hook.wiki_page_events, true);
}
......@@ -393,30 +405,26 @@ fn test_read_repo_branch() {
assert_eq!(repo_branch.name, "master");
if let Some(ref commit) = repo_branch.commit {
assert_eq!(commit.author_email, "ben.boeckel@kitware.com");
assert_eq!(commit.author_name, "Ben Boeckel");
assert_eq!(commit.author_email, "brad.king@kitware.com");
assert_eq!(commit.author_name, "Brad King");
assert_eq!(commit.authored_date,
Utc.ymd(2017, 5, 24)
.and_hms_milli(19, 40, 9, 0));
Utc.ymd(2017, 6, 7)
.and_hms_milli(23, 55, 39, 0));
assert_eq!(commit.committed_date,
Utc.ymd(2017, 5, 24)
.and_hms_milli(19, 40, 14, 0));
Utc.ymd(2017, 6, 7)
.and_hms_milli(23, 55, 39, 0));
assert_eq!(commit.created_at,
Utc.ymd(2017, 5, 24)
.and_hms_milli(19, 40, 14, 0));
assert_eq!(commit.committer_email, "kwrobot@kitware.com");
assert_eq!(commit.committer_name, "Kitware Robot");
Utc.ymd(2017, 6, 7)
.and_hms_milli(23, 55, 39, 0));
assert_eq!(commit.committer_email, "brad.king@kitware.com");
assert_eq!(commit.committer_name, "Brad King");
assert_eq!(commit.id,
ObjectId::new("936709be30f9b51bb7be316187641068efa765a9"));
assert_eq!(commit.short_id, ObjectId::new("936709be"));
assert_eq!(commit.title, "Merge topic 'gitlab-9.2-update'");
assert_eq!(commit.message,
"Merge topic 'gitlab-9.2-update'\n\n861eb484 types: update for 9.2 \
changes\n\nAcked-by: Kitware Robot <kwrobot@kitware.com>\nReviewed-by: Ben \
Boeckel <ben.boeckel@kitware.com>\nMerge-request: !91\n");
ObjectId::new("b2bcc6ae59863b6c8e186ebe1de67df8ba7647ba"));
assert_eq!(commit.short_id, ObjectId::new("b2bcc6ae"));
assert_eq!(commit.title, " cargo: prep for 0.902.1");
assert_eq!(commit.message, " cargo: prep for 0.902.1\n");
assert_eq!(commit.parent_ids,
vec![ObjectId::new("b67a5f29bccd11ce94c267538c93c519dae0a1ed"),
ObjectId::new("861eb484822c41220ff7adfee3b95aa10353414f")]);
vec![ObjectId::new("2853b2549d433c638a895dd487add365930797d9")]);
} else {
panic!("expected to have a commit for the branch");
}
......@@ -510,10 +518,10 @@ fn test_read_user_public() {
Some(Utc.ymd(2017, 4, 27)
.and_hms_milli(14, 59, 16, 823)));
assert_eq!(user_public.last_activity_on,
Some(NaiveDate::from_ymd(2017, 6, 6)));
Some(NaiveDate::from_ymd(2017, 6, 30)));
assert_eq!(user_public.confirmed_at,
Utc.ymd(2015, 2, 26)
.and_hms_milli(15, 58, 34, 660));
Some(Utc.ymd(2015, 2, 26)
.and_hms_milli(15, 58, 34, 660)));
assert_eq!(user_public.email, "kwrobot@kitware.com");
assert_eq!(user_public.color_scheme_id, ColorSchemeId::new(4));
assert_eq!(user_public.projects_limit, 50);
......
......@@ -186,7 +186,7 @@ pub struct UserPublic {
/// When the user last made an action.
pub last_activity_on: Option<NaiveDate>,
/// When the user's account was confirmed.
pub confirmed_at: DateTime<Utc>,
pub confirmed_at: Option<DateTime<Utc>>,
/// The primary email address for the user.
pub email: String,
......@@ -308,8 +308,8 @@ pub struct ProjectHook {
pub note_events: bool,
/// Whether the communication with the hook is verified using TLS certificates.
pub enable_ssl_verification: bool,
/// Whether the hook is contacted for build events.
pub build_events: bool,
/// Whether the hook is contacted for job events.
pub job_events: bool,
/// Whether the hook is contacted for pipeline events.
pub pipeline_events: bool,
/// Whether the hook is contacted for wiki page events.
......@@ -332,8 +332,8 @@ impl From<ProjectHook> for Hook {
#[derive(Debug, Default, Clone, Copy)]
/// The events a webhook listener may receive.
pub struct WebhookEvents {
/// Whether to receive build events of not.
build: bool,
/// Whether to receive job events of not.
job: bool,
/// Whether to receive issue events of not.
issues: bool,
/// Whether to receive merge request events of not.
......@@ -352,7 +352,7 @@ impl WebhookEvents {
/// Create a new, empty webhook event set.
pub fn new() -> Self {
WebhookEvents {
build: false,
job: false,
issues: false,
merge_requests: false,
note: false,
......@@ -362,7 +362,7 @@ impl WebhookEvents {
}
}
with_event!{with_build, build}
with_event!{with_job, job}
with_event!{with_issues, issues}
with_event!{with_merge_requests, merge_requests}
with_event!{with_note, note}
......@@ -370,7 +370,7 @@ impl WebhookEvents {
with_event!{with_push, push}
with_event!{with_wiki_page, wiki_page}
get_event!{build}
get_event!{job}
get_event!{issues}
get_event!{merge_requests}
get_event!{note}
......@@ -409,28 +409,17 @@ pub struct BasicProjectDetails {
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum VisibilityLevel {
/// The project is visible to anonymous users.
Public = 20,
Public,
/// The project is visible to logged in users.
Internal = 10,
Internal,
/// The project is visible only to users with explicit access.
Private = 0,
}
impl From<VisibilityLevel> for u64 {
fn from(visibility: VisibilityLevel) -> Self {
match visibility {
VisibilityLevel::Public => 20,
VisibilityLevel::Internal => 10,
VisibilityLevel::Private => 0,
}
}
}
impl Display for VisibilityLevel {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}", Into::<u64>::into(self.clone()))
}
Private,
}
enum_serialize!(VisibilityLevel -> "visibility level",
Public => "public",
Internal => "internal",
Private => "private",
);
// TODO: enum for NotificationLevel
......@@ -488,12 +477,10 @@ pub struct Project {
pub default_branch: Option<String>,
/// A list of tags for the project.
pub tag_list: Vec<String>,
/// Whether the project is publicly visible or not.
pub public: bool,
/// Whether the project is archived or not.
pub archived: bool,
/// Integral value for the project's visibility.
pub visibility_level: u64,
/// Whether the project is public, internal, or private.
pub visibility: VisibilityLevel,
/// The URL to clone the repository over SSH.
pub ssh_url_to_repo: String,
/// The URL to clone the repository over HTTPS.
......@@ -539,18 +526,18 @@ pub struct Project {
pub open_issues_count: Option<u64>,
/// The continuous integration runner token (if enabled).
pub runners_token: Option<String>,
/// Whether builds are publicly visible.
pub public_builds: bool,
/// Whether jobs are publicly visible.
pub public_jobs: bool,
/// Groups the project is shared with.
pub shared_with_groups: Vec<SharedGroup>,
/// Whether the project only enables the merge button if all builds are passing.
pub only_allow_merge_if_build_succeeds: Option<bool>,
/// Whether the project only enables the merge button if all pipelines are passing.
pub only_allow_merge_if_pipeline_succeeds: Option<bool>,
/// Whether the project only enables the merge button if all discussions are resolved.
pub only_allow_merge_if_all_discussions_are_resolved: Option<bool>,
/// Whether access to the project may be requested.
pub request_access_enabled: bool,
/// Whether builds are enabled or not.
pub builds_enabled: bool,
/// Whether jobs are enabled or not.
pub jobs_enabled: bool,
/// Whether issues are enabled or not.
pub issues_enabled: bool,
/// Whether merge requests are enabled or not.
......@@ -579,8 +566,8 @@ pub struct ProjectStatistics {
pub repository_size: u64,
/// The size, in bytes, of uploaded LFS files.
pub lfs_objects_size: u64,
/// The size, in bytes, of uploaded build artifacts.
pub build_artifacts_size: u64,
/// The size, in bytes, of uploaded job artifacts.
pub job_artifacts_size: u64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
......@@ -656,7 +643,7 @@ pub struct Member {
/// The access level of the user.
pub access_level: u64,
/// When the membership expires.
pub expires_at: Option<DateTime<Utc>>,
pub expires_at: Option<NaiveDate>,
}
impl From<Member> for UserBasic {
......@@ -723,8 +710,8 @@ pub struct Group {
pub path: String,
/// The description of the group.
pub description: Option<String>,
/// Integral value for the group's visibility.
pub visibility_level: u64,
/// Whether the project is public, internal, or private.
pub visibility: VisibilityLevel,
/// Whether LFS is enabled for the group.
pub lfs_enabled: bool,
/// The URL to the group avatar.
......@@ -737,7 +724,7 @@ pub struct Group {
pub full_path: String,
pub parent_id: Option<GroupId>,
/// Statistics about the group.
pub statistics: Option<ProjectStatistics>,
pub statistics: Option<GroupStatistics>,
}
#[cfg_attr(feature="strict", serde(deny_unknown_fields))]
......@@ -750,8 +737,8 @@ pub struct GroupStatistics {
pub repository_size: u64,
/// The size, in bytes, of uploaded LFS files in the group.
pub lfs_objects_size: u64,
/// The size, in bytes, of uploaded build artifacts in the group.