use crate::tickets::api::models::*;
use anyhow::Result;
use async_trait::async_trait;
pub mod github;
pub mod jira;
pub mod linear;
#[derive(Debug, Clone, Default)]
pub struct CreateIssueParams {
pub title: String,
pub description: Option<String>,
pub priority: Option<String>,
pub assignee: Option<String>,
pub labels: Vec<String>,
pub milestone_id: Option<String>,
pub project_id: Option<String>,
pub parent_id: Option<String>,
pub issue_type: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct UpdateIssueParams {
pub title: Option<String>,
pub description: Option<String>,
pub priority: Option<String>,
pub assignee: Option<String>,
pub labels: Option<Vec<String>>,
pub milestone_id: Option<String>,
pub state: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct ListIssuesParams {
pub project_id: Option<String>,
pub state: Option<String>,
pub assignee: Option<String>,
pub labels: Vec<String>,
pub limit: u32,
pub offset: u32,
}
#[derive(Debug, Clone, Default)]
pub struct SearchIssuesParams {
pub query: Option<String>,
pub state: Option<String>,
pub priority: Option<String>,
pub labels: Vec<String>,
pub assignee: Option<String>,
pub project_id: Option<String>,
pub milestone_id: Option<String>,
pub limit: u32,
pub offset: u32,
}
#[derive(Debug, Clone, Default)]
pub struct CreateMilestoneParams {
pub name: String,
pub description: Option<String>,
pub due_date: Option<String>,
}
#[async_trait]
pub trait Backend: Send + Sync {
fn name(&self) -> &'static str;
async fn create_issue(&self, params: CreateIssueParams) -> Result<Issue>;
async fn get_issue(&self, id: &str) -> Result<Issue>;
async fn update_issue(&self, id: &str, params: UpdateIssueParams) -> Result<Issue>;
async fn close_issue(&self, id: &str, comment: Option<&str>) -> Result<Issue>;
async fn reopen_issue(&self, id: &str) -> Result<Issue>;
async fn list_issues(&self, params: ListIssuesParams) -> Result<Vec<Issue>>;
async fn search_issues(&self, params: SearchIssuesParams) -> Result<Vec<Issue>>;
async fn add_comment(&self, issue_id: &str, body: &str) -> Result<Comment>;
async fn list_comments(&self, issue_id: &str) -> Result<Vec<Comment>>;
async fn update_comment(&self, issue_id: &str, comment_id: &str, body: &str)
-> Result<Comment>;
async fn delete_comment(&self, issue_id: &str, comment_id: &str) -> Result<()>;
async fn list_labels(&self) -> Result<Vec<Label>>;
async fn create_label(
&self,
name: &str,
color: Option<&str>,
description: Option<&str>,
) -> Result<Label>;
async fn add_labels(&self, issue_id: &str, labels: &[String]) -> Result<()>;
async fn remove_labels(&self, issue_id: &str, labels: &[String]) -> Result<()>;
async fn list_milestones(&self) -> Result<Vec<Milestone>>;
async fn create_milestone(&self, params: CreateMilestoneParams) -> Result<Milestone>;
async fn close_milestone(&self, id: &str) -> Result<Milestone>;
async fn get_milestone_issues(&self, id: &str) -> Result<Vec<Issue>>;
async fn list_projects(&self) -> Result<Vec<Project>>;
async fn get_project(&self, id: &str) -> Result<Project>;
async fn list_epics(&self) -> Result<Vec<Issue>>;
async fn get_epic_issues(&self, epic_id: &str) -> Result<Vec<Issue>>;
async fn create_project_update(
&self,
project_id: &str,
body: &str,
health: Option<&str>,
) -> Result<ProjectUpdate>;
async fn list_project_updates(&self, project_id: &str) -> Result<Vec<ProjectUpdate>>;
async fn list_states(&self) -> Result<Vec<String>>;
async fn transition_issue(&self, id: &str, state: &str) -> Result<Issue>;
async fn assign_issue(&self, id: &str, assignee: &str) -> Result<Issue>;
}