Commit ced5e7c6 authored by Ben Boeckel's avatar Ben Boeckel Committed by Kitware Robot
Browse files

Merge topic 'gitlab-11.10'

a5010eac types: update for 11.10
b428ba91

 types: implement serialization traits for AccessLevel

Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Ben Boeckel's avatarBen Boeckel <ben.boeckel@kitware.com>
Merge-request: !148
parents 3e837848 a5010eac
......@@ -30,6 +30,42 @@
"discussion_locked": null,
"downvotes": 0,
"force_remove_source_branch": true,
"head_pipeline": {
"before_sha": null,
"committed_at": null,
"coverage": null,
"created_at": "2016-10-04T15:56:53.822-04:00",
"detailed_status": {
"details_path": "/ben.boeckel/rust-gitlab/pipelines/29191",
"favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png",
"group": "success",
"has_details": true,
"icon": "status_success",
"illustration": null,
"label": "passed",
"text": "passed",
"tooltip": "passed"
},
"duration": null,
"finished_at": "2016-10-04T15:56:53.868-04:00",
"id": 29191,
"ref": "add_hook-api",
"sha": "04e94ae667024a62a90179f395bfdc2b35f3efd2",
"started_at": null,
"status": "success",
"tag": false,
"updated_at": "2016-10-04T15:56:53.869-04:00",
"user": {
"avatar_url": "https://secure.gravatar.com/avatar/9ddcd45fcb89d966aab95b1f1002f84c?s=80&d=identicon",
"id": 11,
"name": "Kitware Robot",
"state": "active",
"username": "kwrobot",
"web_url": "https://gitlab.kitware.com/kwrobot"
},
"web_url": "https://gitlab.kitware.com/ben.boeckel/rust-gitlab/pipelines/29191",
"yaml_errors": null
},
"id": 20215,
"iid": 35,
"labels": [],
......@@ -41,6 +77,7 @@
"merged_by": null,
"milestone": null,
"project_id": 855,
"reference": "!35",
"sha": "04e94ae667024a62a90179f395bfdc2b35f3efd2",
"should_remove_source_branch": null,
"source_branch": "add_hook-api",
......
......@@ -16,6 +16,7 @@
"creator_id": 13,
"default_branch": "master",
"description": "Rust library for communicating with a Gitlab instance.",
"external_authorization_classification_label": null,
"forks_count": 7,
"http_url_to_repo": "https://gitlab.kitware.com/utils/rust-gitlab.git",
"id": 855,
......
......@@ -9,6 +9,7 @@
"current_sign_in_at": "2018-10-11T08:36:09.687-04:00",
"email": "kwrobot@kitware.com",
"external": false,
"highest_role": 50,
"id": 11,
"identities": [],
"last_activity_on": "2018-10-25",
......
......@@ -693,6 +693,7 @@ fn test_read_user() {
Some(Utc.ymd(2015, 2, 26).and_hms_milli(15, 58, 34, 670)),
);
assert_eq!(user.is_admin, None);
assert_eq!(user.highest_role, Some(AccessLevel::Owner));
assert_eq!(user.bio, Some("".to_string()));
assert_eq!(user.private_profile, None);
assert_eq!(user.location, None);
......
......@@ -103,6 +103,10 @@ pub struct User {
///
/// Only available when talking to GitLab as an admin.
pub is_admin: Option<bool>,
/// The highest access level available to the user.
///
/// Only available when talking to GitLab as an admin.
pub highest_role: Option<AccessLevel>,
/// Self-described biography of the user.
pub bio: Option<String>,
/// Whether the account has a private profile.
......@@ -181,6 +185,10 @@ pub struct UserPublic {
///
/// Only available when talking to GitLab as an admin.
pub is_admin: Option<bool>,
/// The highest access level available to the user.
///
/// Only available when talking to GitLab as an admin.
pub highest_role: Option<AccessLevel>,
/// Self-described biography of the user.
pub bio: Option<String>,
/// Whether the account has a private profile.
......@@ -256,6 +264,7 @@ impl From<UserPublic> for User {
web_url: user.web_url,
created_at: user.created_at,
is_admin: user.is_admin,
highest_role: user.highest_role,
bio: user.bio,
private_profile: user.private_profile,
location: user.location,
......@@ -707,6 +716,21 @@ impl Display for AccessLevel {
}
}
impl Serialize for AccessLevel {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
u64::from(*self).serialize(serializer)
}
}
impl<'de> Deserialize<'de> for AccessLevel {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
Ok(<u64 as Deserialize>::deserialize(deserializer)?.into())
}
}
#[cfg_attr(feature = "strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone)]
/// A member with extra permissions on a project.
......
Supports Markdown
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