Commit 5f24d8f6 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

gitlab: add a method for setting labels on an issue

parent acc00434
......@@ -14,6 +14,7 @@ readme = "README.md"
chrono = { version = "~0.3", features = ["serde"] }
error-chain = "~0.9"
hyper = { version = "~0.10", default-features = false }
itertools = "~0.5"
log = "~0.3"
reqwest = "~0.4"
serde = "~0.9"
......
......@@ -6,6 +6,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate itertools;
use self::itertools::Itertools;
extern crate reqwest;
use self::reqwest::{Client, Method, RequestBuilder, Url};
......@@ -24,7 +27,7 @@ use error::*;
use types::*;
use std::borrow::Borrow;
use std::fmt::{self, Debug};
use std::fmt::{self, Display, Debug};
/// A representation of the Gitlab API for a single user.
///
......@@ -415,6 +418,18 @@ impl Gitlab {
self._post_with_param(path, &[("body", content)])
}
/// Set the labels on an issue.
pub fn set_issue_labels<I, L>(&self, project: ProjectId, issue: IssueId, labels: I)
-> Result<Issue>
where I: IntoIterator<Item = L>,
L: Display,
{
let path = &format!("projects/{}/issues/{}",
project,
issue);
self._put_with_param(path, &[("labels", labels.into_iter().join(","))])
}
/// Create a URL to an API endpoint.
fn _mk_url(&self, url: &str) -> Result<Url> {
debug!(target: "gitlab", "api call {}", url);
......
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