atlassian_rust_api/jira/
jira.rs1use std::sync::Arc;
2
3use crate::rest_client::{RestClient, RestClientBuilder};
4use crate::Result;
5
6#[derive(Debug, Clone)]
7pub struct Jira {
8 pub(crate) client: Arc<RestClient>,
9}
10
11impl Jira {
12 pub fn builder() -> JiraBuilder {
13 JiraBuilder::default()
14 }
15}
16
17#[derive(Debug, Default)]
18pub struct JiraBuilder {
19 client: RestClientBuilder
20}
21
22impl JiraBuilder {
23 pub fn url(mut self, url: impl Into<String>) -> JiraBuilder {
24 self.client = self.client.url(url.into());
25 self
26 }
27
28 pub fn username(mut self, username: impl Into<String>) -> JiraBuilder {
29 self.client = self.client.username(username.into());
30 self
31 }
32
33 pub fn password(mut self, password: impl Into<String>) -> JiraBuilder {
34 self.client = self.client.password(password.into());
35 self
36 }
37
38 pub fn timeout(mut self, timeout: u64) -> JiraBuilder {
39 self.client = self.client.timeout(timeout);
40 self
41 }
42
43 pub fn api_root(mut self, api_root: impl Into<String>) -> JiraBuilder {
44 self.client = self.client.api_root(api_root.into());
45 self
46 }
47
48 pub fn api_version(mut self, api_version: impl Into<String>) -> JiraBuilder {
49 self.client = self.client.api_version(api_version.into());
50 self
51 }
52
53 pub fn cloud(mut self, cloud: bool) -> JiraBuilder {
54 self.client = self.client.cloud(cloud);
55 self
56 }
57
58 pub fn session(mut self, session: reqwest::Client) -> JiraBuilder {
59 self.client = self.client.session(session);
60 self
61 }
62
63 pub fn build(self) -> Result<Jira> {
64 let client = self.client.build()?;
65 Ok(Jira {
66 client: Arc::new(client)
67 })
68 }
69}