Commit b0519926 authored by Brad King's avatar Brad King

types: update to api v4

Fetch api v4 sample data from a GitLab 9.2 instance.  Using that and
GitLab sources `doc/api/v3_to_v4.md` and `lib/api/entities.rb`, update
our types accordingly.  Most changes are to rename "builds" to "jobs" or
"pipelines".

Also add strong types to internal ids in preparation for switching to
them when constructing API endpoints.
parent a869be24
{"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}
......@@ -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),
......
......@@ -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);
......
This diff is collapsed.
......@@ -18,7 +18,8 @@ use crates::serde::{Deserialize, Deserializer, Serialize, Serializer};
use crates::serde::de::{Error, Unexpected};
use crates::serde_json::{self, Value};
use types::{BuildId, IssueId, IssueState, MergeRequestId, MergeRequestState, MergeStatus,
use types::{JobId, IssueId, IssueInternalId, IssueState,
MergeRequestId, MergeRequestInternalId, MergeRequestState, MergeStatus,
MilestoneId, NoteId, NoteType, NoteableId, ObjectId, ProjectId, SnippetId, UserId};
#[derive(Debug, Clone, Copy)]
......@@ -241,7 +242,7 @@ pub struct IssueHookAttrs {
/// The state of the issue.
pub state: IssueState,
/// The user-visible ID of the issue.
pub iid: u64,
pub iid: IssueInternalId,
/// Whether the issue is confidential or not.
pub confidential: bool,
/// The time estimate, in seconds.
......@@ -388,7 +389,7 @@ pub struct MergeRequestHookAttrs {
/// The merge status of the merge request.
pub merge_status: MergeStatus,
/// The user-visible ID of the merge request.
pub iid: u64,
pub iid: MergeRequestInternalId,
/// The description of the merge request.
pub description: Option<String>,
......@@ -691,7 +692,7 @@ pub struct BuildHook {
/// The object ID that was built.
pub sha: String,
/// The ID of the build.
pub build_id: BuildId,
pub build_id: JobId,
/// The name of the build.
pub build_name: String,
pub build_stage: String,
......
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