jira_api_v2/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;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`delete_project_property`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteProjectPropertyError {
22    Status400(),
23    Status401(),
24    Status403(),
25    Status404(),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`get_project_property`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum GetProjectPropertyError {
33    Status400(),
34    Status401(),
35    Status403(),
36    Status404(),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`get_project_property_keys`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetProjectPropertyKeysError {
44    Status400(),
45    Status401(),
46    Status403(),
47    Status404(),
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`set_project_property`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum SetProjectPropertyError {
55    Status400(),
56    Status401(),
57    Status403(),
58    Status404(),
59    UnknownValue(serde_json::Value),
60}
61
62
63/// 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.
64pub async fn delete_project_property(configuration: &configuration::Configuration, project_id_or_key: &str, property_key: &str) -> Result<(), Error<DeleteProjectPropertyError>> {
65    // add a prefix to parameters to efficiently prevent name collisions
66    let p_project_id_or_key = project_id_or_key;
67    let p_property_key = property_key;
68
69    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/properties/{propertyKey}", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key), propertyKey=crate::apis::urlencode(p_property_key));
70    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
71
72    if let Some(ref user_agent) = configuration.user_agent {
73        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
74    }
75    if let Some(ref token) = configuration.oauth_access_token {
76        req_builder = req_builder.bearer_auth(token.to_owned());
77    };
78    if let Some(ref auth_conf) = configuration.basic_auth {
79        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
80    };
81
82    let req = req_builder.build()?;
83    let resp = configuration.client.execute(req).await?;
84
85    let status = resp.status();
86
87    if !status.is_client_error() && !status.is_server_error() {
88        Ok(())
89    } else {
90        let content = resp.text().await?;
91        let entity: Option<DeleteProjectPropertyError> = serde_json::from_str(&content).ok();
92        Err(Error::ResponseError(ResponseContent { status, content, entity }))
93    }
94}
95
96/// 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.
97pub async fn get_project_property(configuration: &configuration::Configuration, project_id_or_key: &str, property_key: &str) -> Result<models::EntityProperty, Error<GetProjectPropertyError>> {
98    // add a prefix to parameters to efficiently prevent name collisions
99    let p_project_id_or_key = project_id_or_key;
100    let p_property_key = property_key;
101
102    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/properties/{propertyKey}", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key), 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<GetProjectPropertyError> = serde_json::from_str(&content).ok();
126        Err(Error::ResponseError(ResponseContent { status, content, entity }))
127    }
128}
129
130/// 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.
131pub async fn get_project_property_keys(configuration: &configuration::Configuration, project_id_or_key: &str) -> Result<models::PropertyKeys, Error<GetProjectPropertyKeysError>> {
132    // add a prefix to parameters to efficiently prevent name collisions
133    let p_project_id_or_key = project_id_or_key;
134
135    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/properties", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key));
136    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
137
138    if let Some(ref user_agent) = configuration.user_agent {
139        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
140    }
141    if let Some(ref token) = configuration.oauth_access_token {
142        req_builder = req_builder.bearer_auth(token.to_owned());
143    };
144    if let Some(ref auth_conf) = configuration.basic_auth {
145        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
146    };
147
148    let req = req_builder.build()?;
149    let resp = configuration.client.execute(req).await?;
150
151    let status = resp.status();
152
153    if !status.is_client_error() && !status.is_server_error() {
154        let content = resp.text().await?;
155        serde_json::from_str(&content).map_err(Error::from)
156    } else {
157        let content = resp.text().await?;
158        let entity: Option<GetProjectPropertyKeysError> = serde_json::from_str(&content).ok();
159        Err(Error::ResponseError(ResponseContent { status, content, entity }))
160    }
161}
162
163/// 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.
164pub async fn set_project_property(configuration: &configuration::Configuration, project_id_or_key: &str, property_key: &str, body: Option<serde_json::Value>) -> Result<serde_json::Value, Error<SetProjectPropertyError>> {
165    // add a prefix to parameters to efficiently prevent name collisions
166    let p_project_id_or_key = project_id_or_key;
167    let p_property_key = property_key;
168    let p_body = body;
169
170    let uri_str = format!("{}/rest/api/2/project/{projectIdOrKey}/properties/{propertyKey}", configuration.base_path, projectIdOrKey=crate::apis::urlencode(p_project_id_or_key), propertyKey=crate::apis::urlencode(p_property_key));
171    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
172
173    if let Some(ref user_agent) = configuration.user_agent {
174        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
175    }
176    if let Some(ref token) = configuration.oauth_access_token {
177        req_builder = req_builder.bearer_auth(token.to_owned());
178    };
179    if let Some(ref auth_conf) = configuration.basic_auth {
180        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
181    };
182    req_builder = req_builder.json(&p_body);
183
184    let req = req_builder.build()?;
185    let resp = configuration.client.execute(req).await?;
186
187    let status = resp.status();
188
189    if !status.is_client_error() && !status.is_server_error() {
190        let content = resp.text().await?;
191        serde_json::from_str(&content).map_err(Error::from)
192    } else {
193        let content = resp.text().await?;
194        let entity: Option<SetProjectPropertyError> = serde_json::from_str(&content).ok();
195        Err(Error::ResponseError(ResponseContent { status, content, entity }))
196    }
197}
198