jirav2/apis/
issue_attachments_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 [`add_attachment`]
18#[derive(Clone, Debug, Default)]
19pub struct AddAttachmentParams {
20    /// The ID or key of the issue that attachments are added to.
21    pub issue_id_or_key: String
22}
23
24/// struct for passing parameters to the method [`expand_attachment_for_humans`]
25#[derive(Clone, Debug, Default)]
26pub struct ExpandAttachmentForHumansParams {
27    /// The ID of the attachment.
28    pub id: String
29}
30
31/// struct for passing parameters to the method [`expand_attachment_for_machines`]
32#[derive(Clone, Debug, Default)]
33pub struct ExpandAttachmentForMachinesParams {
34    /// The ID of the attachment.
35    pub id: String
36}
37
38/// struct for passing parameters to the method [`get_attachment`]
39#[derive(Clone, Debug, Default)]
40pub struct GetAttachmentParams {
41    /// The ID of the attachment.
42    pub id: String
43}
44
45/// struct for passing parameters to the method [`get_attachment_content`]
46#[derive(Clone, Debug, Default)]
47pub struct GetAttachmentContentParams {
48    /// The ID of the attachment.
49    pub id: String,
50    /// Whether a redirect is provided for the attachment download. Clients that do not automatically follow redirects can set this to `false` to avoid making multiple requests to download the attachment.
51    pub redirect: Option<bool>
52}
53
54/// struct for passing parameters to the method [`get_attachment_thumbnail`]
55#[derive(Clone, Debug, Default)]
56pub struct GetAttachmentThumbnailParams {
57    /// The ID of the attachment.
58    pub id: String,
59    /// Whether a redirect is provided for the attachment download. Clients that do not automatically follow redirects can set this to `false` to avoid making multiple requests to download the attachment.
60    pub redirect: Option<bool>,
61    /// Whether a default thumbnail is returned when the requested thumbnail is not found.
62    pub fallback_to_default: Option<bool>,
63    /// The maximum width to scale the thumbnail to.
64    pub width: Option<i32>,
65    /// The maximum height to scale the thumbnail to.
66    pub height: Option<i32>
67}
68
69/// struct for passing parameters to the method [`remove_attachment`]
70#[derive(Clone, Debug, Default)]
71pub struct RemoveAttachmentParams {
72    /// The ID of the attachment.
73    pub id: String
74}
75
76
77/// struct for typed successes of method [`add_attachment`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum AddAttachmentSuccess {
81    Status200(Vec<crate::models::Attachment>),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed successes of method [`expand_attachment_for_humans`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum ExpandAttachmentForHumansSuccess {
89    Status200(crate::models::AttachmentArchiveMetadataReadable),
90    UnknownValue(serde_json::Value),
91}
92
93/// struct for typed successes of method [`expand_attachment_for_machines`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum ExpandAttachmentForMachinesSuccess {
97    Status200(crate::models::AttachmentArchiveImpl),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed successes of method [`get_attachment`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum GetAttachmentSuccess {
105    Status200(crate::models::AttachmentMetadata),
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed successes of method [`get_attachment_content`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum GetAttachmentContentSuccess {
113    Status200(serde_json::Value),
114    Status206(),
115    Status303(),
116    UnknownValue(serde_json::Value),
117}
118
119/// struct for typed successes of method [`get_attachment_meta`]
120#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum GetAttachmentMetaSuccess {
123    Status200(crate::models::AttachmentSettings),
124    UnknownValue(serde_json::Value),
125}
126
127/// struct for typed successes of method [`get_attachment_thumbnail`]
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum GetAttachmentThumbnailSuccess {
131    Status200(serde_json::Value),
132    Status303(),
133    UnknownValue(serde_json::Value),
134}
135
136/// struct for typed successes of method [`remove_attachment`]
137#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum RemoveAttachmentSuccess {
140    Status204(),
141    UnknownValue(serde_json::Value),
142}
143
144/// struct for typed errors of method [`add_attachment`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum AddAttachmentError {
148    Status403(),
149    Status404(),
150    Status413(),
151    UnknownValue(serde_json::Value),
152}
153
154/// struct for typed errors of method [`expand_attachment_for_humans`]
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum ExpandAttachmentForHumansError {
158    Status401(),
159    Status403(),
160    Status404(),
161    Status409(),
162    UnknownValue(serde_json::Value),
163}
164
165/// struct for typed errors of method [`expand_attachment_for_machines`]
166#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum ExpandAttachmentForMachinesError {
169    Status401(),
170    Status403(),
171    Status404(),
172    Status409(),
173    UnknownValue(serde_json::Value),
174}
175
176/// struct for typed errors of method [`get_attachment`]
177#[derive(Debug, Clone, Serialize, Deserialize)]
178#[serde(untagged)]
179pub enum GetAttachmentError {
180    Status401(),
181    Status403(),
182    Status404(),
183    UnknownValue(serde_json::Value),
184}
185
186/// struct for typed errors of method [`get_attachment_content`]
187#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum GetAttachmentContentError {
190    Status400(),
191    Status401(),
192    Status403(),
193    Status404(),
194    Status416(),
195    UnknownValue(serde_json::Value),
196}
197
198/// struct for typed errors of method [`get_attachment_meta`]
199#[derive(Debug, Clone, Serialize, Deserialize)]
200#[serde(untagged)]
201pub enum GetAttachmentMetaError {
202    Status401(),
203    UnknownValue(serde_json::Value),
204}
205
206/// struct for typed errors of method [`get_attachment_thumbnail`]
207#[derive(Debug, Clone, Serialize, Deserialize)]
208#[serde(untagged)]
209pub enum GetAttachmentThumbnailError {
210    Status400(),
211    Status401(),
212    Status403(),
213    Status404(),
214    UnknownValue(serde_json::Value),
215}
216
217/// struct for typed errors of method [`remove_attachment`]
218#[derive(Debug, Clone, Serialize, Deserialize)]
219#[serde(untagged)]
220pub enum RemoveAttachmentError {
221    Status403(),
222    Status404(),
223    UnknownValue(serde_json::Value),
224}
225
226
227/// Adds one or more attachments to an issue. Attachments are posted as multipart/form-data ([RFC 1867](https://www.ietf.org/rfc/rfc1867.txt)).  Note that:   *  The request must have a `X-Atlassian-Token: no-check` header, if not it is blocked. See [Special headers](#special-request-headers) for more information.  *  The name of the multipart/form-data parameter that contains the attachments must be `file`.  The following examples upload a file called *myfile.txt* to the issue *TEST-123*:  #### curl ####      curl --location --request POST 'https://your-domain.atlassian.net/rest/api/2/issue/TEST-123/attachments'      -u 'email@example.com:<api_token>'      -H 'X-Atlassian-Token: no-check'      --form 'file=@\"myfile.txt\"'  #### Node.js ####      // This code sample uses the 'node-fetch' and 'form-data' libraries:      // https://www.npmjs.com/package/node-fetch      // https://www.npmjs.com/package/form-data      const fetch = require('node-fetch');      const FormData = require('form-data');      const fs = require('fs');           const filePath = 'myfile.txt';      const form = new FormData();      const stats = fs.statSync(filePath);      const fileSizeInBytes = stats.size;      const fileStream = fs.createReadStream(filePath);           form.append('file', fileStream, {knownLength: fileSizeInBytes});           fetch('https://your-domain.atlassian.net/rest/api/2/issue/TEST-123/attachments', {          method: 'POST',          body: form,          headers: {              'Authorization': `Basic ${Buffer.from(                  'email@example.com:'              ).toString('base64')}`,              'Accept': 'application/json',              'X-Atlassian-Token': 'no-check'          }      })          .then(response => {              console.log(                  `Response: ${response.status} ${response.statusText}`              );              return response.text();          })          .then(text => console.log(text))          .catch(err => console.error(err));  #### Java ####      // This code sample uses the  'Unirest' library:      // http://unirest.io/java.html      HttpResponse response = Unirest.post(\"https://your-domain.atlassian.net/rest/api/2/issue/{issueIdOrKey}/attachments\")              .basicAuth(\"email@example.com\", \"\")              .header(\"Accept\", \"application/json\")              .header(\"X-Atlassian-Token\", \"no-check\")              .field(\"file\", new File(\"myfile.txt\"))              .asJson();                   System.out.println(response.getBody());  #### Python ####      # This code sample uses the 'requests' library:      # http://docs.python-requests.org      import requests      from requests.auth import HTTPBasicAuth      import json           url = \"https://your-domain.atlassian.net/rest/api/2/issue/{issueIdOrKey}/attachments\"           auth = HTTPBasicAuth(\"email@example.com\", \"\")           headers = {         \"Accept\": \"application/json\",         \"X-Atlassian-Token\": \"no-check\"      }           response = requests.request(         \"POST\",         url,         headers = headers,         auth = auth,         files = {              \"file\": (\"myfile.txt\", open(\"myfile.txt\",\"rb\"), \"application-type\")         }      )           print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(\",\", \": \")))  #### PHP ####      // This code sample uses the 'Unirest' library:      // http://unirest.io/php.html      Unirest\\Request::auth('email@example.com', '');           $headers = array(        'Accept' => 'application/json',        'X-Atlassian-Token' => 'no-check'      );           $parameters = array(        'file' => File::add('myfile.txt')      );           $response = Unirest\\Request::post(        'https://your-domain.atlassian.net/rest/api/2/issue/{issueIdOrKey}/attachments',        $headers,        $parameters      );           var_dump($response)  #### Forge ####      // This sample uses Atlassian Forge and the `form-data` library.      // https://developer.atlassian.com/platform/forge/      // https://www.npmjs.com/package/form-data      import api from \"@forge/api\";      import FormData from \"form-data\";           const form = new FormData();      form.append('file', fileStream, {knownLength: fileSizeInBytes});           const response = await api.asApp().requestJira('/rest/api/2/issue/{issueIdOrKey}/attachments', {          method: 'POST',          body: form,          headers: {              'Accept': 'application/json',              'X-Atlassian-Token': 'no-check'          }      });           console.log(`Response: ${response.status} ${response.statusText}`);      console.log(await response.json());  Tip: Use a client library. Many client libraries have classes for handling multipart POST operations. For example, in Java, the Apache HTTP Components library provides a [MultiPartEntity](http://hc.apache.org/httpcomponents-client-ga/httpmime/apidocs/org/apache/http/entity/mime/MultipartEntity.html) class for multipart POST operations.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:**    *  *Browse Projects* and *Create attachments* [ 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.
228pub async fn add_attachment(configuration: &configuration::Configuration, params: AddAttachmentParams) -> Result<ResponseContent<AddAttachmentSuccess>, Error<AddAttachmentError>> {
229    let local_var_configuration = configuration;
230
231    // unbox the parameters
232    let issue_id_or_key = params.issue_id_or_key;
233
234
235    let local_var_client = &local_var_configuration.client;
236
237    let local_var_uri_str = format!("{}/rest/api/2/issue/{issueIdOrKey}/attachments", local_var_configuration.base_path, issueIdOrKey=crate::apis::urlencode(issue_id_or_key));
238    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
239
240    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
241        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
242    }
243    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
244        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
245    };
246    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
247        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
248    };
249
250    let local_var_req = local_var_req_builder.build()?;
251    let local_var_resp = local_var_client.execute(local_var_req).await?;
252
253    let local_var_status = local_var_resp.status();
254    let local_var_content = local_var_resp.text().await?;
255
256    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
257        let local_var_entity: Option<AddAttachmentSuccess> = serde_json::from_str(&local_var_content).ok();
258        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
259        Ok(local_var_result)
260    } else {
261        let local_var_entity: Option<AddAttachmentError> = serde_json::from_str(&local_var_content).ok();
262        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
263        Err(Error::ResponseError(local_var_error))
264    }
265}
266
267/// Returns the metadata for the contents of an attachment, if it is an archive, and metadata for the attachment itself. For example, if the attachment is a ZIP archive, then information about the files in the archive is returned and metadata for the ZIP archive. Currently, only the ZIP archive format is supported.  Use this operation to retrieve data that is presented to the user, as this operation returns the metadata for the attachment itself, such as the attachment's ID and name. Otherwise, use [ Get contents metadata for an expanded attachment](#api-rest-api-2-attachment-id-expand-raw-get), which only returns the metadata for the attachment's contents.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** For the issue containing the attachment:   *  *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.
268pub async fn expand_attachment_for_humans(configuration: &configuration::Configuration, params: ExpandAttachmentForHumansParams) -> Result<ResponseContent<ExpandAttachmentForHumansSuccess>, Error<ExpandAttachmentForHumansError>> {
269    let local_var_configuration = configuration;
270
271    // unbox the parameters
272    let id = params.id;
273
274
275    let local_var_client = &local_var_configuration.client;
276
277    let local_var_uri_str = format!("{}/rest/api/2/attachment/{id}/expand/human", local_var_configuration.base_path, id=crate::apis::urlencode(id));
278    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
279
280    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
281        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
282    }
283    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
284        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
285    };
286    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
287        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
288    };
289
290    let local_var_req = local_var_req_builder.build()?;
291    let local_var_resp = local_var_client.execute(local_var_req).await?;
292
293    let local_var_status = local_var_resp.status();
294    let local_var_content = local_var_resp.text().await?;
295
296    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
297        let local_var_entity: Option<ExpandAttachmentForHumansSuccess> = serde_json::from_str(&local_var_content).ok();
298        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
299        Ok(local_var_result)
300    } else {
301        let local_var_entity: Option<ExpandAttachmentForHumansError> = serde_json::from_str(&local_var_content).ok();
302        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
303        Err(Error::ResponseError(local_var_error))
304    }
305}
306
307/// Returns the metadata for the contents of an attachment, if it is an archive. For example, if the attachment is a ZIP archive, then information about the files in the archive is returned. Currently, only the ZIP archive format is supported.  Use this operation if you are processing the data without presenting it to the user, as this operation only returns the metadata for the contents of the attachment. Otherwise, to retrieve data to present to the user, use [ Get all metadata for an expanded attachment](#api-rest-api-2-attachment-id-expand-human-get) which also returns the metadata for the attachment itself, such as the attachment's ID and name.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** For the issue containing the attachment:   *  *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.
308pub async fn expand_attachment_for_machines(configuration: &configuration::Configuration, params: ExpandAttachmentForMachinesParams) -> Result<ResponseContent<ExpandAttachmentForMachinesSuccess>, Error<ExpandAttachmentForMachinesError>> {
309    let local_var_configuration = configuration;
310
311    // unbox the parameters
312    let id = params.id;
313
314
315    let local_var_client = &local_var_configuration.client;
316
317    let local_var_uri_str = format!("{}/rest/api/2/attachment/{id}/expand/raw", local_var_configuration.base_path, id=crate::apis::urlencode(id));
318    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
319
320    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
321        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
322    }
323    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
324        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
325    };
326    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
327        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
328    };
329
330    let local_var_req = local_var_req_builder.build()?;
331    let local_var_resp = local_var_client.execute(local_var_req).await?;
332
333    let local_var_status = local_var_resp.status();
334    let local_var_content = local_var_resp.text().await?;
335
336    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
337        let local_var_entity: Option<ExpandAttachmentForMachinesSuccess> = serde_json::from_str(&local_var_content).ok();
338        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
339        Ok(local_var_result)
340    } else {
341        let local_var_entity: Option<ExpandAttachmentForMachinesError> = serde_json::from_str(&local_var_content).ok();
342        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
343        Err(Error::ResponseError(local_var_error))
344    }
345}
346
347/// Returns the metadata for an attachment. Note that the attachment itself is not returned.  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.
348pub async fn get_attachment(configuration: &configuration::Configuration, params: GetAttachmentParams) -> Result<ResponseContent<GetAttachmentSuccess>, Error<GetAttachmentError>> {
349    let local_var_configuration = configuration;
350
351    // unbox the parameters
352    let id = params.id;
353
354
355    let local_var_client = &local_var_configuration.client;
356
357    let local_var_uri_str = format!("{}/rest/api/2/attachment/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
358    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
359
360    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
361        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
362    }
363    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
364        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
365    };
366    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
367        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
368    };
369
370    let local_var_req = local_var_req_builder.build()?;
371    let local_var_resp = local_var_client.execute(local_var_req).await?;
372
373    let local_var_status = local_var_resp.status();
374    let local_var_content = local_var_resp.text().await?;
375
376    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
377        let local_var_entity: Option<GetAttachmentSuccess> = serde_json::from_str(&local_var_content).ok();
378        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
379        Ok(local_var_result)
380    } else {
381        let local_var_entity: Option<GetAttachmentError> = serde_json::from_str(&local_var_content).ok();
382        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
383        Err(Error::ResponseError(local_var_error))
384    }
385}
386
387/// Returns the contents of an attachment. A `Range` header can be set to define a range of bytes within the attachment to download. See the [HTTP Range header standard](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range) for details.  To return a thumbnail of the attachment, use [Download attachment thumbnail](#api-rest-api-2-attachment-thumbnail-id-get).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** For the issue containing the attachment:   *  *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.
388pub async fn get_attachment_content(configuration: &configuration::Configuration, params: GetAttachmentContentParams) -> Result<ResponseContent<GetAttachmentContentSuccess>, Error<GetAttachmentContentError>> {
389    let local_var_configuration = configuration;
390
391    // unbox the parameters
392    let id = params.id;
393    let redirect = params.redirect;
394
395
396    let local_var_client = &local_var_configuration.client;
397
398    let local_var_uri_str = format!("{}/rest/api/2/attachment/content/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
399    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
400
401    if let Some(ref local_var_str) = redirect {
402        local_var_req_builder = local_var_req_builder.query(&[("redirect", &local_var_str.to_string())]);
403    }
404    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
405        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
406    }
407    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
408        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
409    };
410    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
411        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
412    };
413
414    let local_var_req = local_var_req_builder.build()?;
415    let local_var_resp = local_var_client.execute(local_var_req).await?;
416
417    let local_var_status = local_var_resp.status();
418    let local_var_content = local_var_resp.text().await?;
419
420    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
421        let local_var_entity: Option<GetAttachmentContentSuccess> = serde_json::from_str(&local_var_content).ok();
422        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
423        Ok(local_var_result)
424    } else {
425        let local_var_entity: Option<GetAttachmentContentError> = serde_json::from_str(&local_var_content).ok();
426        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
427        Err(Error::ResponseError(local_var_error))
428    }
429}
430
431/// Returns the attachment settings, that is, whether attachments are enabled and the maximum attachment size allowed.  Note that there are also [project permissions](https://confluence.atlassian.com/x/yodKLg) that restrict whether users can create and delete attachments.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
432pub async fn get_attachment_meta(configuration: &configuration::Configuration) -> Result<ResponseContent<GetAttachmentMetaSuccess>, Error<GetAttachmentMetaError>> {
433    let local_var_configuration = configuration;
434
435    // unbox the parameters
436
437
438    let local_var_client = &local_var_configuration.client;
439
440    let local_var_uri_str = format!("{}/rest/api/2/attachment/meta", local_var_configuration.base_path);
441    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
442
443    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
444        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
445    }
446    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
447        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
448    };
449    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
450        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
451    };
452
453    let local_var_req = local_var_req_builder.build()?;
454    let local_var_resp = local_var_client.execute(local_var_req).await?;
455
456    let local_var_status = local_var_resp.status();
457    let local_var_content = local_var_resp.text().await?;
458
459    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
460        let local_var_entity: Option<GetAttachmentMetaSuccess> = serde_json::from_str(&local_var_content).ok();
461        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
462        Ok(local_var_result)
463    } else {
464        let local_var_entity: Option<GetAttachmentMetaError> = serde_json::from_str(&local_var_content).ok();
465        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
466        Err(Error::ResponseError(local_var_error))
467    }
468}
469
470/// Returns the thumbnail of an attachment.  To return the attachment contents, use [Download attachment content](#api-rest-api-2-attachment-content-id-get).  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** For the issue containing the attachment:   *  *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.
471pub async fn get_attachment_thumbnail(configuration: &configuration::Configuration, params: GetAttachmentThumbnailParams) -> Result<ResponseContent<GetAttachmentThumbnailSuccess>, Error<GetAttachmentThumbnailError>> {
472    let local_var_configuration = configuration;
473
474    // unbox the parameters
475    let id = params.id;
476    let redirect = params.redirect;
477    let fallback_to_default = params.fallback_to_default;
478    let width = params.width;
479    let height = params.height;
480
481
482    let local_var_client = &local_var_configuration.client;
483
484    let local_var_uri_str = format!("{}/rest/api/2/attachment/thumbnail/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
485    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
486
487    if let Some(ref local_var_str) = redirect {
488        local_var_req_builder = local_var_req_builder.query(&[("redirect", &local_var_str.to_string())]);
489    }
490    if let Some(ref local_var_str) = fallback_to_default {
491        local_var_req_builder = local_var_req_builder.query(&[("fallbackToDefault", &local_var_str.to_string())]);
492    }
493    if let Some(ref local_var_str) = width {
494        local_var_req_builder = local_var_req_builder.query(&[("width", &local_var_str.to_string())]);
495    }
496    if let Some(ref local_var_str) = height {
497        local_var_req_builder = local_var_req_builder.query(&[("height", &local_var_str.to_string())]);
498    }
499    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
500        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
501    }
502    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
503        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
504    };
505    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
506        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
507    };
508
509    let local_var_req = local_var_req_builder.build()?;
510    let local_var_resp = local_var_client.execute(local_var_req).await?;
511
512    let local_var_status = local_var_resp.status();
513    let local_var_content = local_var_resp.text().await?;
514
515    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
516        let local_var_entity: Option<GetAttachmentThumbnailSuccess> = serde_json::from_str(&local_var_content).ok();
517        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
518        Ok(local_var_result)
519    } else {
520        let local_var_entity: Option<GetAttachmentThumbnailError> = serde_json::from_str(&local_var_content).ok();
521        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
522        Err(Error::ResponseError(local_var_error))
523    }
524}
525
526/// Deletes an attachment from an issue.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** For the project holding the issue containing the attachment:   *  *Delete own attachments* [project permission](https://confluence.atlassian.com/x/yodKLg) to delete an attachment created by the calling user.  *  *Delete all attachments* [project permission](https://confluence.atlassian.com/x/yodKLg) to delete an attachment created by any user.
527pub async fn remove_attachment(configuration: &configuration::Configuration, params: RemoveAttachmentParams) -> Result<ResponseContent<RemoveAttachmentSuccess>, Error<RemoveAttachmentError>> {
528    let local_var_configuration = configuration;
529
530    // unbox the parameters
531    let id = params.id;
532
533
534    let local_var_client = &local_var_configuration.client;
535
536    let local_var_uri_str = format!("{}/rest/api/2/attachment/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
537    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
538
539    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
540        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
541    }
542    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
543        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
544    };
545    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
546        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
547    };
548
549    let local_var_req = local_var_req_builder.build()?;
550    let local_var_resp = local_var_client.execute(local_var_req).await?;
551
552    let local_var_status = local_var_resp.status();
553    let local_var_content = local_var_resp.text().await?;
554
555    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
556        let local_var_entity: Option<RemoveAttachmentSuccess> = serde_json::from_str(&local_var_content).ok();
557        let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
558        Ok(local_var_result)
559    } else {
560        let local_var_entity: Option<RemoveAttachmentError> = serde_json::from_str(&local_var_content).ok();
561        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
562        Err(Error::ResponseError(local_var_error))
563    }
564}
565