mod jira_import#

module jira_import#

Free-tier Jira platform REST only (no Marketplace apps).

Endpoint map (official Cloud + Server/DC docs):

Op

Endpoint

Notes

Probe

GET /rest/api/2/myself (+ serverInfo)

Cloud Free email+API token or Server PAT

Search

GET /rest/api/2/search?jql=&fields=summary

Free JQL; Server also allows POST search

Comments GET

GET /rest/api/2/issue/{key}/comment

Wiki string or Cloud ADF body

Comment POST

Server: POST /rest/api/2/.../comment wiki · Cloud: POST /rest/api/3/.../comment ADF

No paid formatters

Import writes drafts under corpus/imports/ only. Write is explicit one-shot comment post (review-before-migrate), not bulk library sync.

Functions

fn comment_body_to_text(body: &serde_json::Value) -> String#

Flatten free-platform comment bodies: wiki strings stay as-is; Cloud ADF (Atlassian Document Format) is reduced to plain text without Marketplace apps.

fn default_import_dir() -> PathBuf#

Where imported drafts land by default (never auto-indexed or quality-checked).

fn draft_markdown(id: &str, issue_key: &str, title: &str, prefix: &str, comments: &[(String, String, String)]) -> String#

Render one issue’s comments as a review draft: front matter plus one section per comment. id must already carry {prefix}-.

fn fetch_comments(cfg: &JiraConfig, issue_key: &str) -> Result<Vec<IssueComment>>#

Fetch all comments for one issue (api/2, then api/3 on Cloud-style hosts).

fn format_probe(probe: &JiraProbe) -> String#

Format a probe result for CLI stdout.

fn import_jira(cfg: &JiraConfig, jql: &str, out_dir: &Path, max_results: u32, dry_run: bool, prefix: &str) -> Result<Vec<PathBuf>>#

Import issues matching jql into out_dir as review drafts (never corpus/responses/). Returns the paths written, or, when dry_run is set, the paths that would be written without touching the filesystem or fetching comments.

fn is_cloud_host(base_url: &str) -> bool#

True when the base URL looks like Jira Cloud Free/Standard host.

fn plain_text_to_adf(text: &str) -> serde_json::Value#

Build minimal free ADF document from plain/wiki text (Cloud comment write path).

Official Cloud v3 comments expect Atlassian Document Format bodies (developer.atlassian.com Cloud platform REST). This does not use paid apps.

fn post_comment_from_markdown(cfg: &JiraConfig, issue_key: &str, markdown_path: &Path, dry_run: bool) -> Result<PostedComment>#

Convert a markdown corpus file with pandoc jira writer, then POST as a comment.

When dry_run is true, returns the wiki body that would be posted without calling Jira (still requires pandoc for a real conversion).

fn post_comment_from_markdown_with_format(cfg: &JiraConfig, issue_key: &str, markdown_path: &Path, dry_run: bool, format: CommentBodyFormat) -> Result<PostedComment>#

Like post_comment_from_markdown with an explicit free-tier body format.

fn post_issue_comment(cfg: &JiraConfig, issue_key: &str, body_wiki: &str) -> Result<PostedComment>#

POST a comment via free platform REST (wiki on Server/DC, ADF on Cloud Free).

body_wiki is pandoc jira markup (or plain text). On Cloud Free, it is wrapped in minimal ADF. No Marketplace apps.

fn post_issue_comment_with_format(cfg: &JiraConfig, issue_key: &str, body_wiki: &str, format: CommentBodyFormat) -> Result<PostedComment>#

Like post_issue_comment with an explicit body format.

fn probe_jira(cfg: &JiraConfig) -> Result<JiraProbe>#

Probe free Jira REST: authenticated identity + optional server banner.

Uses only platform endpoints (/rest/api/2/myself, /serverInfo) — no Marketplace apps. Exit path for CLI: non-zero when HTTP fails or auth rejects.

fn search_all_issues(cfg: &JiraConfig, jql: &str, page_size: u32) -> Result<Vec<IssueSummary>>#

Search for issues matching jql, paginating until Jira reports no more.

Tries free platform search paths in order (api/2 then Cloud api/3 variants).

fn slugify(title: &str) -> String#

Turn a title into a slug: lowercase ASCII alphanumerics, everything else collapsed to a single -, with no leading, trailing, or repeated dash.

Enums

enum CommentBodyFormat#

How to encode free write comment bodies for platform REST.

Wiki#

Server/Data Center wiki string: {"body":"h1. ..."} on /rest/api/2/....

Adf#

Cloud Free-compatible ADF on /rest/api/3/... (no Marketplace formatter).

Auto#

*.atlassian.net → Adf, otherwise Wiki.

Implementations

impl CommentBodyFormat#

Functions

fn resolve(self, base_url: &str) -> CommentBodyFormat#
enum JiraAuth#

How to authenticate against the Jira REST API.

Basic#

Jira Cloud convention: an account email plus an API token.

user: String#
token: String#
Header(String)#

A raw Authorization header value, e.g. Bearer <personal-access-token> for Jira Server/Data Center.

Structs and Unions

struct IssueComment#

One comment on a Jira issue, with its body still in Jira wiki markup.

author: String#
created: String#
body_wiki: String#
struct IssueSummary#

One issue found by a JQL search: key plus its summary.

key: String#
summary: String#
struct JiraConfig#

Jira instance connection details.

base_url: String#
auth: JiraAuth#

Implementations

impl JiraConfig#

Functions

fn from_canonic(cfg: &crate::config::CanonicConfig) -> Result<Self>#

Convenience: extract Jira settings from a full crate::config::CanonicConfig.

fn from_settings(jira: &crate::config::JiraSettings) -> Result<Self>#

Build from [jira] settings in canonic.toml / canonic.local.toml.

fn new(base_url: impl Into<String>, auth: JiraAuth) -> Self#
struct JiraProbe#

Result of a free-tier connectivity probe (/myself + optional serverInfo).

base_url: String#
display_name: String#
account: String#
server_title: Option<String>#
server_version: Option<String>#
cloud_host: bool#

Cloud Free-style host (*.atlassian.net) vs Server/DC-style.

comment_format: CommentBodyFormat#

Resolved free comment write format for this host.

struct PostedComment#

One comment created via free REST POST.

issue_key: String#
comment_id: String#
body_wiki: String#