jira_api_v2/apis/
issue_properties_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;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`bulk_delete_issue_property`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BulkDeleteIssuePropertyError {
22    Status400(models::ErrorCollection),
23    Status401(models::ErrorCollection),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`bulk_set_issue_property`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum BulkSetIssuePropertyError {
31    Status400(models::ErrorCollection),
32    Status401(models::ErrorCollection),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`bulk_set_issues_properties`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum BulkSetIssuesPropertiesError {
40    Status400(models::ErrorCollection),
41    Status401(models::ErrorCollection),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`delete_issue_property`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum DeleteIssuePropertyError {
49    Status401(),
50    Status404(),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`get_issue_property`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum GetIssuePropertyError {
58    Status401(),
59    Status404(),
60    UnknownValue(serde_json::Value),
61}
62
63/// struct for typed errors of method [`get_issue_property_keys`]
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum GetIssuePropertyKeysError {
67    Status404(),
68    UnknownValue(serde_json::Value),
69}
70
71/// struct for typed errors of method [`set_issue_property`]
72#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum SetIssuePropertyError {
75    Status400(),
76    Status401(),
77    Status403(),
78    Status404(),
79    UnknownValue(serde_json::Value),
80}
81
82
83/// Deletes a property value from multiple issues. The issues to be updated can be specified by filter criteria.  The criteria the filter used to identify eligible issues are:   *  `entityIds` Only issues from this list are eligible.  *  `currentValue` Only issues with the property set to this value are eligible.  If both criteria is specified, they are joined with the logical *AND*: only issues that satisfy both criteria are considered eligible.  If no filter criteria are specified, all the issues visible to the user and where the user has the EDIT\\_ISSUES permission for the issue are considered eligible.  This operation is:   *  transactional, either the property is deleted from all eligible issues or, when errors occur, no properties are deleted.  *  [asynchronous](#async). Follow the `location` link in the response to determine the status of the task and use [Get task](#api-rest-api-2-task-taskId-get) to obtain subsequent updates.  **[Permissions](#permissions) required:**   *  *Browse projects* [ project permission](https://confluence.atlassian.com/x/yodKLg) for each project containing issues.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.  *  *Edit issues* [project permission](https://confluence.atlassian.com/x/yodKLg) for each issue.
84pub async fn bulk_delete_issue_property(configuration: &configuration::Configuration, property_key: &str, issue_filter_for_bulk_property_delete: models::IssueFilterForBulkPropertyDelete) -> Result<(), Error<BulkDeleteIssuePropertyError>> {
85    // add a prefix to parameters to efficiently prevent name collisions
86    let p_property_key = property_key;
87    let p_issue_filter_for_bulk_property_delete = issue_filter_for_bulk_property_delete;
88
89    let uri_str = format!("{}/rest/api/2/issue/properties/{propertyKey}", configuration.base_path, propertyKey=crate::apis::urlencode(p_property_key));
90    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
91
92    if let Some(ref user_agent) = configuration.user_agent {
93        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
94    }
95    if let Some(ref token) = configuration.oauth_access_token {
96        req_builder = req_builder.bearer_auth(token.to_owned());
97    };
98    if let Some(ref auth_conf) = configuration.basic_auth {
99        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
100    };
101    req_builder = req_builder.json(&p_issue_filter_for_bulk_property_delete);
102
103    let req = req_builder.build()?;
104    let resp = configuration.client.execute(req).await?;
105
106    let status = resp.status();
107
108    if !status.is_client_error() && !status.is_server_error() {
109        Ok(())
110    } else {
111        let content = resp.text().await?;
112        let entity: Option<BulkDeleteIssuePropertyError> = serde_json::from_str(&content).ok();
113        Err(Error::ResponseError(ResponseContent { status, content, entity }))
114    }
115}
116
117/// Sets a property value on multiple issues.  The value set can be a constant or determined by a [Jira expression](https://developer.atlassian.com/cloud/jira/platform/jira-expressions/). Expressions must be computable with constant complexity when applied to a set of issues. Expressions must also comply with the [restrictions](https://developer.atlassian.com/cloud/jira/platform/jira-expressions/#restrictions) that apply to all Jira expressions.  The issues to be updated can be specified by a filter.  The filter identifies issues eligible for update using these criteria:   *  `entityIds` Only issues from this list are eligible.  *  `currentValue` Only issues with the property set to this value are eligible.  *  `hasProperty`:           *  If *true*, only issues with the property are eligible.      *  If *false*, only issues without the property are eligible.  If more than one criteria is specified, they are joined with the logical *AND*: only issues that satisfy all criteria are eligible.  If an invalid combination of criteria is provided, an error is returned. For example, specifying a `currentValue` and `hasProperty` as *false* would not match any issues (because without the property the property cannot have a value).  The filter is optional. Without the filter all the issues visible to the user and where the user has the EDIT\\_ISSUES permission for the issue are considered eligible.  This operation is:   *  transactional, either all eligible issues are updated or, when errors occur, none are updated.  *  [asynchronous](#async). Follow the `location` link in the response to determine the status of the task and use [Get task](#api-rest-api-2-task-taskId-get) to obtain subsequent updates.  **[Permissions](#permissions) required:**   *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for each project containing issues.  *  If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.  *  *Edit issues* [project permission](https://confluence.atlassian.com/x/yodKLg) for each issue.
118pub async fn bulk_set_issue_property(configuration: &configuration::Configuration, property_key: &str, bulk_issue_property_update_request: models::BulkIssuePropertyUpdateRequest) -> Result<(), Error<BulkSetIssuePropertyError>> {
119    // add a prefix to parameters to efficiently prevent name collisions
120    let p_property_key = property_key;
121    let p_bulk_issue_property_update_request = bulk_issue_property_update_request;
122
123    let uri_str = format!("{}/rest/api/2/issue/properties/{propertyKey}", configuration.base_path, propertyKey=crate::apis::urlencode(p_property_key));
124    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
125
126    if let Some(ref user_agent) = configuration.user_agent {
127        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
128    }
129    if let Some(ref token) = configuration.oauth_access_token {
130        req_builder = req_builder.bearer_auth(token.to_owned());
131    };
132    if let Some(ref auth_conf) = configuration.basic_auth {
133        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
134    };
135    req_builder = req_builder.json(&p_bulk_issue_property_update_request);
136
137    let req = req_builder.build()?;
138    let resp = configuration.client.execute(req).await?;
139
140    let status = resp.status();
141
142    if !status.is_client_error() && !status.is_server_error() {
143        Ok(())
144    } else {
145        let content = resp.text().await?;
146        let entity: Option<BulkSetIssuePropertyError> = serde_json::from_str(&content).ok();
147        Err(Error::ResponseError(ResponseContent { status, content, entity }))
148    }
149}
150
151/// Sets the values of entity properties on issues. It can set up to 10 entity properties on up to 10,000 issues.  The value of the request body must be a [valid](http://tools.ietf.org/html/rfc4627), non-empty JSON. The maximum length of single issue property value is 32768 characters. This operation can be accessed anonymously.  This operation is:   *  transactional, either all properties are updated in all eligible issues or, when errors occur, no properties are updated.  *  [asynchronous](#async). Follow the `location` link in the response to determine the status of the task and use [Get task](#api-rest-api-2-task-taskId-get) to obtain subsequent updates.  **[Permissions](#permissions) required:**   *  *Browse projects* and *Edit issues* [project permissions](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.
152pub async fn bulk_set_issues_properties(configuration: &configuration::Configuration, issue_entity_properties: models::IssueEntityProperties) -> Result<(), Error<BulkSetIssuesPropertiesError>> {
153    // add a prefix to parameters to efficiently prevent name collisions
154    let p_issue_entity_properties = issue_entity_properties;
155
156    let uri_str = format!("{}/rest/api/2/issue/properties", configuration.base_path);
157    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
158
159    if let Some(ref user_agent) = configuration.user_agent {
160        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
161    }
162    if let Some(ref token) = configuration.oauth_access_token {
163        req_builder = req_builder.bearer_auth(token.to_owned());
164    };
165    if let Some(ref auth_conf) = configuration.basic_auth {
166        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
167    };
168    req_builder = req_builder.json(&p_issue_entity_properties);
169
170    let req = req_builder.build()?;
171    let resp = configuration.client.execute(req).await?;
172
173    let status = resp.status();
174
175    if !status.is_client_error() && !status.is_server_error() {
176        Ok(())
177    } else {
178        let content = resp.text().await?;
179        let entity: Option<BulkSetIssuesPropertiesError> = serde_json::from_str(&content).ok();
180        Err(Error::ResponseError(ResponseContent { status, content, entity }))
181    }
182}
183
184/// Deletes an issue's property.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* and *Edit issues* [project permissions](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.
185pub async fn delete_issue_property(configuration: &configuration::Configuration, issue_id_or_key: &str, property_key: &str) -> Result<(), Error<DeleteIssuePropertyError>> {
186    // add a prefix to parameters to efficiently prevent name collisions
187    let p_issue_id_or_key = issue_id_or_key;
188    let p_property_key = property_key;
189
190    let uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/properties/{propertyKey}", configuration.base_path, issueIdOrKey=crate::apis::urlencode(p_issue_id_or_key), propertyKey=crate::apis::urlencode(p_property_key));
191    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
192
193    if let Some(ref user_agent) = configuration.user_agent {
194        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
195    }
196    if let Some(ref token) = configuration.oauth_access_token {
197        req_builder = req_builder.bearer_auth(token.to_owned());
198    };
199    if let Some(ref auth_conf) = configuration.basic_auth {
200        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
201    };
202
203    let req = req_builder.build()?;
204    let resp = configuration.client.execute(req).await?;
205
206    let status = resp.status();
207
208    if !status.is_client_error() && !status.is_server_error() {
209        Ok(())
210    } else {
211        let content = resp.text().await?;
212        let entity: Option<DeleteIssuePropertyError> = serde_json::from_str(&content).ok();
213        Err(Error::ResponseError(ResponseContent { status, content, entity }))
214    }
215}
216
217/// Returns the key and value of an issue's property.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *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.
218pub async fn get_issue_property(configuration: &configuration::Configuration, issue_id_or_key: &str, property_key: &str) -> Result<models::EntityProperty, Error<GetIssuePropertyError>> {
219    // add a prefix to parameters to efficiently prevent name collisions
220    let p_issue_id_or_key = issue_id_or_key;
221    let p_property_key = property_key;
222
223    let uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/properties/{propertyKey}", configuration.base_path, issueIdOrKey=crate::apis::urlencode(p_issue_id_or_key), propertyKey=crate::apis::urlencode(p_property_key));
224    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
225
226    if let Some(ref user_agent) = configuration.user_agent {
227        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
228    }
229    if let Some(ref token) = configuration.oauth_access_token {
230        req_builder = req_builder.bearer_auth(token.to_owned());
231    };
232    if let Some(ref auth_conf) = configuration.basic_auth {
233        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
234    };
235
236    let req = req_builder.build()?;
237    let resp = configuration.client.execute(req).await?;
238
239    let status = resp.status();
240
241    if !status.is_client_error() && !status.is_server_error() {
242        let content = resp.text().await?;
243        serde_json::from_str(&content).map_err(Error::from)
244    } else {
245        let content = resp.text().await?;
246        let entity: Option<GetIssuePropertyError> = serde_json::from_str(&content).ok();
247        Err(Error::ResponseError(ResponseContent { status, content, entity }))
248    }
249}
250
251/// Returns the URLs and keys of an issue's properties.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** Property details are only returned 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.
252pub async fn get_issue_property_keys(configuration: &configuration::Configuration, issue_id_or_key: &str) -> Result<models::PropertyKeys, Error<GetIssuePropertyKeysError>> {
253    // add a prefix to parameters to efficiently prevent name collisions
254    let p_issue_id_or_key = issue_id_or_key;
255
256    let uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/properties", configuration.base_path, issueIdOrKey=crate::apis::urlencode(p_issue_id_or_key));
257    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
258
259    if let Some(ref user_agent) = configuration.user_agent {
260        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
261    }
262    if let Some(ref token) = configuration.oauth_access_token {
263        req_builder = req_builder.bearer_auth(token.to_owned());
264    };
265    if let Some(ref auth_conf) = configuration.basic_auth {
266        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
267    };
268
269    let req = req_builder.build()?;
270    let resp = configuration.client.execute(req).await?;
271
272    let status = resp.status();
273
274    if !status.is_client_error() && !status.is_server_error() {
275        let content = resp.text().await?;
276        serde_json::from_str(&content).map_err(Error::from)
277    } else {
278        let content = resp.text().await?;
279        let entity: Option<GetIssuePropertyKeysError> = serde_json::from_str(&content).ok();
280        Err(Error::ResponseError(ResponseContent { status, content, entity }))
281    }
282}
283
284/// Sets the value of an issue's property. Use this resource to store custom data against an issue.  The value of the request body must be a [valid](http://tools.ietf.org/html/rfc4627), non-empty JSON blob. The maximum length is 32768 characters.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *Browse projects* and *Edit issues* [project permissions](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.
285pub async fn set_issue_property(configuration: &configuration::Configuration, issue_id_or_key: &str, property_key: &str, body: Option<serde_json::Value>) -> Result<serde_json::Value, Error<SetIssuePropertyError>> {
286    // add a prefix to parameters to efficiently prevent name collisions
287    let p_issue_id_or_key = issue_id_or_key;
288    let p_property_key = property_key;
289    let p_body = body;
290
291    let uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/properties/{propertyKey}", configuration.base_path, issueIdOrKey=crate::apis::urlencode(p_issue_id_or_key), propertyKey=crate::apis::urlencode(p_property_key));
292    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
293
294    if let Some(ref user_agent) = configuration.user_agent {
295        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
296    }
297    if let Some(ref token) = configuration.oauth_access_token {
298        req_builder = req_builder.bearer_auth(token.to_owned());
299    };
300    if let Some(ref auth_conf) = configuration.basic_auth {
301        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
302    };
303    req_builder = req_builder.json(&p_body);
304
305    let req = req_builder.build()?;
306    let resp = configuration.client.execute(req).await?;
307
308    let status = resp.status();
309
310    if !status.is_client_error() && !status.is_server_error() {
311        let content = resp.text().await?;
312        serde_json::from_str(&content).map_err(Error::from)
313    } else {
314        let content = resp.text().await?;
315        let entity: Option<SetIssuePropertyError> = serde_json::from_str(&content).ok();
316        Err(Error::ResponseError(ResponseContent { status, content, entity }))
317    }
318}
319