jira_api_v2/apis/
issue_worklog_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 [`delete_worklog_property`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteWorklogPropertyError {
22    Status400(),
23    Status401(),
24    Status403(),
25    Status404(),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`get_worklog_property`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum GetWorklogPropertyError {
33    Status400(),
34    Status401(),
35    Status404(),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_worklog_property_keys`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetWorklogPropertyKeysError {
43    Status400(),
44    Status401(),
45    Status404(),
46    UnknownValue(serde_json::Value),
47}
48
49/// struct for typed errors of method [`set_worklog_property`]
50#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum SetWorklogPropertyError {
53    Status400(),
54    Status401(),
55    Status403(),
56    Status404(),
57    UnknownValue(serde_json::Value),
58}
59
60
61/// Deletes a worklog property.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *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.  *  If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to.
62pub async fn delete_worklog_property(configuration: &configuration::Configuration, issue_id_or_key: &str, worklog_id: &str, property_key: &str) -> Result<(), Error<DeleteWorklogPropertyError>> {
63    // add a prefix to parameters to efficiently prevent name collisions
64    let p_issue_id_or_key = issue_id_or_key;
65    let p_worklog_id = worklog_id;
66    let p_property_key = property_key;
67
68    let uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/worklog/{worklogId}/properties/{propertyKey}", configuration.base_path, issueIdOrKey=crate::apis::urlencode(p_issue_id_or_key), worklogId=crate::apis::urlencode(p_worklog_id), propertyKey=crate::apis::urlencode(p_property_key));
69    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
70
71    if let Some(ref user_agent) = configuration.user_agent {
72        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
73    }
74    if let Some(ref token) = configuration.oauth_access_token {
75        req_builder = req_builder.bearer_auth(token.to_owned());
76    };
77    if let Some(ref auth_conf) = configuration.basic_auth {
78        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
79    };
80
81    let req = req_builder.build()?;
82    let resp = configuration.client.execute(req).await?;
83
84    let status = resp.status();
85
86    if !status.is_client_error() && !status.is_server_error() {
87        Ok(())
88    } else {
89        let content = resp.text().await?;
90        let entity: Option<DeleteWorklogPropertyError> = serde_json::from_str(&content).ok();
91        Err(Error::ResponseError(ResponseContent { status, content, entity }))
92    }
93}
94
95/// Returns the value of a worklog property.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *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.  *  If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to.
96pub async fn get_worklog_property(configuration: &configuration::Configuration, issue_id_or_key: &str, worklog_id: &str, property_key: &str) -> Result<models::EntityProperty, Error<GetWorklogPropertyError>> {
97    // add a prefix to parameters to efficiently prevent name collisions
98    let p_issue_id_or_key = issue_id_or_key;
99    let p_worklog_id = worklog_id;
100    let p_property_key = property_key;
101
102    let uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/worklog/{worklogId}/properties/{propertyKey}", configuration.base_path, issueIdOrKey=crate::apis::urlencode(p_issue_id_or_key), worklogId=crate::apis::urlencode(p_worklog_id), propertyKey=crate::apis::urlencode(p_property_key));
103    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
104
105    if let Some(ref user_agent) = configuration.user_agent {
106        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
107    }
108    if let Some(ref token) = configuration.oauth_access_token {
109        req_builder = req_builder.bearer_auth(token.to_owned());
110    };
111    if let Some(ref auth_conf) = configuration.basic_auth {
112        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
113    };
114
115    let req = req_builder.build()?;
116    let resp = configuration.client.execute(req).await?;
117
118    let status = resp.status();
119
120    if !status.is_client_error() && !status.is_server_error() {
121        let content = resp.text().await?;
122        serde_json::from_str(&content).map_err(Error::from)
123    } else {
124        let content = resp.text().await?;
125        let entity: Option<GetWorklogPropertyError> = serde_json::from_str(&content).ok();
126        Err(Error::ResponseError(ResponseContent { status, content, entity }))
127    }
128}
129
130/// Returns the keys of all properties for a worklog.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**   *  *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.  *  If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to.
131pub async fn get_worklog_property_keys(configuration: &configuration::Configuration, issue_id_or_key: &str, worklog_id: &str) -> Result<models::PropertyKeys, Error<GetWorklogPropertyKeysError>> {
132    // add a prefix to parameters to efficiently prevent name collisions
133    let p_issue_id_or_key = issue_id_or_key;
134    let p_worklog_id = worklog_id;
135
136    let uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/worklog/{worklogId}/properties", configuration.base_path, issueIdOrKey=crate::apis::urlencode(p_issue_id_or_key), worklogId=crate::apis::urlencode(p_worklog_id));
137    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
138
139    if let Some(ref user_agent) = configuration.user_agent {
140        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
141    }
142    if let Some(ref token) = configuration.oauth_access_token {
143        req_builder = req_builder.bearer_auth(token.to_owned());
144    };
145    if let Some(ref auth_conf) = configuration.basic_auth {
146        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
147    };
148
149    let req = req_builder.build()?;
150    let resp = configuration.client.execute(req).await?;
151
152    let status = resp.status();
153
154    if !status.is_client_error() && !status.is_server_error() {
155        let content = resp.text().await?;
156        serde_json::from_str(&content).map_err(Error::from)
157    } else {
158        let content = resp.text().await?;
159        let entity: Option<GetWorklogPropertyKeysError> = serde_json::from_str(&content).ok();
160        Err(Error::ResponseError(ResponseContent { status, content, entity }))
161    }
162}
163
164/// Sets the value of a worklog property. Use this operation to store custom data against the worklog.  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* [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.  *  *Edit all worklogs*[ project permission](https://confluence.atlassian.com/x/yodKLg) to update any worklog or *Edit own worklogs* to update worklogs created by the user.  *  If the worklog has visibility restrictions, belongs to the group or has the role visibility is restricted to.
165pub async fn set_worklog_property(configuration: &configuration::Configuration, issue_id_or_key: &str, worklog_id: &str, property_key: &str, body: Option<serde_json::Value>) -> Result<serde_json::Value, Error<SetWorklogPropertyError>> {
166    // add a prefix to parameters to efficiently prevent name collisions
167    let p_issue_id_or_key = issue_id_or_key;
168    let p_worklog_id = worklog_id;
169    let p_property_key = property_key;
170    let p_body = body;
171
172    let uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/worklog/{worklogId}/properties/{propertyKey}", configuration.base_path, issueIdOrKey=crate::apis::urlencode(p_issue_id_or_key), worklogId=crate::apis::urlencode(p_worklog_id), propertyKey=crate::apis::urlencode(p_property_key));
173    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
174
175    if let Some(ref user_agent) = configuration.user_agent {
176        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
177    }
178    if let Some(ref token) = configuration.oauth_access_token {
179        req_builder = req_builder.bearer_auth(token.to_owned());
180    };
181    if let Some(ref auth_conf) = configuration.basic_auth {
182        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
183    };
184    req_builder = req_builder.json(&p_body);
185
186    let req = req_builder.build()?;
187    let resp = configuration.client.execute(req).await?;
188
189    let status = resp.status();
190
191    if !status.is_client_error() && !status.is_server_error() {
192        let content = resp.text().await?;
193        serde_json::from_str(&content).map_err(Error::from)
194    } else {
195        let content = resp.text().await?;
196        let entity: Option<SetWorklogPropertyError> = serde_json::from_str(&content).ok();
197        Err(Error::ResponseError(ResponseContent { status, content, entity }))
198    }
199}
200