hi_jira2/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 errors of method [`get_issue_picker_resource`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetIssuePickerResourceError {
73    Status401(),
74    UnknownValue(serde_json::Value),
75}
76
77/// struct for typed errors of method [`match_issues`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum MatchIssuesError {
81    Status400(),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed errors of method [`search_for_issues_using_jql`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum SearchForIssuesUsingJqlError {
89    Status400(),
90    Status401(),
91    UnknownValue(serde_json::Value),
92}
93
94/// struct for typed errors of method [`search_for_issues_using_jql_post`]
95#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum SearchForIssuesUsingJqlPostError {
98    Status400(),
99    Status401(),
100    UnknownValue(serde_json::Value),
101}
102
103
104/// 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.
105pub async fn get_issue_picker_resource(configuration: &configuration::Configuration, params: GetIssuePickerResourceParams) -> Result<crate::models::IssuePickerSuggestions, Error<GetIssuePickerResourceError>> {
106    let local_var_configuration = configuration;
107
108    // unbox the parameters
109    let query = params.query;
110    let current_jql = params.current_jql;
111    let current_issue_key = params.current_issue_key;
112    let current_project_id = params.current_project_id;
113    let show_sub_tasks = params.show_sub_tasks;
114    let show_sub_task_parent = params.show_sub_task_parent;
115
116
117    let local_var_client = &local_var_configuration.client;
118
119    let local_var_uri_str = format!("{}/rest/api/2/issue/picker", local_var_configuration.base_path);
120    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
121
122    if let Some(ref local_var_str) = query {
123        local_var_req_builder = local_var_req_builder.query(&[("query", &local_var_str.to_string())]);
124    }
125    if let Some(ref local_var_str) = current_jql {
126        local_var_req_builder = local_var_req_builder.query(&[("currentJQL", &local_var_str.to_string())]);
127    }
128    if let Some(ref local_var_str) = current_issue_key {
129        local_var_req_builder = local_var_req_builder.query(&[("currentIssueKey", &local_var_str.to_string())]);
130    }
131    if let Some(ref local_var_str) = current_project_id {
132        local_var_req_builder = local_var_req_builder.query(&[("currentProjectId", &local_var_str.to_string())]);
133    }
134    if let Some(ref local_var_str) = show_sub_tasks {
135        local_var_req_builder = local_var_req_builder.query(&[("showSubTasks", &local_var_str.to_string())]);
136    }
137    if let Some(ref local_var_str) = show_sub_task_parent {
138        local_var_req_builder = local_var_req_builder.query(&[("showSubTaskParent", &local_var_str.to_string())]);
139    }
140    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
141        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
142    }
143    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
144        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
145    };
146    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
147        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
148    };
149
150    let local_var_req = local_var_req_builder.build()?;
151    let local_var_resp = local_var_client.execute(local_var_req).await?;
152
153    let local_var_status = local_var_resp.status();
154    let local_var_content = local_var_resp.text().await?;
155
156    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
157        serde_json::from_str(&local_var_content).map_err(Error::from)
158    } else {
159        let local_var_entity: Option<GetIssuePickerResourceError> = serde_json::from_str(&local_var_content).ok();
160        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
161        Err(Error::ResponseError(local_var_error))
162    }
163}
164
165/// 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.
166pub async fn match_issues(configuration: &configuration::Configuration, params: MatchIssuesParams) -> Result<crate::models::IssueMatches, Error<MatchIssuesError>> {
167    let local_var_configuration = configuration;
168
169    // unbox the parameters
170    let issues_and_jql_queries = params.issues_and_jql_queries;
171
172
173    let local_var_client = &local_var_configuration.client;
174
175    let local_var_uri_str = format!("{}/rest/api/2/jql/match", local_var_configuration.base_path);
176    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
177
178    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
179        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
180    }
181    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
182        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
183    };
184    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
185        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
186    };
187    local_var_req_builder = local_var_req_builder.json(&issues_and_jql_queries);
188
189    let local_var_req = local_var_req_builder.build()?;
190    let local_var_resp = local_var_client.execute(local_var_req).await?;
191
192    let local_var_status = local_var_resp.status();
193    let local_var_content = local_var_resp.text().await?;
194
195    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
196        serde_json::from_str(&local_var_content).map_err(Error::from)
197    } else {
198        let local_var_entity: Option<MatchIssuesError> = serde_json::from_str(&local_var_content).ok();
199        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
200        Err(Error::ResponseError(local_var_error))
201    }
202}
203
204/// 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.
205pub async fn search_for_issues_using_jql(configuration: &configuration::Configuration, params: SearchForIssuesUsingJqlParams) -> Result<crate::models::SearchResults, Error<SearchForIssuesUsingJqlError>> {
206    let local_var_configuration = configuration;
207
208    // unbox the parameters
209    let jql = params.jql;
210    let start_at = params.start_at;
211    let max_results = params.max_results;
212    let validate_query = params.validate_query;
213    let fields = params.fields;
214    let expand = params.expand;
215    let properties = params.properties;
216    let fields_by_keys = params.fields_by_keys;
217
218
219    let local_var_client = &local_var_configuration.client;
220
221    let local_var_uri_str = format!("{}/rest/api/2/search", local_var_configuration.base_path);
222    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
223
224    if let Some(ref local_var_str) = jql {
225        local_var_req_builder = local_var_req_builder.query(&[("jql", &local_var_str.to_string())]);
226    }
227    if let Some(ref local_var_str) = start_at {
228        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
229    }
230    if let Some(ref local_var_str) = max_results {
231        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
232    }
233    if let Some(ref local_var_str) = validate_query {
234        local_var_req_builder = local_var_req_builder.query(&[("validateQuery", &local_var_str.to_string())]);
235    }
236    if let Some(ref local_var_str) = fields {
237        local_var_req_builder = match "multi" {
238            "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)>>()),
239            _ => local_var_req_builder.query(&[("fields", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
240        };
241    }
242    if let Some(ref local_var_str) = expand {
243        local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
244    }
245    if let Some(ref local_var_str) = properties {
246        local_var_req_builder = match "multi" {
247            "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)>>()),
248            _ => local_var_req_builder.query(&[("properties", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
249        };
250    }
251    if let Some(ref local_var_str) = fields_by_keys {
252        local_var_req_builder = local_var_req_builder.query(&[("fieldsByKeys", &local_var_str.to_string())]);
253    }
254    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
255        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
256    }
257    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
258        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
259    };
260    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
261        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
262    };
263
264    let local_var_req = local_var_req_builder.build()?;
265    let local_var_resp = local_var_client.execute(local_var_req).await?;
266
267    let local_var_status = local_var_resp.status();
268    let local_var_content = local_var_resp.text().await?;
269
270    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
271        serde_json::from_str(&local_var_content).map_err(Error::from)
272    } else {
273        let local_var_entity: Option<SearchForIssuesUsingJqlError> = serde_json::from_str(&local_var_content).ok();
274        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
275        Err(Error::ResponseError(local_var_error))
276    }
277}
278
279/// 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.
280pub async fn search_for_issues_using_jql_post(configuration: &configuration::Configuration, params: SearchForIssuesUsingJqlPostParams) -> Result<crate::models::SearchResults, Error<SearchForIssuesUsingJqlPostError>> {
281    let local_var_configuration = configuration;
282
283    // unbox the parameters
284    let search_request_bean = params.search_request_bean;
285
286
287    let local_var_client = &local_var_configuration.client;
288
289    let local_var_uri_str = format!("{}/rest/api/2/search", local_var_configuration.base_path);
290    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
291
292    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
293        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
294    }
295    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
296        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
297    };
298    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
299        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
300    };
301    local_var_req_builder = local_var_req_builder.json(&search_request_bean);
302
303    let local_var_req = local_var_req_builder.build()?;
304    let local_var_resp = local_var_client.execute(local_var_req).await?;
305
306    let local_var_status = local_var_resp.status();
307    let local_var_content = local_var_resp.text().await?;
308
309    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
310        serde_json::from_str(&local_var_content).map_err(Error::from)
311    } else {
312        let local_var_entity: Option<SearchForIssuesUsingJqlPostError> = serde_json::from_str(&local_var_content).ok();
313        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
314        Err(Error::ResponseError(local_var_error))
315    }
316}
317