11 releases (7 breaking)

0.10.0 Mar 11, 2025
0.9.0 Oct 3, 2024
0.8.0 Jul 3, 2024
0.7.1 Jul 23, 2023
0.3.1 Jul 1, 2022

#112 in Authentication

Download history 114/week @ 2024-11-27 89/week @ 2024-12-04 96/week @ 2024-12-11 47/week @ 2024-12-18 12/week @ 2024-12-25 52/week @ 2025-01-01 47/week @ 2025-01-08 132/week @ 2025-01-15 86/week @ 2025-01-22 96/week @ 2025-01-29 82/week @ 2025-02-05 113/week @ 2025-02-12 186/week @ 2025-02-19 138/week @ 2025-02-26 327/week @ 2025-03-05 209/week @ 2025-03-12

894 downloads per month
Used in dgira

MIT license

92KB
2K SLoC

gouqi

Software License Released API docs Rust codecov

a rust interface for jira

Forked from goji https://github.com/softprops/goji

install

Add the following to your Cargo.toml file

[dependencies]
gouqi = "*"

# Optional: Enable async API
gouqi = { version = "*", features = ["async"] }

usage

Please browse the examples directory in this repo for some example applications.

Basic usage requires a jira host, and a flavor of jira::Credentials for authorization.

Synchronous API

The default API uses synchronous requests:

extern crate gouqi;

use gouqi::{Credentials, Jira};
use std::env;
use tracing::error;

fn main() { 
    if let Ok(host) = env::var("JIRA_HOST") {
        let query = env::args().nth(1).unwrap_or("order by created DESC".to_owned());
        let jira = Jira::new(host, Credentials::Anonymous).expect("Error initializing Jira");

        match jira.search().iter(query, &Default::default()) {
            Ok(results) => {
                for issue in results {
                    println!("{:#?}", issue);
                }
            }
            Err(err) => panic!("{:#?}", err),
        }
    } else {
        error!("Missing environment variable JIRA_HOST!");
    }
}

Asynchronous API

With the async feature enabled, you can use the asynchronous API:

extern crate gouqi;

use futures::stream::StreamExt;
use gouqi::{Credentials, SearchOptions};
use std::env;
use tracing::error;

#[tokio::main]
async fn main() {
    if let Ok(host) = env::var("JIRA_HOST") {
        let query = env::args().nth(1).unwrap_or("order by created DESC".to_owned());
        
        // Create an async Jira client
        let jira = gouqi::r#async::Jira::new(host, Credentials::Anonymous)
            .expect("Error initializing Jira");

        // Use the stream method to get a futures Stream
        let search_options = SearchOptions::default();
        match jira.search().stream(query, &search_options).await {
            Ok(mut stream) => {
                // Consume the stream asynchronously
                while let Some(issue) = stream.next().await {
                    println!("{:#?}", issue);
                }
            }
            Err(err) => error!("{:#?}", err),
        }
    } else {
        error!("Missing environment variable JIRA_HOST!");
    }
}

You can also convert between sync and async clients:

// Convert from sync to async
let sync_jira = Jira::new(host, credentials)?;
let async_jira = sync_jira.into_async();

// Convert from async to sync
let async_jira = gouqi::r#async::Jira::new(host, credentials)?;
let sync_jira = crate::sync::Jira::from(&async_jira);

## Commiting a PR

Please make sure to run `cargo fmt`, `cargo test` and `cargo clippy` before committing.
New code should contains tests.
Commits to follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.

Changelog is generated using [git cliff](https://github.com/orhun/git-cliff)

```sh
cargo install git-cliff
git cliff -o --use-branch-tags

what's with the name

Jira's name is a shortened form of gojira, another name for godzilla. Goji is a play on that.

Goji (Chinese: 枸杞; pinyin: gǒuqǐ)

Doug Tangren (softprops) 2016-2018

Dependencies

~5–17MB
~231K SLoC