19 releases (6 stable)

1.5.0 May 22, 2024
1.3.0 Jul 3, 2023
1.1.0 Feb 12, 2023
0.7.6 Aug 9, 2022
0.7.4 Jul 26, 2022

#2 in #jira

Download history 14/week @ 2024-06-10 131/week @ 2024-06-24 8/week @ 2024-07-01 2/week @ 2024-07-08 9/week @ 2024-07-15 39/week @ 2024-07-22 9/week @ 2024-07-29 28/week @ 2024-08-05 43/week @ 2024-08-12 39/week @ 2024-08-19 29/week @ 2024-08-26 54/week @ 2024-09-02 30/week @ 2024-09-09 26/week @ 2024-09-16 78/week @ 2024-09-23

192 downloads per month
Used in acorns

Apache-2.0

31KB
543 lines

jira_query

Crates.io Apache-2.0 license Documentation

CI tests Dependency status

Access issues on a remote Jira instance.

Description

The jira_query crate is a Rust library that can query a Jira instance using its REST API. It returns a strongly typed representation of the requested issues.

This library provides no functionality to create or modify issues. The access is read-only.

Usage

Basic anonymous query

Without logging in, search for a single ticket and check for its priority:

use tokio;
use jira_query::JiraInstance;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let jira = JiraInstance::at("https://issues.redhat.com".to_string())?;

    let issue = jira.issue("CS-1113").await?;

    assert_eq!(issue.fields.priority.name, "Normal");

    Ok(())
}

Advanced query

Use an API key to log into Jira. Search for all CentOS Stream tickets that are of the Blocker priority. Check that there is more than one ticket:

use tokio;
use jira_query::{Auth, JiraInstance, Pagination};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let jira = JiraInstance::at("https://bugzilla.redhat.com".to_string())?
        .authenticate(Auth::ApiKey("My API Key".to_string()))
        .paginate(Pagination::ChunkSize(32));

    let query = r#"project="CentOS Stream" AND priority=Blocker"#;

    let issues = jira.search(query).await?;

    assert!(issues.len() > 1);

    Ok(())
}

A note on semantic versioning

This crate reserves the right to make limited breaking changes to the Jira structs in minor versions (X.Y).

The reason is that the official Jira documentation does not specify which fields in the JSON body are optional (Option<T>) and which are mandatory (T). Rather than exposing all fields as optional, this crate tries to process fields as mandatory until proven otherwise in testing. As a consequence, minor releases must occasionally turn a mandatory field to an optional field.

See also

Dependencies

~5–16MB
~219K SLoC