Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chenaoxd/gritlab
Gritlab is a async gitlab API sdk.
https://github.com/chenaoxd/gritlab
gitlab gitlab-api rust
Last synced: about 1 month ago
JSON representation
Gritlab is a async gitlab API sdk.
- Host: GitHub
- URL: https://github.com/chenaoxd/gritlab
- Owner: chenaoxd
- License: mit
- Created: 2022-02-26T18:32:41.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-04T15:17:14.000Z (over 2 years ago)
- Last Synced: 2024-10-13T15:50:09.665Z (2 months ago)
- Topics: gitlab, gitlab-api, rust
- Language: Rust
- Homepage:
- Size: 121 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gritlab
`Gritlab` is a async gitlab API sdk.
[![Crates.io][crates-badge]][crates-url]
[![MIT licensed][mit-badge]][mit-url][crates-badge]: https://img.shields.io/crates/v/gritlab.svg
[crates-url]: https://crates.io/crates/gritlab
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[mit-url]: https://github.com/chenaoxd/gritlab/blob/master/LICENSE## Usage example
```rust
use std::env;use anyhow::Context;
use gritlab::{
client::Gritlab, hook::CreateHookOption, status::CreateStatusOption, Result,
};#[tokio::main]
async fn main() -> Result<()> {
let (owner, repo) = ("chenao", "test-jarvis");
let commit_id = "ff0e6ddd616ffabfc02d6943b2aed496fca2c63c";let host = env::var("HOST")
.with_context(|| format!("get environment variable HOST failed"))?;
let access_token = env::var("ACCESS_TOKEN")
.with_context(|| format!("get environment variable ACCESS_TOKEN failed"))?;let cli = Gritlab::builder(host).token(access_token).build()?;
let user = cli.current_user().await?;
println!("current_user: {:#?}", user);let _repos = cli.list_repos().await?;
// println!("repos: {:#?}", repos);let repo_ = cli.get_repo(owner, repo).await?;
println!("repo: {:#?}", repo_);let hook = cli
.create_hook(
owner,
repo,
&CreateHookOption::new(
"https://foo.bar/hook",
Some("demo_token".to_string()),
),
)
.await?;
println!("new hook: {:#?}", hook);let hooks = cli.list_hooks(owner, repo).await?;
println!("hooks: {:#?}", hooks);cli.delete_hook(owner, repo, hook.id).await?;
println!("hook deleted");let status = cli
.create_status(
owner,
repo,
commit_id,
&CreateStatusOption {
state: "failed".to_string(),
ref_: None,
name: Some("jarvis".to_string()),
target_url: Some("https://jarvis.chenaoxd.com/repo/1/jobs".to_string()),
description: Some("some description".to_string()),
coverage: None,
pipeline_id: None,
},
)
.await?;
println!("created status: {:#?}", status);let statuses = cli.list_statuses(owner, repo, commit_id).await?;
println!("statuses: {:#?}", statuses);Ok(())
}
```## License
This project is licensed under the [MIT license](./LICENSE).