Skip to main content

Jira

Struct Jira 

Source
pub struct Jira { /* private fields */ }
Expand description

Jira client with cached-session management via the Session trait.

Implementations§

Source§

impl Jira

Source

pub fn new(config: &JiraConfig) -> Self

Builds a client from the config; no network activity yet.

use kasl::api::jira::{Jira, JiraConfig};

let config = JiraConfig {
    login: "username".to_string(),
    api_url: "https://jira.company.com".to_string(),
    completed_statuses: Vec::new(),
};
let jira = Jira::new(&config);
Source

pub async fn get_completed_issues( &mut self, date: &NaiveDate, ) -> Result<Vec<JiraIssue>>

Fetches the user’s issues resolved on date (full-day range).

A 401 drops the cached session and retries up to the limit; other failures propagate - completed issues feed the report, so a silent empty result would hide real problems.

let config = JiraConfig {
    login: "username".to_string(),
    api_url: "https://jira.company.com".to_string(),
    completed_statuses: Vec::new(),
};
let mut jira = Jira::new(&config);

let today = chrono::Local::now().date_naive();
let issues = jira.get_completed_issues(&today).await?;

for issue in issues {
    println!("Completed: {} - {}", issue.key, issue.fields.summary);
}
Source

pub async fn get_assigned_open_issues( &mut self, extra_field_ids: &[String], ) -> Result<Vec<JiraIssue>>

Fetches open issues currently assigned to the authenticated user.

Uses JQL assignee = currentUser() AND resolution is EMPTY. Paginates through all matching issues (startAt / total). Extra field ids (custom fields such as Scoring) are included in the fields query.

A poll that fails is an error, never an empty list. The caller reconciles the inbox against whatever comes back, so an empty answer for a dropped VPN would mark every issue gone - and the next good poll would bring all of them “back”, one change toast per issue.

Source

pub async fn get_assigned_open_issues_noninteractive( &mut self, extra_field_ids: &[String], ) -> Result<Option<Vec<JiraIssue>>>

Like [get_assigned_open_issues], but never prompts for a password.

Uses a cached session cookie and/or the keyring secret. Returns Ok(None) when neither is available so background daemons can skip the poll without blocking on stdin. A poll that fails is an error, for the same reason as in [get_assigned_open_issues]: the daemon must skip the reconcile, not reconcile against nothing.

Source

pub fn open_issues_url(&self) -> String

Builds the issue-navigator URL listing the user’s open issues.

Summary toasts point here: they speak for many issues at once, so no single browse URL fits.

Source

pub fn issue_browse_url(&self, key: &str) -> String

Builds a browse URL for an issue key using this client’s API base.

Source

pub fn priority_rank(priority: &Option<JiraPriority>) -> i32

Maps a Jira priority id to a sortable rank (lower = more urgent).

Source

pub fn extract_number(value: &Value) -> Option<f64>

Extracts a numeric value from a Jira custom-field JSON value.

Supports bare numbers, numeric strings, and objects with value / amount.

Source

pub fn sort_value_from_issue(issue: &JiraIssue, field_id: &str) -> Option<f64>

Reads a numeric custom field from issue extras by field id.

Trait Implementations§

Source§

impl Debug for Jira

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Session for Jira

Source§

async fn login(&self) -> Result<String>

Logs in and returns the session cookie as name=value.

Source§

fn set_credentials(&mut self, password: &str) -> Result<()>

Stores the password (encoded as the provider requires) for login.
Source§

fn session_id_file(&self) -> &str

Per-provider session cache filename.
Source§

fn secret(&self) -> Secret

Per-provider secret manager (prompt text, cache file).
Source§

fn retry(&self) -> i32

Current failed-attempt count.
Source§

fn inc_retry(&mut self)

Bumps the failed-attempt count.
Source§

fn reset_retry(&mut self)

Clears the failed-attempt count after a successful login.
Source§

async fn get_session_id(&mut self) -> Result<String>

Returns a session id: cached if available, otherwise via login with up to [MAX_RETRY_COUNT] password attempts (a retry always re-prompts rather than reusing a password that just failed).
Source§

fn read_session_id(file_name: &str) -> Result<String>

Reads the cached session id.
Source§

fn write_session_id(file_name: &str, session_id: &str) -> Result<()>

Writes the session id to the cache file.
Source§

fn delete_session_id(&self) -> Result<()>

Drops the cached session, forcing a fresh login next time.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Jira

§

impl !UnwindSafe for Jira

§

impl Freeze for Jira

§

impl Send for Jira

§

impl Sync for Jira

§

impl Unpin for Jira

§

impl UnsafeUnpin for Jira

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more