Commit cec57c05 authored by Ben Boeckel's avatar Ben Boeckel

types: add structs for gitlab API entities

Got bored typing up docs part of the way through. Some of the more
obscure entities are left untouched.

Objects meant to be passed to POST or PUT endpoints are not represented
here (though they should be added).

Fixes #1.
parent 5e30ec59
......@@ -8,11 +8,17 @@ Gitlab API client.
"""
repository = "https://gitlab.kitware.com/utils/rust-gitlab.git"
homepage = "https://gitlab.kitware.com/utils/rust-gitlab"
build = "build.rs"
[build-dependencies]
serde_codegen = "*"
[dependencies]
chrono = { version = "~0.2", features = ["serde"] }
#ease = "~0.5"
hyper = "~0.9"
log = "*"
serde = "~0.7"
serde_json = "~0.7"
url = "~1.1"
......
extern crate serde_codegen;
use std::env;
use std::fs;
use std::path::Path;
pub fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let paths = [
"types",
];
for path in paths.iter() {
let src = format!("src/{}.rs.in", path);
let dst = format!("{}.rs", path);
let src_path = Path::new(&src);
let dst_path = Path::new(&out_dir).join(&dst);
fs::create_dir_all(dst_path.parent().unwrap()).unwrap();
serde_codegen::expand(&src_path, &dst_path).unwrap();
}
}
......@@ -9,36 +9,10 @@ extern crate url;
use self::url::percent_encoding::{PATH_SEGMENT_ENCODE_SET, percent_encode};
use super::error::Error;
use super::types::*;
use std::borrow::Borrow;
#[derive(Clone, Copy)]
/// States for commit statuses.
pub enum CommitStatus {
/// The check is queued.
Pending,
/// The check is currently running.
Running,
/// The check succeeded.
Success,
/// The check failed.
Failed,
/// The check was cancelled.
Cancelled,
}
impl Borrow<str> for CommitStatus {
fn borrow(&self) -> &str {
match *self {
CommitStatus::Pending => "pending",
CommitStatus::Running => "running",
CommitStatus::Success => "success",
CommitStatus::Failed => "failed",
CommitStatus::Cancelled => "canceled", // [sic]
}
}
}
/// A representation of the Gitlab API for a single user.
///
/// Separate users should use separate instances of this.
......@@ -100,7 +74,7 @@ impl Gitlab {
}
/// Create a status message for a commit.
pub fn create_commit_status(&self, project: u64, sha: &str, state: CommitStatus, refname: &str,
pub fn create_commit_status(&self, project: u64, sha: &str, state: StatusState, refname: &str,
name: &str, description: &str)
-> GitlabResult {
let path = &format!("projects/{}/statuses/{}", project, sha);
......
......@@ -10,6 +10,8 @@ extern crate log;
mod error;
mod gitlab;
mod types;
pub use error::Error;
pub use gitlab::Gitlab;
pub use types::*;
include!(concat!(env!("OUT_DIR"), "/types.rs"));
This diff is collapsed.
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