Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created February 22, 2019 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/bf94b664e1b97c2aad82dbdd48e3edb2 to your computer and use it in GitHub Desktop.
Save rust-play/bf94b664e1b97c2aad82dbdd48e3edb2 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
extern crate chrono;
use gitlab::types::*;
use chrono::{DateTime, NaiveDate, NaiveTime, NaiveDateTime, Utc};
fn main() {
let my = gitlab::Gitlab::new("gitlab.com", "PRIVATE-TOKEN").unwrap();
let pid = my.project(ProjectId::new(1664)).unwrap();
let current_user = my.current_user().unwrap();
let otheruser = current_user.clone();
let u1 = UserBasic::from(current_user);
let v1: Vec<UserBasic> = vec![UserBasic::from(otheruser)];
let dt = DateTime::<Utc>::from_utc(NaiveDateTime::new(NaiveDate::from_ymd(1985, 08, 18), NaiveTime::from_hms(12,0,0)), Utc);
let issue = Issue::new(pid.id, "My great title".to_string(), u1)
.with_description("This is a description\nincluding all sorts of things, like:\n- [ ] lists\n```code```\netc…".to_string())
.with_confidential(true)
.with_assignees(v1)
.with_labels(vec!["youpi".to_string(), "youpla".to_string()])
.with_created_at(dt)
.with_due_date(NaiveDate::from_ymd(2019, 08, 01));
let created_issue = my.create_issue(pid.id, issue);
println!("{:?}", created_issue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment