jira/gen/apis/
permission_schemes_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
11use super::{configuration, Error};
12use crate::gen::apis::ResponseContent;
13use crate::gen::models;
14
15/// struct for passing parameters to the method `create_permission_grant`
16#[derive(Clone, Debug)]
17pub struct CreatePermissionGrantParams {
18    /// The ID of the permission scheme in which to create a new permission grant.
19    pub scheme_id: i64,
20    /// The permission grant to create.
21    pub permission_grant: models::PermissionGrant,
22    /// Use expand to include additional information in the response. This parameter accepts a comma-separated list. Note that permissions are always included when you specify any value. Expand options include:   *  `permissions` Returns all permission grants for each permission scheme.  *  `user` Returns information about the user who is granted the permission.  *  `group` Returns information about the group that is granted the permission.  *  `projectRole` Returns information about the project role granted the permission.  *  `field` Returns information about the custom field granted the permission.  *  `all` Returns all expandable information.
23    pub expand: Option<String>,
24}
25
26/// struct for passing parameters to the method `create_permission_scheme`
27#[derive(Clone, Debug)]
28pub struct CreatePermissionSchemeParams {
29    /// The permission scheme to create.
30    pub request_body: ::std::collections::HashMap<String, serde_json::Value>,
31    /// Use expand to include additional information in the response. This parameter accepts a comma-separated list. Note that permissions are always included when you specify any value. Expand options include:   *  `all` Returns all expandable information.  *  `field` Returns information about the custom field granted the permission.  *  `group` Returns information about the group that is granted the permission.  *  `permissions` Returns all permission grants for each permission scheme.  *  `projectRole` Returns information about the project role granted the permission.  *  `user` Returns information about the user who is granted the permission.
32    pub expand: Option<String>,
33}
34
35/// struct for passing parameters to the method `delete_permission_scheme`
36#[derive(Clone, Debug)]
37pub struct DeletePermissionSchemeParams {
38    /// The ID of the permission scheme being deleted.
39    pub scheme_id: i64,
40}
41
42/// struct for passing parameters to the method `delete_permission_scheme_entity`
43#[derive(Clone, Debug)]
44pub struct DeletePermissionSchemeEntityParams {
45    /// The ID of the permission scheme to delete the permission grant from.
46    pub scheme_id: i64,
47    /// The ID of the permission grant to delete.
48    pub permission_id: i64,
49}
50
51/// struct for passing parameters to the method `get_all_permission_schemes`
52#[derive(Clone, Debug)]
53pub struct GetAllPermissionSchemesParams {
54    /// Use expand to include additional information in the response. This parameter accepts a comma-separated list. Note that permissions are included when you specify any value. Expand options include:   *  `all` Returns all expandable information.  *  `field` Returns information about the custom field granted the permission.  *  `group` Returns information about the group that is granted the permission.  *  `permissions` Returns all permission grants for each permission scheme.  *  `projectRole` Returns information about the project role granted the permission.  *  `user` Returns information about the user who is granted the permission.
55    pub expand: Option<String>,
56}
57
58/// struct for passing parameters to the method `get_permission_scheme`
59#[derive(Clone, Debug)]
60pub struct GetPermissionSchemeParams {
61    /// The ID of the permission scheme to return.
62    pub scheme_id: i64,
63    /// Use expand to include additional information in the response. This parameter accepts a comma-separated list. Note that permissions are included when you specify any value. Expand options include:   *  `all` Returns all expandable information.  *  `field` Returns information about the custom field granted the permission.  *  `group` Returns information about the group that is granted the permission.  *  `permissions` Returns all permission grants for each permission scheme.  *  `projectRole` Returns information about the project role granted the permission.  *  `user` Returns information about the user who is granted the permission.
64    pub expand: Option<String>,
65}
66
67/// struct for passing parameters to the method `get_permission_scheme_grant`
68#[derive(Clone, Debug)]
69pub struct GetPermissionSchemeGrantParams {
70    /// The ID of the permission scheme.
71    pub scheme_id: i64,
72    /// The ID of the permission grant.
73    pub permission_id: i64,
74    /// Use expand to include additional information in the response. This parameter accepts a comma-separated list. Note that permissions are always included when you specify any value. Expand options include:   *  `all` Returns all expandable information.  *  `field` Returns information about the custom field granted the permission.  *  `group` Returns information about the group that is granted the permission.  *  `permissions` Returns all permission grants for each permission scheme.  *  `projectRole` Returns information about the project role granted the permission.  *  `user` Returns information about the user who is granted the permission.
75    pub expand: Option<String>,
76}
77
78/// struct for passing parameters to the method `get_permission_scheme_grants`
79#[derive(Clone, Debug)]
80pub struct GetPermissionSchemeGrantsParams {
81    /// The ID of the permission scheme.
82    pub scheme_id: i64,
83    /// Use expand to include additional information in the response. This parameter accepts a comma-separated list. Note that permissions are always included when you specify any value. Expand options include:   *  `permissions` Returns all permission grants for each permission scheme.  *  `user` Returns information about the user who is granted the permission.  *  `group` Returns information about the group that is granted the permission.  *  `projectRole` Returns information about the project role granted the permission.  *  `field` Returns information about the custom field granted the permission.  *  `all` Returns all expandable information.
84    pub expand: Option<String>,
85}
86
87/// struct for passing parameters to the method `update_permission_scheme`
88#[derive(Clone, Debug)]
89pub struct UpdatePermissionSchemeParams {
90    /// The ID of the permission scheme to update.
91    pub scheme_id: i64,
92    pub request_body: ::std::collections::HashMap<String, serde_json::Value>,
93    /// Use expand to include additional information in the response. This parameter accepts a comma-separated list. Note that permissions are always included when you specify any value. Expand options include:   *  `all` Returns all expandable information.  *  `field` Returns information about the custom field granted the permission.  *  `group` Returns information about the group that is granted the permission.  *  `permissions` Returns all permission grants for each permission scheme.  *  `projectRole` Returns information about the project role granted the permission.  *  `user` Returns information about the user who is granted the permission.
94    pub expand: Option<String>,
95}
96
97/// struct for typed errors of method `create_permission_grant`
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum CreatePermissionGrantError {
101    Status400(),
102    Status401(),
103    Status403(),
104    UnknownValue(serde_json::Value),
105}
106
107/// struct for typed errors of method `create_permission_scheme`
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum CreatePermissionSchemeError {
111    Status400(),
112    Status401(),
113    Status403(),
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method `delete_permission_scheme`
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum DeletePermissionSchemeError {
121    Status401(),
122    Status403(),
123    Status404(),
124    UnknownValue(serde_json::Value),
125}
126
127/// struct for typed errors of method `delete_permission_scheme_entity`
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum DeletePermissionSchemeEntityError {
131    Status400(),
132    Status401(),
133    Status403(),
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method `get_all_permission_schemes`
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum GetAllPermissionSchemesError {
141    Status401(),
142    UnknownValue(serde_json::Value),
143}
144
145/// struct for typed errors of method `get_permission_scheme`
146#[derive(Debug, Clone, Serialize, Deserialize)]
147#[serde(untagged)]
148pub enum GetPermissionSchemeError {
149    Status401(),
150    Status404(),
151    UnknownValue(serde_json::Value),
152}
153
154/// struct for typed errors of method `get_permission_scheme_grant`
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum GetPermissionSchemeGrantError {
158    Status401(),
159    Status404(),
160    UnknownValue(serde_json::Value),
161}
162
163/// struct for typed errors of method `get_permission_scheme_grants`
164#[derive(Debug, Clone, Serialize, Deserialize)]
165#[serde(untagged)]
166pub enum GetPermissionSchemeGrantsError {
167    Status401(),
168    Status404(),
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method `update_permission_scheme`
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum UpdatePermissionSchemeError {
176    Status401(),
177    Status403(),
178    Status404(),
179    UnknownValue(serde_json::Value),
180}
181
182/// Creates a permission grant in a permission scheme.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
183pub async fn create_permission_grant(
184    configuration: &configuration::Configuration,
185    params: CreatePermissionGrantParams,
186) -> Result<models::PermissionGrant, Error<CreatePermissionGrantError>> {
187    // unbox the parameters
188    let scheme_id = params.scheme_id;
189    let permission_grant = params.permission_grant;
190    let expand = params.expand;
191
192    let local_var_client = &configuration.client;
193
194    let local_var_uri_str = format!(
195        "{}/rest/api/3/permissionscheme/{schemeId}/permission",
196        configuration.base_path,
197        schemeId = scheme_id
198    );
199    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
200
201    if let Some(ref local_var_str) = expand {
202        local_var_req_builder =
203            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
204    }
205    if let Some(ref local_var_user_agent) = configuration.user_agent {
206        local_var_req_builder =
207            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
208    }
209    if let Some(ref local_var_token) = configuration.oauth_access_token {
210        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
211    };
212    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
213        local_var_req_builder = local_var_req_builder.basic_auth(
214            local_var_auth_conf.0.to_owned(),
215            local_var_auth_conf.1.to_owned(),
216        );
217    };
218    local_var_req_builder = local_var_req_builder.json(&permission_grant);
219
220    let local_var_req = local_var_req_builder.build()?;
221    let local_var_resp = local_var_client.execute(local_var_req).await?;
222
223    let local_var_status = local_var_resp.status();
224    let local_var_content = local_var_resp.text().await?;
225
226    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
227        serde_json::from_str(&local_var_content).map_err(Error::from)
228    } else {
229        let local_var_entity: Option<CreatePermissionGrantError> =
230            serde_json::from_str(&local_var_content).ok();
231        let local_var_error = ResponseContent {
232            status: local_var_status,
233            content: local_var_content,
234            entity: local_var_entity,
235        };
236        Err(Error::ResponseError(local_var_error))
237    }
238}
239
240/// Creates a new permission scheme. You can create a permission scheme with or without defining a set of permission grants.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
241pub async fn create_permission_scheme(
242    configuration: &configuration::Configuration,
243    params: CreatePermissionSchemeParams,
244) -> Result<models::PermissionScheme, Error<CreatePermissionSchemeError>> {
245    // unbox the parameters
246    let request_body = params.request_body;
247    let expand = params.expand;
248
249    let local_var_client = &configuration.client;
250
251    let local_var_uri_str = format!("{}/rest/api/3/permissionscheme", configuration.base_path);
252    let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
253
254    if let Some(ref local_var_str) = expand {
255        local_var_req_builder =
256            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
257    }
258    if let Some(ref local_var_user_agent) = configuration.user_agent {
259        local_var_req_builder =
260            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
261    }
262    if let Some(ref local_var_token) = configuration.oauth_access_token {
263        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
264    };
265    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
266        local_var_req_builder = local_var_req_builder.basic_auth(
267            local_var_auth_conf.0.to_owned(),
268            local_var_auth_conf.1.to_owned(),
269        );
270    };
271    local_var_req_builder = local_var_req_builder.json(&request_body);
272
273    let local_var_req = local_var_req_builder.build()?;
274    let local_var_resp = local_var_client.execute(local_var_req).await?;
275
276    let local_var_status = local_var_resp.status();
277    let local_var_content = local_var_resp.text().await?;
278
279    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
280        serde_json::from_str(&local_var_content).map_err(Error::from)
281    } else {
282        let local_var_entity: Option<CreatePermissionSchemeError> =
283            serde_json::from_str(&local_var_content).ok();
284        let local_var_error = ResponseContent {
285            status: local_var_status,
286            content: local_var_content,
287            entity: local_var_entity,
288        };
289        Err(Error::ResponseError(local_var_error))
290    }
291}
292
293/// Deletes a permission scheme.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
294pub async fn delete_permission_scheme(
295    configuration: &configuration::Configuration,
296    params: DeletePermissionSchemeParams,
297) -> Result<(), Error<DeletePermissionSchemeError>> {
298    // unbox the parameters
299    let scheme_id = params.scheme_id;
300
301    let local_var_client = &configuration.client;
302
303    let local_var_uri_str = format!(
304        "{}/rest/api/3/permissionscheme/{schemeId}",
305        configuration.base_path,
306        schemeId = scheme_id
307    );
308    let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
309
310    if let Some(ref local_var_user_agent) = configuration.user_agent {
311        local_var_req_builder =
312            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
313    }
314    if let Some(ref local_var_token) = configuration.oauth_access_token {
315        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
316    };
317    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
318        local_var_req_builder = local_var_req_builder.basic_auth(
319            local_var_auth_conf.0.to_owned(),
320            local_var_auth_conf.1.to_owned(),
321        );
322    };
323
324    let local_var_req = local_var_req_builder.build()?;
325    let local_var_resp = local_var_client.execute(local_var_req).await?;
326
327    let local_var_status = local_var_resp.status();
328    let local_var_content = local_var_resp.text().await?;
329
330    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
331        Ok(())
332    } else {
333        let local_var_entity: Option<DeletePermissionSchemeError> =
334            serde_json::from_str(&local_var_content).ok();
335        let local_var_error = ResponseContent {
336            status: local_var_status,
337            content: local_var_content,
338            entity: local_var_entity,
339        };
340        Err(Error::ResponseError(local_var_error))
341    }
342}
343
344/// Deletes a permission grant from a permission scheme. See [About permission schemes and grants](#about-permission-schemes) for more details.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
345pub async fn delete_permission_scheme_entity(
346    configuration: &configuration::Configuration,
347    params: DeletePermissionSchemeEntityParams,
348) -> Result<(), Error<DeletePermissionSchemeEntityError>> {
349    // unbox the parameters
350    let scheme_id = params.scheme_id;
351    let permission_id = params.permission_id;
352
353    let local_var_client = &configuration.client;
354
355    let local_var_uri_str = format!(
356        "{}/rest/api/3/permissionscheme/{schemeId}/permission/{permissionId}",
357        configuration.base_path,
358        schemeId = scheme_id,
359        permissionId = permission_id
360    );
361    let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
362
363    if let Some(ref local_var_user_agent) = configuration.user_agent {
364        local_var_req_builder =
365            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
366    }
367    if let Some(ref local_var_token) = configuration.oauth_access_token {
368        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
369    };
370    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
371        local_var_req_builder = local_var_req_builder.basic_auth(
372            local_var_auth_conf.0.to_owned(),
373            local_var_auth_conf.1.to_owned(),
374        );
375    };
376
377    let local_var_req = local_var_req_builder.build()?;
378    let local_var_resp = local_var_client.execute(local_var_req).await?;
379
380    let local_var_status = local_var_resp.status();
381    let local_var_content = local_var_resp.text().await?;
382
383    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
384        Ok(())
385    } else {
386        let local_var_entity: Option<DeletePermissionSchemeEntityError> =
387            serde_json::from_str(&local_var_content).ok();
388        let local_var_error = ResponseContent {
389            status: local_var_status,
390            content: local_var_content,
391            entity: local_var_entity,
392        };
393        Err(Error::ResponseError(local_var_error))
394    }
395}
396
397/// Returns all permission schemes.  ### About permission schemes and grants ###  A permission scheme is a collection of permission grants. A permission grant consists of a `holder` and a `permission`.  #### Holder object ####  The `holder` object contains information about the user or group being granted the permission. For example, the *Administer projects* permission is granted to a group named *Teams in space administrators*. In this case, the type is `\"type\": \"group\"`, and the parameter is the group name, `\"parameter\": \"Teams in space administrators\"`. The `holder` object is defined by the following properties:   *  `type` Identifies the user or group (see the list of types below).  *  `parameter` The value of this property depends on the `type`. For example, if the `type` is a group, then you need to specify the group name.  The following `types` are available. The expected values for the `parameter` are given in parenthesis (some `types` may not have a `parameter`):   *  `anyone` Grant for anonymous users.  *  `applicationRole` Grant for users with access to the specified application (application name). See [Update product access settings](https://confluence.atlassian.com/x/3YxjL) for more information.  *  `assignee` Grant for the user currently assigned to an issue.  *  `group` Grant for the specified group (group name).  *  `groupCustomField` Grant for a user in the group selected in the specified custom field (custom field ID).  *  `projectLead` Grant for a project lead.  *  `projectRole` Grant for the specified project role (project role ID).  *  `reporter` Grant for the user who reported the issue.  *  `sd.customer.portal.only` Jira Service Desk only. Grants customers permission to access the customer portal but not Jira. See [Customizing Jira Service Desk permissions](https://confluence.atlassian.com/x/24dKLg) for more information.  *  `user` Grant for the specified user (user ID - historically this was the userkey but that is deprecated and the account ID should be used).  *  `userCustomField` Grant for a user selected in the specified custom field (custom field ID).  #### Built-in permissions ####  The [built-in Jira permissions](https://confluence.atlassian.com/x/yodKLg) are listed below. Apps can also define custom permissions. See the [project permission](https://developer.atlassian.com/cloud/jira/platform/modules/project-permission/) and [global permission](https://developer.atlassian.com/cloud/jira/platform/modules/global-permission/) module documentation for more information.  **Project permissions**   *  `ADMINISTER_PROJECTS`  *  `BROWSE_PROJECTS`  *  `MANAGE_SPRINTS_PERMISSION` (Jira Software only)  *  `SERVICEDESK_AGENT` (Jira Service Desk only)  *  `VIEW_DEV_TOOLS` (Jira Software only)  *  `VIEW_READONLY_WORKFLOW`  **Issue permissions**   *  `ASSIGNABLE_USER`  *  `ASSIGN_ISSUES`  *  `CLOSE_ISSUES`  *  `CREATE_ISSUES`  *  `DELETE_ISSUES`  *  `EDIT_ISSUES`  *  `LINK_ISSUES`  *  `MODIFY_REPORTER`  *  `MOVE_ISSUES`  *  `RESOLVE_ISSUES`  *  `SCHEDULE_ISSUES`  *  `SET_ISSUE_SECURITY`  *  `TRANSITION_ISSUES`  **Voters and watchers permissions**   *  `MANAGE_WATCHERS`  *  `VIEW_VOTERS_AND_WATCHERS`  **Comments permissions**   *  `ADD_COMMENTS`  *  `DELETE_ALL_COMMENTS`  *  `DELETE_OWN_COMMENTS`  *  `EDIT_ALL_COMMENTS`  *  `EDIT_OWN_COMMENTS`  **Attachments permissions**   *  `CREATE_ATTACHMENTS`  *  `DELETE_ALL_ATTACHMENTS`  *  `DELETE_OWN_ATTACHMENTS`  **Time tracking permissions**   *  `DELETE_ALL_WORKLOGS`  *  `DELETE_OWN_WORKLOGS`  *  `EDIT_ALL_WORKLOGS`  *  `EDIT_OWN_WORKLOGS`  *  `WORK_ON_ISSUES`  **[Permissions](#permissions) required:** Permission to access Jira.
398pub async fn get_all_permission_schemes(
399    configuration: &configuration::Configuration,
400    params: GetAllPermissionSchemesParams,
401) -> Result<models::PermissionSchemes, Error<GetAllPermissionSchemesError>> {
402    // unbox the parameters
403    let expand = params.expand;
404
405    let local_var_client = &configuration.client;
406
407    let local_var_uri_str = format!("{}/rest/api/3/permissionscheme", configuration.base_path);
408    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
409
410    if let Some(ref local_var_str) = expand {
411        local_var_req_builder =
412            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
413    }
414    if let Some(ref local_var_user_agent) = configuration.user_agent {
415        local_var_req_builder =
416            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
417    }
418    if let Some(ref local_var_token) = configuration.oauth_access_token {
419        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
420    };
421    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
422        local_var_req_builder = local_var_req_builder.basic_auth(
423            local_var_auth_conf.0.to_owned(),
424            local_var_auth_conf.1.to_owned(),
425        );
426    };
427
428    let local_var_req = local_var_req_builder.build()?;
429    let local_var_resp = local_var_client.execute(local_var_req).await?;
430
431    let local_var_status = local_var_resp.status();
432    let local_var_content = local_var_resp.text().await?;
433
434    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
435        serde_json::from_str(&local_var_content).map_err(Error::from)
436    } else {
437        let local_var_entity: Option<GetAllPermissionSchemesError> =
438            serde_json::from_str(&local_var_content).ok();
439        let local_var_error = ResponseContent {
440            status: local_var_status,
441            content: local_var_content,
442            entity: local_var_entity,
443        };
444        Err(Error::ResponseError(local_var_error))
445    }
446}
447
448/// Returns a permission scheme.  **[Permissions](#permissions) required:** Permission to access Jira.
449pub async fn get_permission_scheme(
450    configuration: &configuration::Configuration,
451    params: GetPermissionSchemeParams,
452) -> Result<models::PermissionScheme, Error<GetPermissionSchemeError>> {
453    // unbox the parameters
454    let scheme_id = params.scheme_id;
455    let expand = params.expand;
456
457    let local_var_client = &configuration.client;
458
459    let local_var_uri_str = format!(
460        "{}/rest/api/3/permissionscheme/{schemeId}",
461        configuration.base_path,
462        schemeId = scheme_id
463    );
464    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
465
466    if let Some(ref local_var_str) = expand {
467        local_var_req_builder =
468            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
469    }
470    if let Some(ref local_var_user_agent) = configuration.user_agent {
471        local_var_req_builder =
472            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
473    }
474    if let Some(ref local_var_token) = configuration.oauth_access_token {
475        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
476    };
477    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
478        local_var_req_builder = local_var_req_builder.basic_auth(
479            local_var_auth_conf.0.to_owned(),
480            local_var_auth_conf.1.to_owned(),
481        );
482    };
483
484    let local_var_req = local_var_req_builder.build()?;
485    let local_var_resp = local_var_client.execute(local_var_req).await?;
486
487    let local_var_status = local_var_resp.status();
488    let local_var_content = local_var_resp.text().await?;
489
490    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
491        serde_json::from_str(&local_var_content).map_err(Error::from)
492    } else {
493        let local_var_entity: Option<GetPermissionSchemeError> =
494            serde_json::from_str(&local_var_content).ok();
495        let local_var_error = ResponseContent {
496            status: local_var_status,
497            content: local_var_content,
498            entity: local_var_entity,
499        };
500        Err(Error::ResponseError(local_var_error))
501    }
502}
503
504/// Returns a permission grant.  **[Permissions](#permissions) required:** Permission to access Jira.
505pub async fn get_permission_scheme_grant(
506    configuration: &configuration::Configuration,
507    params: GetPermissionSchemeGrantParams,
508) -> Result<models::PermissionGrant, Error<GetPermissionSchemeGrantError>> {
509    // unbox the parameters
510    let scheme_id = params.scheme_id;
511    let permission_id = params.permission_id;
512    let expand = params.expand;
513
514    let local_var_client = &configuration.client;
515
516    let local_var_uri_str = format!(
517        "{}/rest/api/3/permissionscheme/{schemeId}/permission/{permissionId}",
518        configuration.base_path,
519        schemeId = scheme_id,
520        permissionId = permission_id
521    );
522    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
523
524    if let Some(ref local_var_str) = expand {
525        local_var_req_builder =
526            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
527    }
528    if let Some(ref local_var_user_agent) = configuration.user_agent {
529        local_var_req_builder =
530            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
531    }
532    if let Some(ref local_var_token) = configuration.oauth_access_token {
533        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
534    };
535    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
536        local_var_req_builder = local_var_req_builder.basic_auth(
537            local_var_auth_conf.0.to_owned(),
538            local_var_auth_conf.1.to_owned(),
539        );
540    };
541
542    let local_var_req = local_var_req_builder.build()?;
543    let local_var_resp = local_var_client.execute(local_var_req).await?;
544
545    let local_var_status = local_var_resp.status();
546    let local_var_content = local_var_resp.text().await?;
547
548    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
549        serde_json::from_str(&local_var_content).map_err(Error::from)
550    } else {
551        let local_var_entity: Option<GetPermissionSchemeGrantError> =
552            serde_json::from_str(&local_var_content).ok();
553        let local_var_error = ResponseContent {
554            status: local_var_status,
555            content: local_var_content,
556            entity: local_var_entity,
557        };
558        Err(Error::ResponseError(local_var_error))
559    }
560}
561
562/// Returns all permission grants for a permission scheme.  **[Permissions](#permissions) required:** Permission to access Jira.
563pub async fn get_permission_scheme_grants(
564    configuration: &configuration::Configuration,
565    params: GetPermissionSchemeGrantsParams,
566) -> Result<models::PermissionGrants, Error<GetPermissionSchemeGrantsError>> {
567    // unbox the parameters
568    let scheme_id = params.scheme_id;
569    let expand = params.expand;
570
571    let local_var_client = &configuration.client;
572
573    let local_var_uri_str = format!(
574        "{}/rest/api/3/permissionscheme/{schemeId}/permission",
575        configuration.base_path,
576        schemeId = scheme_id
577    );
578    let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
579
580    if let Some(ref local_var_str) = expand {
581        local_var_req_builder =
582            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
583    }
584    if let Some(ref local_var_user_agent) = configuration.user_agent {
585        local_var_req_builder =
586            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
587    }
588    if let Some(ref local_var_token) = configuration.oauth_access_token {
589        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
590    };
591    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
592        local_var_req_builder = local_var_req_builder.basic_auth(
593            local_var_auth_conf.0.to_owned(),
594            local_var_auth_conf.1.to_owned(),
595        );
596    };
597
598    let local_var_req = local_var_req_builder.build()?;
599    let local_var_resp = local_var_client.execute(local_var_req).await?;
600
601    let local_var_status = local_var_resp.status();
602    let local_var_content = local_var_resp.text().await?;
603
604    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
605        serde_json::from_str(&local_var_content).map_err(Error::from)
606    } else {
607        let local_var_entity: Option<GetPermissionSchemeGrantsError> =
608            serde_json::from_str(&local_var_content).ok();
609        let local_var_error = ResponseContent {
610            status: local_var_status,
611            content: local_var_content,
612            entity: local_var_entity,
613        };
614        Err(Error::ResponseError(local_var_error))
615    }
616}
617
618/// Updates a permission scheme. Below are some important things to note when using this resource:   *  If a permissions list is present in the request, then it is set in the permission scheme, overwriting *all existing* grants.  *  If you want to update only the name and description, then do not send a permissions list in the request.  *  Sending an empty list will remove all permission grants from the permission scheme.  If you want to add or delete a permission grant instead of updating the whole list, see [Create permission grant](#api-rest-api-3-permissionscheme-schemeId-permission-post) or [Delete permission scheme entity](#api-rest-api-3-permissionscheme-schemeId-permission-permissionId-delete).  See [About permission schemes and grants](#about-permission-schemes) for more details.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
619pub async fn update_permission_scheme(
620    configuration: &configuration::Configuration,
621    params: UpdatePermissionSchemeParams,
622) -> Result<models::PermissionScheme, Error<UpdatePermissionSchemeError>> {
623    // unbox the parameters
624    let scheme_id = params.scheme_id;
625    let request_body = params.request_body;
626    let expand = params.expand;
627
628    let local_var_client = &configuration.client;
629
630    let local_var_uri_str = format!(
631        "{}/rest/api/3/permissionscheme/{schemeId}",
632        configuration.base_path,
633        schemeId = scheme_id
634    );
635    let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
636
637    if let Some(ref local_var_str) = expand {
638        local_var_req_builder =
639            local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
640    }
641    if let Some(ref local_var_user_agent) = configuration.user_agent {
642        local_var_req_builder =
643            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
644    }
645    if let Some(ref local_var_token) = configuration.oauth_access_token {
646        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
647    };
648    if let Some(ref local_var_auth_conf) = configuration.basic_auth {
649        local_var_req_builder = local_var_req_builder.basic_auth(
650            local_var_auth_conf.0.to_owned(),
651            local_var_auth_conf.1.to_owned(),
652        );
653    };
654    local_var_req_builder = local_var_req_builder.json(&request_body);
655
656    let local_var_req = local_var_req_builder.build()?;
657    let local_var_resp = local_var_client.execute(local_var_req).await?;
658
659    let local_var_status = local_var_resp.status();
660    let local_var_content = local_var_resp.text().await?;
661
662    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
663        serde_json::from_str(&local_var_content).map_err(Error::from)
664    } else {
665        let local_var_entity: Option<UpdatePermissionSchemeError> =
666            serde_json::from_str(&local_var_content).ok();
667        let local_var_error = ResponseContent {
668            status: local_var_status,
669            content: local_var_content,
670            entity: local_var_entity,
671        };
672        Err(Error::ResponseError(local_var_error))
673    }
674}