Rq

Struct Rq 

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

This struct represents a request to Jira

Implementations§

Source§

impl Rq

Source

pub fn new(bot: Rujira) -> Self

Source

pub fn uri(self, uri: &str) -> Self

Source

pub fn method(self, method: Method) -> Self

Source

pub fn add_header(self, header: &[u8], value: &str) -> Self

Source

pub fn add_params(self, params: Vec<(&str, &str)>) -> Self

Source

pub fn load_payload(self, value: Value) -> Self

Source

pub fn add_payload(self, key: &str, value: Value) -> Self

Examples found in repository?
examples/check_connection.rs (line 22)
7async fn main() {
8    dotenv().ok();
9    fmt()
10        .with_env_filter(EnvFilter::from_default_env())
11        .compact()
12        .init();
13    let bot = Rujira::new().from_env_handler();
14    let Ok(me) = crate::api::myself::get(bot.clone()).apply().await else {
15        todo!()
16    };
17    tracing::debug!(?me);
18    let Some(name) = me.data["displayName"].as_str() else {
19        todo!()
20    };
21    let Ok(project) = crate::api::project::create(bot.clone(), "ITMG", "iTmage", "software", name)
22        .add_payload("description", json!("Custom field added by bot"))
23        .apply()
24        .await
25    else {
26        todo!()
27    };
28    tracing::debug!(?project);
29    let fields = json!({
30        "project": { "key": "ITMG" },
31        "summary": "BOT: added a new feature.",
32        "description": "This task was generated by the bot when creating changes in the repository.",
33        "issuetype": { "name": "Task" },
34    });
35    let Ok(issue) = crate::api::issue::create(bot.clone(), fields, false)
36        .apply()
37        .await
38    else {
39        todo!()
40    };
41    tracing::debug!(?issue);
42    let project = crate::api::project::delete(bot.clone(), "ITMG")
43        .apply()
44        .await;
45    tracing::debug!(?project);
46}
Source

pub fn apply_if<T, F>(self, val: Option<T>, fun: F) -> Self
where Self: Sized, F: FnOnce(Self, T) -> Self,

Source

pub async fn apply(self) -> Result<Rs, Error>

Examples found in repository?
examples/sprint.rs (line 18)
6async fn main() {
7    dotenv().ok();
8    fmt()
9        .with_env_filter(EnvFilter::from_default_env())
10        .compact()
11        .init();
12    let bot = Rujira::new().from_env_handler();
13    let id = agile::sprint::id_by_name(bot.clone(), "Sample Sprint 2", "1")
14        .await
15        .unwrap();
16    println!("{:#?}", id);
17    let list = agile::sprint::list(bot.clone(), "1", None, None, None)
18        .apply()
19        .await;
20    println!("{:#?}", list);
21}
More examples
Hide additional examples
examples/check_connection.rs (line 14)
7async fn main() {
8    dotenv().ok();
9    fmt()
10        .with_env_filter(EnvFilter::from_default_env())
11        .compact()
12        .init();
13    let bot = Rujira::new().from_env_handler();
14    let Ok(me) = crate::api::myself::get(bot.clone()).apply().await else {
15        todo!()
16    };
17    tracing::debug!(?me);
18    let Some(name) = me.data["displayName"].as_str() else {
19        todo!()
20    };
21    let Ok(project) = crate::api::project::create(bot.clone(), "ITMG", "iTmage", "software", name)
22        .add_payload("description", json!("Custom field added by bot"))
23        .apply()
24        .await
25    else {
26        todo!()
27    };
28    tracing::debug!(?project);
29    let fields = json!({
30        "project": { "key": "ITMG" },
31        "summary": "BOT: added a new feature.",
32        "description": "This task was generated by the bot when creating changes in the repository.",
33        "issuetype": { "name": "Task" },
34    });
35    let Ok(issue) = crate::api::issue::create(bot.clone(), fields, false)
36        .apply()
37        .await
38    else {
39        todo!()
40    };
41    tracing::debug!(?issue);
42    let project = crate::api::project::delete(bot.clone(), "ITMG")
43        .apply()
44        .await;
45    tracing::debug!(?project);
46}
examples/cli.rs (line 121)
111async fn main() {
112    dotenv().ok();
113    fmt()
114        .with_env_filter(EnvFilter::from_default_env())
115        .compact()
116        .init();
117    let bot = Rujira::new().from_env_handler();
118    let args = Cli::parse();
119    match args.command {
120        Commands::Myself => {
121            let me = match crate::api::myself::get(bot).apply().await {
122                Ok(rs) => rs,
123                Err(e) => {
124                    eprintln!("{e}");
125                    panic!();
126                }
127            };
128            println!("{me:#?}");
129        }
130        Commands::Issue(s) => match s.command {
131            IssueCommands::Create {
132                project,
133                summary,
134                description,
135                r#type,
136            } => {
137                let fields = json!({
138                    "project": { "key": &project },
139                    "summary": &summary,
140                    "description": &description,
141                    "issuetype": { "name": &r#type },
142                });
143                let issue = crate::api::issue::create(bot.clone(), fields, false)
144                    .apply()
145                    .await
146                    .unwrap();
147                println!("{issue:#?}");
148            }
149            IssueCommands::Edit { key, sprint } => {
150                let payload = json!({
151                    "sprint": { "name": sprint }
152                });
153                let issue = crate::api::issue::edit(bot.clone(), &key, None, Some(payload), None)
154                    .apply()
155                    .await
156                    .unwrap();
157                println!("{issue:#?}");
158            }
159            IssueCommands::Get { key } => {
160                let issue = crate::api::issue::get(bot.clone(), &key, None, None, None, None)
161                    .apply()
162                    .await
163                    .unwrap();
164                println!("{issue:#?}");
165            }
166            _ => todo!(),
167        },
168        Commands::Project(s) => match s.command {
169            ProjectCommands::Update {
170                key,
171                update,
172                expand,
173            } => {
174                // ### Example
175                // ```
176                // cargo run --example cli -- project update T1 -u '{"name":"new"}'
177                // ```
178                let update = serde_json::from_str(&update).unwrap();
179                let project = api::project::update(bot.clone(), &key, update, expand.as_deref())
180                    .apply()
181                    .await
182                    .unwrap();
183                println!("{project:#?}");
184            }
185            ProjectCommands::List {
186                include_archive,
187                browse_archive,
188                expand,
189                recent,
190            } => {
191                let projects = api::project::list(
192                    bot.clone(),
193                    include_archive,
194                    browse_archive,
195                    // TOASK: Why it is as_deref working?
196                    expand.as_deref(),
197                    recent,
198                )
199                .apply()
200                .await
201                .unwrap();
202                println!("{projects:#?}");
203            }
204            ProjectCommands::Create {
205                key,
206                name,
207                r#type,
208                lead,
209            } => {
210                api::project::create(bot.clone(), &key, &name, &r#type, &lead)
211                    .apply()
212                    .await
213                    .unwrap();
214            }
215            ProjectCommands::Delete { key } => {
216                api::project::delete(bot.clone(), &key)
217                    .apply()
218                    .await
219                    .unwrap();
220            }
221        },
222        Commands::Board(s) => match s.command {
223            BoardCommands::List {} => {
224                let boards = agile::board::list(bot.clone(), None, None, None, None, None)
225                    .apply()
226                    .await
227                    .unwrap();
228                println!("{boards:#?}");
229            }
230            BoardCommands::Get { key } => {
231                let board = agile::board::get(bot.clone(), &key).apply().await.unwrap();
232                println!("{board:#?}");
233            }
234        },
235        Commands::Sprint(s) => match s.command {
236            SprintCommands::List { board } => {
237                let sprints = agile::sprint::list(bot.clone(), &board, None, None, None)
238                    .apply()
239                    .await
240                    .unwrap();
241                println!("{sprints:#?}");
242            }
243            SprintCommands::Get { key } => {
244                let sprint = agile::sprint::get(bot.clone(), &key).apply().await.unwrap();
245                println!("{sprint:#?}");
246            }
247            SprintCommands::Issue { key, task } => {
248                let payload = json!([task]);
249                let sprint = agile::sprint::issue(bot.clone(), &key, payload)
250                    .apply()
251                    .await
252                    .unwrap();
253                println!("{sprint:#?}");
254            }
255        },
256    }
257}

Trait Implementations§

Source§

impl Default for Rq

Source§

fn default() -> Rq

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Rq

§

impl RefUnwindSafe for Rq

§

impl Send for Rq

§

impl Sync for Rq

§

impl Unpin for Rq

§

impl UnwindSafe for Rq

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: 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: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,