jirav2/apis/
issue_search_api.rs

1/*
2 * The Jira Cloud platform REST API
3 *
4 * Jira Cloud platform REST API documentation
5 *
6 * The version of the OpenAPI document: 1001.0.0-SNAPSHOT
7 * Contact: ecosystem@atlassian.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`get_issue_picker_resource`]
18#[derive(Clone, Debug, Default)]
19pub struct GetIssuePickerResourceParams {
20    /// A string to match against text fields in the issue such as title, description, or comments.
21    pub query: Option<String>,
22    /// A JQL query defining a list of issues to search for the query term. Note that `username` and `userkey` cannot be used as search terms for this parameter, due to privacy reasons. Use `accountId` instead.
23    pub current_jql: Option<String>,
24    /// The key of an issue to exclude from search results. For example, the issue the user is viewing when they perform this query.
25    pub current_issue_key: Option<String>,
26    /// The ID of a project that suggested issues must belong to.
27    pub current_project_id: Option<String>,
28    /// Indicate whether to include subtasks in the suggestions list.
29    pub show_sub_tasks: Option<bool>,
30    /// When `currentIssueKey` is a subtask, whether to include the parent issue in the suggestions if it matches the query.
31    pub show_sub_task_parent: Option<bool>
32}
33
34/// struct for passing parameters to the method [`match_issues`]
35#[derive(Clone, Debug, Default)]
36pub struct MatchIssuesParams {
37    pub issues_and_jql_queries: crate::models::IssuesAndJqlQueries
38}
39
40/// struct for passing parameters to the method [`search_for_issues_using_jql`]
41#[derive(Clone, Debug, Default)]
42pub struct SearchForIssuesUsingJqlParams {
43    /// The [JQL](https://confluence.atlassian.com/x/egORLQ) that defines the search. Note:   *  If no JQL expression is provided, all issues are returned.  *  `username` and `userkey` cannot be used as search terms due to privacy reasons. Use `accountId` instead.  *  If a user has hidden their email address in their user profile, partial matches of the email address will not find the user. An exact match is required.
44    pub jql: Option<String>,
45    /// The index of the first item to return in a page of results (page offset).
46    pub start_at: Option<i32>,
47    /// The maximum number of items to return per page. To manage page size, Jira may return fewer items per page where a large number of fields are requested. The greatest number of items returned per page is achieved when requesting `id` or `key` only.
48    pub max_results: Option<i32>,
49    /// Determines how to validate the JQL query and treat the validation results. Supported values are:   *  `strict` Returns a 400 response code if any errors are found, along with a list of all errors (and warnings).  *  `warn` Returns all errors as warnings.  *  `none` No validation is performed.  *  `true` *Deprecated* A legacy synonym for `strict`.  *  `false` *Deprecated* A legacy synonym for `warn`.  Note: If the JQL is not correctly formed a 400 response code is returned, regardless of the `validateQuery` value.
50    pub validate_query: Option<String>,
51    /// A list of fields to return for each issue, use it to retrieve a subset of fields. This parameter accepts a comma-separated list. Expand options include:   *  `*all` Returns all fields.  *  `*navigable` Returns navigable fields.  *  Any issue field, prefixed with a minus to exclude.  Examples:   *  `summary,comment` Returns only the summary and comments fields.  *  `-description` Returns all navigable (default) fields except description.  *  `*all,-comment` Returns all fields except comments.  This parameter may be specified multiple times. For example, `fields=field1,field2&fields=field3`.  Note: All navigable fields are returned by default. This differs from [GET issue](#api-rest-api-2-issue-issueIdOrKey-get) where the default is all fields.
52    pub fields: Option<Vec<String>>,
53    /// Use [expand](#expansion) to include additional information about issues in the response. This parameter accepts a comma-separated list. Expand options include:   *  `renderedFields` Returns field values rendered in HTML format.  *  `names` Returns the display name of each field.  *  `schema` Returns the schema describing a field type.  *  `transitions` Returns all possible transitions for the issue.  *  `operations` Returns all possible operations for the issue.  *  `editmeta` Returns information about how each field can be edited.  *  `changelog` Returns a list of recent updates to an issue, sorted by date, starting from the most recent.  *  `versionedRepresentations` Instead of `fields`, returns `versionedRepresentations` a JSON array containing each version of a field's value, with the highest numbered item representing the most recent version.
54    pub expand: Option<String>,
55    /// A list of issue property keys for issue properties to include in the results. This parameter accepts a comma-separated list. Multiple properties can also be provided using an ampersand separated list. For example, `properties=prop1,prop2&properties=prop3`. A maximum of 5 issue property keys can be specified.
56    pub properties: Option<Vec<String>>,
57    /// Reference fields by their key (rather than ID).
58    pub fields_by_keys: Option<bool>
59}
60
61/// struct for passing parameters to the method [`search_for_issues_using_jql_post`]
62#[derive(Clone, Debug, Default)]
63pub struct SearchForIssuesUsingJqlPostParams {
64    /// A JSON object containing the search request.
65    pub search_request_bean: crate::models::SearchRequestBean
66}
67
68
69/// struct for typed successes of method [`get_issue_picker_resource`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetIssuePickerResourceSuccess {
73    Status200(crate::models::IssuePickerSuggestions),
74    UnknownValue(serde_json::Value),
75}
76
77/// struct for typed successes of method [`match_issues`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum MatchIssuesSuccess {
81    Status200(crate::models::IssueMatches),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed successes of method [`search_for_issues_using_jql`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum SearchForIssuesUsingJqlSuccess {
89    Status200(crate::models::SearchResults),
90    UnknownValue(serde_json::Value),
91}
92
93/// struct for typed successes of method [`search_for_issues_using_jql_post`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum SearchForIssuesUsingJqlPostSuccess {
97    Status200(crate::models::SearchResults),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`get_issue_picker_resource`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum GetIssuePickerResourceError {
105    Status401(),
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`match_issues`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum MatchIssuesError {
113    Status400(),
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`search_for_issues_using_jql`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum SearchForIssuesUsingJqlError {
121    Status400(),
122    Status401(),
123    UnknownValue(serde_json::Value),
124}
125
126/// struct for typed errors of method [`search_for_issues_using_jql_post`]
127#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum SearchForIssuesUsingJqlPostError {
130    Status400(),
131    Status401(),
132    UnknownValue(serde_json::Value),
133}
134
135
136/// Returns lists of issues matching a query string. Use this resource to provide auto-completion suggestions when the user is looking for an issue using a word or string.  This operation returns two lists:   *  `History Search` which includes issues from the user's history of created, edited, or viewed issues that contain the string in the `query` parameter.  *  `Current Search` which includes issues that match the JQL expression in `currentJQL` and contain the string in the `query` parameter.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
137pub async fn get_issue_picker_resource(configuration: &configuration::Configuration, params: GetIssuePickerResourceParams) -> Result<ResponseContent<GetIssuePickerResourceSuccess>, Error<GetIssuePickerResourceError>> {
138    let local_var_configuration = configuration;
139
140    // unbox the parameters
141    let query = params.query;
142    let current_jql = params.current_jql;
143    let current_issue_key = params.current_issue_key;
144    let current_project_id = params.current_project_id;
145    let show_sub_tasks = params.show_sub_tasks;
146    let show_sub_task_parent = params.show_sub_task_parent;
147
148
149    let local_var_client = &local_var_configuration.client;
150
151    let local_var_uri_str = format!("{}/rest/api/2/issue/picker", local_var_configuration.base_path);
152    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
153
154    if let Some(ref local_var_str) = query {
155        local_var_req_builder = local_var_req_builder.query(&[("query", &local_var_str.to_string())]);
156    }
157    if let Some(ref local_var_str) = current_jql {
158        local_var_req_builder = local_var_req_builder.query(&[("currentJQL", &local_var_str.to_string())]);
159    }
160    if let Some(ref local_var_str) = current_issue_key {
161        local_var_req_builder = local_var_req_builder.query(&[("currentIssueKey", &local_var_str.to_string())]);
162    }
163    if let Some(ref local_var_str) = current_project_id {
164        local_var_req_builder = local_var_req_builder.query(&[("currentProjectId", &local_var_str.to_string())]);
165    }
166    if let Some(ref local_var_str) = show_sub_tasks {
167        local_var_req_builder = local_var_req_builder.query(&[("showSubTasks", &local_var_str.to_string())]);
168    }
169    if let Some(ref local_var_str) = show_sub_task_parent {
170        local_var_req_builder = local_var_req_builder.query(&[("showSubTaskParent", &local_var_str.to_string())]);
171    }
172    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
173        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
174    }
175    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
176        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
177    };
178    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
179        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
180    };
181
182    let local_var_req = local_var_req_builder.build()?;
183    let local_var_resp = local_var_client.execute(local_var_req).await?;
184
185    let local_var_status = local_var_resp.status();
186    let local_var_content = local_var_resp.text().await?;
187
188    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
189        let local_var_entity: Option<GetIssuePickerResourceSuccess> = serde_json::from_str(&local_var_content).ok();
190        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
191        Ok(local_var_result)
192    } else {
193        let local_var_entity: Option<GetIssuePickerResourceError> = serde_json::from_str(&local_var_content).ok();
194        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
195        Err(Error::ResponseError(local_var_error))
196    }
197}
198
199/// Checks whether one or more issues would be returned by one or more JQL queries.  **[Permissions](#permissions) required:** None, however, issues are only matched against JQL queries where the user has:   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
200pub async fn match_issues(configuration: &configuration::Configuration, params: MatchIssuesParams) -> Result<ResponseContent<MatchIssuesSuccess>, Error<MatchIssuesError>> {
201    let local_var_configuration = configuration;
202
203    // unbox the parameters
204    let issues_and_jql_queries = params.issues_and_jql_queries;
205
206
207    let local_var_client = &local_var_configuration.client;
208
209    let local_var_uri_str = format!("{}/rest/api/2/jql/match", local_var_configuration.base_path);
210    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
211
212    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
213        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
214    }
215    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
216        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
217    };
218    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
219        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
220    };
221    local_var_req_builder = local_var_req_builder.json(&issues_and_jql_queries);
222
223    let local_var_req = local_var_req_builder.build()?;
224    let local_var_resp = local_var_client.execute(local_var_req).await?;
225
226    let local_var_status = local_var_resp.status();
227    let local_var_content = local_var_resp.text().await?;
228
229    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
230        let local_var_entity: Option<MatchIssuesSuccess> = serde_json::from_str(&local_var_content).ok();
231        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
232        Ok(local_var_result)
233    } else {
234        let local_var_entity: Option<MatchIssuesError> = serde_json::from_str(&local_var_content).ok();
235        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
236        Err(Error::ResponseError(local_var_error))
237    }
238}
239
240/// Searches for issues using [JQL](https://confluence.atlassian.com/x/egORLQ).  If the JQL query expression is too large to be encoded as a query parameter, use the [POST](#api-rest-api-2-search-post) version of this resource.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** Issues are included in the response where the user has:   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the issue.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
241pub async fn search_for_issues_using_jql(configuration: &configuration::Configuration, params: SearchForIssuesUsingJqlParams) -> Result<ResponseContent<SearchForIssuesUsingJqlSuccess>, Error<SearchForIssuesUsingJqlError>> {
242    let local_var_configuration = configuration;
243
244    // unbox the parameters
245    let jql = params.jql;
246    let start_at = params.start_at;
247    let max_results = params.max_results;
248    let validate_query = params.validate_query;
249    let fields = params.fields;
250    let expand = params.expand;
251    let properties = params.properties;
252    let fields_by_keys = params.fields_by_keys;
253
254
255    let local_var_client = &local_var_configuration.client;
256
257    let local_var_uri_str = format!("{}/rest/api/2/search", local_var_configuration.base_path);
258    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
259
260    if let Some(ref local_var_str) = jql {
261        local_var_req_builder = local_var_req_builder.query(&[("jql", &local_var_str.to_string())]);
262    }
263    if let Some(ref local_var_str) = start_at {
264        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
265    }
266    if let Some(ref local_var_str) = max_results {
267        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
268    }
269    if let Some(ref local_var_str) = validate_query {
270        local_var_req_builder = local_var_req_builder.query(&[("validateQuery", &local_var_str.to_string())]);
271    }
272    if let Some(ref local_var_str) = fields {
273        local_var_req_builder = match "multi" {
274            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("fields".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
275            _ => local_var_req_builder.query(&[("fields", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
276        };
277    }
278    if let Some(ref local_var_str) = expand {
279        local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
280    }
281    if let Some(ref local_var_str) = properties {
282        local_var_req_builder = match "multi" {
283            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("properties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
284            _ => local_var_req_builder.query(&[("properties", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
285        };
286    }
287    if let Some(ref local_var_str) = fields_by_keys {
288        local_var_req_builder = local_var_req_builder.query(&[("fieldsByKeys", &local_var_str.to_string())]);
289    }
290    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
291        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
292    }
293    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
294        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
295    };
296    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
297        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
298    };
299
300    let local_var_req = local_var_req_builder.build()?;
301    let local_var_resp = local_var_client.execute(local_var_req).await?;
302
303    let local_var_status = local_var_resp.status();
304    let local_var_content = local_var_resp.text().await?;
305
306    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
307        let local_var_entity: Option<SearchForIssuesUsingJqlSuccess> = serde_json::from_str(&local_var_content).ok();
308        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
309        Ok(local_var_result)
310    } else {
311        let local_var_entity: Option<SearchForIssuesUsingJqlError> = serde_json::from_str(&local_var_content).ok();
312        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
313        Err(Error::ResponseError(local_var_error))
314    }
315}
316
317/// Searches for issues using [JQL](https://confluence.atlassian.com/x/egORLQ).  There is a [GET](#api-rest-api-2-search-get) version of this resource that can be used for smaller JQL query expressions.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** Issues are included in the response where the user has:   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the issue.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
318pub async fn search_for_issues_using_jql_post(configuration: &configuration::Configuration, params: SearchForIssuesUsingJqlPostParams) -> Result<ResponseContent<SearchForIssuesUsingJqlPostSuccess>, Error<SearchForIssuesUsingJqlPostError>> {
319    let local_var_configuration = configuration;
320
321    // unbox the parameters
322    let search_request_bean = params.search_request_bean;
323
324
325    let local_var_client = &local_var_configuration.client;
326
327    let local_var_uri_str = format!("{}/rest/api/2/search", local_var_configuration.base_path);
328    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
329
330    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
331        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
332    }
333    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
334        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
335    };
336    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
337        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
338    };
339    local_var_req_builder = local_var_req_builder.json(&search_request_bean);
340
341    let local_var_req = local_var_req_builder.build()?;
342    let local_var_resp = local_var_client.execute(local_var_req).await?;
343
344    let local_var_status = local_var_resp.status();
345    let local_var_content = local_var_resp.text().await?;
346
347    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
348        let local_var_entity: Option<SearchForIssuesUsingJqlPostSuccess> = serde_json::from_str(&local_var_content).ok();
349        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
350        Ok(local_var_result)
351    } else {
352        let local_var_entity: Option<SearchForIssuesUsingJqlPostError> = serde_json::from_str(&local_var_content).ok();
353        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
354        Err(Error::ResponseError(local_var_error))
355    }
356}
357