[][src]Crate jiragen

jiragen is a collection of utilities for sending requests to JIRA. It includes functionality for sending bulk issue creation from a .csv file.

use csv::{Reader, StringRecord};
use jiragen::{Config, csv_to_json, JiraClient, JiraIssue};
use serde_json::json;

// Configure & initialize JIRA client
let config = Config {
  jira_url: "my-jira.com".to_string(),
  jira_user: "user".to_string(),
  jira_password: "password".to_string(),
let jira = JiraClient::new(config);

// Prepare CSV data
let mut csv_reader = Reader::from_path("jiragen_issues.csv").unwrap();
let ids_record = csv_reader.headers().unwrap().clone();
let ids: Vec<&str> = ids_record.iter().collect();

let mut csv_records = csv_reader.into_records();
csv_records.next(); // skip line 2, which contains human-readable field names

// create bulk issues to send starting on line 3
let filtered_csv_records: Vec<StringRecord> = csv_records
  .filter_map(|record_result| match record_result {
    Ok(result) => Some(result),
    Err(_) => None,
let json_values = csv_to_json(ids, filtered_csv_records).unwrap();

let issues_to_create: Vec<JiraIssue> = json_values
  .map(|record_json| JiraIssue {
    update: None,
    fields: record_json,

let bulk_issue_create_request = jira.init_request("POST", "/rest/api/2/issue/bulk");
let request_json = json!({ "issueUpdates": issues_to_create });

let mut response = bulk_issue_create_request



JiraGen configuration that is used for sending requests to JIRA. The username and password fields are required because JiraGen uses Basic Authentication to send requests to JIRA.


Used as a possible value of Error.


A JiraClient instance handles requests sent to JIRA. An instance is created via JiraClient::new(Config), and then that instance can then be used for creating requests to JIRA, via .init_request() (which creates authorization headers using the Config username/password).


The object to send to JIRA’s "bulk issue creation" API endpoint



Error handler for JiraGen-related errors. Encapsulates CSV, Reqwest, File, and Serialization errors.



Reads the issues template .csv file and converts it to a JSON object