hi_jira2/apis/
jql_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_auto_complete_post`]
18#[derive(Clone, Debug, Default)]
19pub struct GetAutoCompletePostParams {
20    pub search_auto_complete_filter: crate::models::SearchAutoCompleteFilter
21}
22
23/// struct for passing parameters to the method [`get_field_auto_complete_for_query_string`]
24#[derive(Clone, Debug, Default)]
25pub struct GetFieldAutoCompleteForQueryStringParams {
26    /// The name of the field.
27    pub field_name: Option<String>,
28    /// The partial field item name entered by the user.
29    pub field_value: Option<String>,
30    /// The name of the [ CHANGED operator predicate](https://confluence.atlassian.com/x/hQORLQ#Advancedsearching-operatorsreference-CHANGEDCHANGED) for which the suggestions are generated. The valid predicate operators are *by*, *from*, and *to*.
31    pub predicate_name: Option<String>,
32    /// The partial predicate item name entered by the user.
33    pub predicate_value: Option<String>
34}
35
36/// struct for passing parameters to the method [`migrate_queries`]
37#[derive(Clone, Debug, Default)]
38pub struct MigrateQueriesParams {
39    pub jql_personal_data_migration_request: crate::models::JqlPersonalDataMigrationRequest
40}
41
42/// struct for passing parameters to the method [`parse_jql_queries`]
43#[derive(Clone, Debug, Default)]
44pub struct ParseJqlQueriesParams {
45    pub jql_queries_to_parse: crate::models::JqlQueriesToParse,
46    /// How to validate the JQL query and treat the validation results. Validation options include:   *  `strict` Returns all errors. If validation fails, the query structure is not returned.  *  `warn` Returns all errors. If validation fails but the JQL query is correctly formed, the query structure is returned.  *  `none` No validation is performed. If JQL query is correctly formed, the query structure is returned.
47    pub validation: Option<String>
48}
49
50/// struct for passing parameters to the method [`sanitise_jql_queries`]
51#[derive(Clone, Debug, Default)]
52pub struct SanitiseJqlQueriesParams {
53    pub jql_queries_to_sanitize: crate::models::JqlQueriesToSanitize
54}
55
56
57/// struct for typed errors of method [`get_auto_complete`]
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum GetAutoCompleteError {
61    Status401(),
62    UnknownValue(serde_json::Value),
63}
64
65/// struct for typed errors of method [`get_auto_complete_post`]
66#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum GetAutoCompletePostError {
69    Status400(),
70    Status401(),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`get_field_auto_complete_for_query_string`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetFieldAutoCompleteForQueryStringError {
78    Status400(),
79    Status401(),
80    UnknownValue(serde_json::Value),
81}
82
83/// struct for typed errors of method [`migrate_queries`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum MigrateQueriesError {
87    Status400(),
88    Status401(),
89    UnknownValue(serde_json::Value),
90}
91
92/// struct for typed errors of method [`parse_jql_queries`]
93#[derive(Debug, Clone, Serialize, Deserialize)]
94#[serde(untagged)]
95pub enum ParseJqlQueriesError {
96    Status400(crate::models::ErrorCollection),
97    Status401(),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`sanitise_jql_queries`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum SanitiseJqlQueriesError {
105    Status400(crate::models::ErrorCollection),
106    Status401(crate::models::ErrorCollection),
107    Status403(crate::models::ErrorCollection),
108    UnknownValue(serde_json::Value),
109}
110
111
112/// Returns reference data for JQL searches. This is a downloadable version of the documentation provided in [Advanced searching - fields reference](https://confluence.atlassian.com/x/gwORLQ) and [Advanced searching - functions reference](https://confluence.atlassian.com/x/hgORLQ), along with a list of JQL-reserved words. Use this information to assist with the programmatic creation of JQL queries or the validation of queries built in a custom query builder.  To filter visible field details by project or collapse non-unique fields by field type then [Get field reference data (POST)](#api-rest-api-2-jql-autocompletedata-post) can be used.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
113pub async fn get_auto_complete(configuration: &configuration::Configuration) -> Result<crate::models::JqlReferenceData, Error<GetAutoCompleteError>> {
114    let local_var_configuration = configuration;
115
116    // unbox the parameters
117
118
119    let local_var_client = &local_var_configuration.client;
120
121    let local_var_uri_str = format!("{}/rest/api/2/jql/autocompletedata", local_var_configuration.base_path);
122    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
123
124    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
125        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
126    }
127    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
128        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
129    };
130    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
131        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
132    };
133
134    let local_var_req = local_var_req_builder.build()?;
135    let local_var_resp = local_var_client.execute(local_var_req).await?;
136
137    let local_var_status = local_var_resp.status();
138    let local_var_content = local_var_resp.text().await?;
139
140    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
141        serde_json::from_str(&local_var_content).map_err(Error::from)
142    } else {
143        let local_var_entity: Option<GetAutoCompleteError> = serde_json::from_str(&local_var_content).ok();
144        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
145        Err(Error::ResponseError(local_var_error))
146    }
147}
148
149/// Returns reference data for JQL searches. This is a downloadable version of the documentation provided in [Advanced searching - fields reference](https://confluence.atlassian.com/x/gwORLQ) and [Advanced searching - functions reference](https://confluence.atlassian.com/x/hgORLQ), along with a list of JQL-reserved words. Use this information to assist with the programmatic creation of JQL queries or the validation of queries built in a custom query builder.  This operation can filter the custom fields returned by project. Invalid project IDs in `projectIds` are ignored. System fields are always returned.  It can also return the collapsed field for custom fields. Collapsed fields enable searches to be performed across all fields with the same name and of the same field type. For example, the collapsed field `Component - Component[Dropdown]` enables dropdown fields `Component - cf[10061]` and `Component - cf[10062]` to be searched simultaneously.  **[Permissions](#permissions) required:** None.
150pub async fn get_auto_complete_post(configuration: &configuration::Configuration, params: GetAutoCompletePostParams) -> Result<crate::models::JqlReferenceData, Error<GetAutoCompletePostError>> {
151    let local_var_configuration = configuration;
152
153    // unbox the parameters
154    let search_auto_complete_filter = params.search_auto_complete_filter;
155
156
157    let local_var_client = &local_var_configuration.client;
158
159    let local_var_uri_str = format!("{}/rest/api/2/jql/autocompletedata", local_var_configuration.base_path);
160    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
161
162    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
163        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
164    }
165    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
166        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
167    };
168    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
169        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
170    };
171    local_var_req_builder = local_var_req_builder.json(&search_auto_complete_filter);
172
173    let local_var_req = local_var_req_builder.build()?;
174    let local_var_resp = local_var_client.execute(local_var_req).await?;
175
176    let local_var_status = local_var_resp.status();
177    let local_var_content = local_var_resp.text().await?;
178
179    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
180        serde_json::from_str(&local_var_content).map_err(Error::from)
181    } else {
182        let local_var_entity: Option<GetAutoCompletePostError> = serde_json::from_str(&local_var_content).ok();
183        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
184        Err(Error::ResponseError(local_var_error))
185    }
186}
187
188/// Returns the JQL search auto complete suggestions for a field.  Suggestions can be obtained by providing:   *  `fieldName` to get a list of all values for the field.  *  `fieldName` and `fieldValue` to get a list of values containing the text in `fieldValue`.  *  `fieldName` and `predicateName` to get a list of all predicate values for the field.  *  `fieldName`, `predicateName`, and `predicateValue` to get a list of predicate values containing the text in `predicateValue`.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
189pub async fn get_field_auto_complete_for_query_string(configuration: &configuration::Configuration, params: GetFieldAutoCompleteForQueryStringParams) -> Result<crate::models::AutoCompleteSuggestions, Error<GetFieldAutoCompleteForQueryStringError>> {
190    let local_var_configuration = configuration;
191
192    // unbox the parameters
193    let field_name = params.field_name;
194    let field_value = params.field_value;
195    let predicate_name = params.predicate_name;
196    let predicate_value = params.predicate_value;
197
198
199    let local_var_client = &local_var_configuration.client;
200
201    let local_var_uri_str = format!("{}/rest/api/2/jql/autocompletedata/suggestions", local_var_configuration.base_path);
202    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
203
204    if let Some(ref local_var_str) = field_name {
205        local_var_req_builder = local_var_req_builder.query(&[("fieldName", &local_var_str.to_string())]);
206    }
207    if let Some(ref local_var_str) = field_value {
208        local_var_req_builder = local_var_req_builder.query(&[("fieldValue", &local_var_str.to_string())]);
209    }
210    if let Some(ref local_var_str) = predicate_name {
211        local_var_req_builder = local_var_req_builder.query(&[("predicateName", &local_var_str.to_string())]);
212    }
213    if let Some(ref local_var_str) = predicate_value {
214        local_var_req_builder = local_var_req_builder.query(&[("predicateValue", &local_var_str.to_string())]);
215    }
216    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
217        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
218    }
219    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
220        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
221    };
222    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
223        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
224    };
225
226    let local_var_req = local_var_req_builder.build()?;
227    let local_var_resp = local_var_client.execute(local_var_req).await?;
228
229    let local_var_status = local_var_resp.status();
230    let local_var_content = local_var_resp.text().await?;
231
232    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
233        serde_json::from_str(&local_var_content).map_err(Error::from)
234    } else {
235        let local_var_entity: Option<GetFieldAutoCompleteForQueryStringError> = serde_json::from_str(&local_var_content).ok();
236        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
237        Err(Error::ResponseError(local_var_error))
238    }
239}
240
241/// Converts one or more JQL queries with user identifiers (username or user key) to equivalent JQL queries with account IDs.  You may wish to use this operation if your system stores JQL queries and you want to make them GDPR-compliant. For more information about GDPR-related changes, see the [migration guide](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/).  **[Permissions](#permissions) required:** Permission to access Jira.
242pub async fn migrate_queries(configuration: &configuration::Configuration, params: MigrateQueriesParams) -> Result<crate::models::ConvertedJqlQueries, Error<MigrateQueriesError>> {
243    let local_var_configuration = configuration;
244
245    // unbox the parameters
246    let jql_personal_data_migration_request = params.jql_personal_data_migration_request;
247
248
249    let local_var_client = &local_var_configuration.client;
250
251    let local_var_uri_str = format!("{}/rest/api/2/jql/pdcleaner", local_var_configuration.base_path);
252    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
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    local_var_req_builder = local_var_req_builder.json(&jql_personal_data_migration_request);
264
265    let local_var_req = local_var_req_builder.build()?;
266    let local_var_resp = local_var_client.execute(local_var_req).await?;
267
268    let local_var_status = local_var_resp.status();
269    let local_var_content = local_var_resp.text().await?;
270
271    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
272        serde_json::from_str(&local_var_content).map_err(Error::from)
273    } else {
274        let local_var_entity: Option<MigrateQueriesError> = serde_json::from_str(&local_var_content).ok();
275        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
276        Err(Error::ResponseError(local_var_error))
277    }
278}
279
280/// Parses and validates JQL queries.  Validation is performed in context of the current user.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
281pub async fn parse_jql_queries(configuration: &configuration::Configuration, params: ParseJqlQueriesParams) -> Result<crate::models::ParsedJqlQueries, Error<ParseJqlQueriesError>> {
282    let local_var_configuration = configuration;
283
284    // unbox the parameters
285    let jql_queries_to_parse = params.jql_queries_to_parse;
286    let validation = params.validation;
287
288
289    let local_var_client = &local_var_configuration.client;
290
291    let local_var_uri_str = format!("{}/rest/api/2/jql/parse", local_var_configuration.base_path);
292    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
293
294    if let Some(ref local_var_str) = validation {
295        local_var_req_builder = local_var_req_builder.query(&[("validation", &local_var_str.to_string())]);
296    }
297    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
298        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
299    }
300    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
301        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
302    };
303    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
304        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
305    };
306    local_var_req_builder = local_var_req_builder.json(&jql_queries_to_parse);
307
308    let local_var_req = local_var_req_builder.build()?;
309    let local_var_resp = local_var_client.execute(local_var_req).await?;
310
311    let local_var_status = local_var_resp.status();
312    let local_var_content = local_var_resp.text().await?;
313
314    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
315        serde_json::from_str(&local_var_content).map_err(Error::from)
316    } else {
317        let local_var_entity: Option<ParseJqlQueriesError> = serde_json::from_str(&local_var_content).ok();
318        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
319        Err(Error::ResponseError(local_var_error))
320    }
321}
322
323/// Sanitizes one or more JQL queries by converting readable details into IDs where a user doesn't have permission to view the entity.  For example, if the query contains the clause *project = 'Secret project'*, and a user does not have browse permission for the project \"Secret project\", the sanitized query replaces the clause with *project = 12345\"* (where 12345 is the ID of the project). If a user has the required permission, the clause is not sanitized. If the account ID is null, sanitizing is performed for an anonymous user.  Note that sanitization doesn't make the queries GDPR-compliant, because it doesn't remove user identifiers (username or user key). If you need to make queries GDPR-compliant, use [Convert user identifiers to account IDs in JQL queries](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-jql/#api-rest-api-3-jql-sanitize-post).  Before sanitization each JQL query is parsed. The queries are returned in the same order that they were passed.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
324pub async fn sanitise_jql_queries(configuration: &configuration::Configuration, params: SanitiseJqlQueriesParams) -> Result<crate::models::SanitizedJqlQueries, Error<SanitiseJqlQueriesError>> {
325    let local_var_configuration = configuration;
326
327    // unbox the parameters
328    let jql_queries_to_sanitize = params.jql_queries_to_sanitize;
329
330
331    let local_var_client = &local_var_configuration.client;
332
333    let local_var_uri_str = format!("{}/rest/api/2/jql/sanitize", local_var_configuration.base_path);
334    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
335
336    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
337        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
338    }
339    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
340        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
341    };
342    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
343        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
344    };
345    local_var_req_builder = local_var_req_builder.json(&jql_queries_to_sanitize);
346
347    let local_var_req = local_var_req_builder.build()?;
348    let local_var_resp = local_var_client.execute(local_var_req).await?;
349
350    let local_var_status = local_var_resp.status();
351    let local_var_content = local_var_resp.text().await?;
352
353    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
354        serde_json::from_str(&local_var_content).map_err(Error::from)
355    } else {
356        let local_var_entity: Option<SanitiseJqlQueriesError> = serde_json::from_str(&local_var_content).ok();
357        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
358        Err(Error::ResponseError(local_var_error))
359    }
360}
361