jira2/apis/
project_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;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`delete_project_property`]
18#[derive(Clone, Debug, Default)]
19pub struct DeleteProjectPropertyParams {
20    /// The project ID or project key (case sensitive).
21    pub project_id_or_key: String,
22    /// The project property key. Use [Get project property keys](#api-rest-api-2-project-projectIdOrKey-properties-get) to get a list of all project property keys.
23    pub property_key: String
24}
25
26/// struct for passing parameters to the method [`get_project_property`]
27#[derive(Clone, Debug, Default)]
28pub struct GetProjectPropertyParams {
29    /// The project ID or project key (case sensitive).
30    pub project_id_or_key: String,
31    /// The project property key. Use [Get project property keys](#api-rest-api-2-project-projectIdOrKey-properties-get) to get a list of all project property keys.
32    pub property_key: String
33}
34
35/// struct for passing parameters to the method [`get_project_property_keys`]
36#[derive(Clone, Debug, Default)]
37pub struct GetProjectPropertyKeysParams {
38    /// The project ID or project key (case sensitive).
39    pub project_id_or_key: String
40}
41
42/// struct for passing parameters to the method [`set_project_property`]
43#[derive(Clone, Debug, Default)]
44pub struct SetProjectPropertyParams {
45    /// The project ID or project key (case sensitive).
46    pub project_id_or_key: String,
47    /// The key of the project property. The maximum length is 255 characters.
48    pub property_key: String,
49    pub body: Option<serde_json::Value>
50}
51
52
53/// struct for typed errors of method [`delete_project_property`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum DeleteProjectPropertyError {
57    Status400(),
58    Status401(),
59    Status403(),
60    Status404(),
61    UnknownValue(serde_json::Value),
62}
63
64/// struct for typed errors of method [`get_project_property`]
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum GetProjectPropertyError {
68    Status400(),
69    Status401(),
70    Status403(),
71    Status404(),
72    UnknownValue(serde_json::Value),
73}
74
75/// struct for typed errors of method [`get_project_property_keys`]
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum GetProjectPropertyKeysError {
79    Status400(),
80    Status401(),
81    Status403(),
82    Status404(),
83    UnknownValue(serde_json::Value),
84}
85
86/// struct for typed errors of method [`set_project_property`]
87#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum SetProjectPropertyError {
90    Status400(),
91    Status401(),
92    Status403(),
93    Status404(),
94    UnknownValue(serde_json::Value),
95}
96
97
98/// Deletes the [property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties) from a project.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the property.
99pub async fn delete_project_property(configuration: &configuration::Configuration, params: DeleteProjectPropertyParams) -> Result<(), Error<DeleteProjectPropertyError>> {
100    let local_var_configuration = configuration;
101
102    // unbox the parameters
103    let project_id_or_key = params.project_id_or_key;
104    let property_key = params.property_key;
105
106
107    let local_var_client = &local_var_configuration.client;
108
109    let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/properties/{propertyKey}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key), propertyKey=crate::apis::urlencode(property_key));
110    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
111
112    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
113        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
114    }
115    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
116        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
117    };
118    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
119        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
120    };
121
122    let local_var_req = local_var_req_builder.build()?;
123    let local_var_resp = local_var_client.execute(local_var_req).await?;
124
125    let local_var_status = local_var_resp.status();
126    let local_var_content = local_var_resp.text().await?;
127
128    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
129        Ok(())
130    } else {
131        let local_var_entity: Option<DeleteProjectPropertyError> = serde_json::from_str(&local_var_content).ok();
132        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
133        Err(Error::ResponseError(local_var_error))
134    }
135}
136
137/// Returns the value of a [project property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the property.
138pub async fn get_project_property(configuration: &configuration::Configuration, params: GetProjectPropertyParams) -> Result<crate::models::EntityProperty, Error<GetProjectPropertyError>> {
139    let local_var_configuration = configuration;
140
141    // unbox the parameters
142    let project_id_or_key = params.project_id_or_key;
143    let property_key = params.property_key;
144
145
146    let local_var_client = &local_var_configuration.client;
147
148    let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/properties/{propertyKey}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key), propertyKey=crate::apis::urlencode(property_key));
149    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
150
151    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
152        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
153    }
154    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
155        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
156    };
157    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
158        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
159    };
160
161    let local_var_req = local_var_req_builder.build()?;
162    let local_var_resp = local_var_client.execute(local_var_req).await?;
163
164    let local_var_status = local_var_resp.status();
165    let local_var_content = local_var_resp.text().await?;
166
167    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
168        serde_json::from_str(&local_var_content).map_err(Error::from)
169    } else {
170        let local_var_entity: Option<GetProjectPropertyError> = serde_json::from_str(&local_var_content).ok();
171        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
172        Err(Error::ResponseError(local_var_error))
173    }
174}
175
176/// Returns all [project property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties) keys for the project.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** *Browse Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project.
177pub async fn get_project_property_keys(configuration: &configuration::Configuration, params: GetProjectPropertyKeysParams) -> Result<crate::models::PropertyKeys, Error<GetProjectPropertyKeysError>> {
178    let local_var_configuration = configuration;
179
180    // unbox the parameters
181    let project_id_or_key = params.project_id_or_key;
182
183
184    let local_var_client = &local_var_configuration.client;
185
186    let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/properties", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key));
187    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
188
189    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
190        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
191    }
192    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
193        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
194    };
195    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
196        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
197    };
198
199    let local_var_req = local_var_req_builder.build()?;
200    let local_var_resp = local_var_client.execute(local_var_req).await?;
201
202    let local_var_status = local_var_resp.status();
203    let local_var_content = local_var_resp.text().await?;
204
205    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
206        serde_json::from_str(&local_var_content).map_err(Error::from)
207    } else {
208        let local_var_entity: Option<GetProjectPropertyKeysError> = serde_json::from_str(&local_var_content).ok();
209        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
210        Err(Error::ResponseError(local_var_error))
211    }
212}
213
214/// Sets the value of the [project property](https://developer.atlassian.com/cloud/jira/platform/storing-data-without-a-database/#a-id-jira-entity-properties-a-jira-entity-properties). You can use project properties to store custom data against the project.  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:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg) or *Administer Projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project in which the property is created.
215pub async fn set_project_property(configuration: &configuration::Configuration, params: SetProjectPropertyParams) -> Result<serde_json::Value, Error<SetProjectPropertyError>> {
216    let local_var_configuration = configuration;
217
218    // unbox the parameters
219    let project_id_or_key = params.project_id_or_key;
220    let property_key = params.property_key;
221    let body = params.body;
222
223
224    let local_var_client = &local_var_configuration.client;
225
226    let local_var_uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/properties/{propertyKey}", local_var_configuration.base_path, projectIdOrKey=crate::apis::urlencode(project_id_or_key), propertyKey=crate::apis::urlencode(property_key));
227    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
228
229    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
230        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
231    }
232    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
233        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
234    };
235    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
236        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
237    };
238    local_var_req_builder = local_var_req_builder.json(&body);
239
240    let local_var_req = local_var_req_builder.build()?;
241    let local_var_resp = local_var_client.execute(local_var_req).await?;
242
243    let local_var_status = local_var_resp.status();
244    let local_var_content = local_var_resp.text().await?;
245
246    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
247        serde_json::from_str(&local_var_content).map_err(Error::from)
248    } else {
249        let local_var_entity: Option<SetProjectPropertyError> = serde_json::from_str(&local_var_content).ok();
250        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
251        Err(Error::ResponseError(local_var_error))
252    }
253}
254