hi_jira2/apis/
issue_security_level_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 [`get_issue_security_level`]
18#[derive(Clone, Debug, Default)]
19pub struct GetIssueSecurityLevelParams {
20    /// The ID of the issue security level.
21    pub id: String
22}
23
24/// struct for passing parameters to the method [`get_issue_security_level_members`]
25#[derive(Clone, Debug, Default)]
26pub struct GetIssueSecurityLevelMembersParams {
27    /// The ID of the issue security scheme. Use the [Get issue security schemes](#api-rest-api-2-issuesecurityschemes-get) operation to get a list of issue security scheme IDs.
28    pub issue_security_scheme_id: i64,
29    /// The index of the first item to return in a page of results (page offset).
30    pub start_at: Option<i64>,
31    /// The maximum number of items to return per page.
32    pub max_results: Option<i32>,
33    /// The list of issue security level IDs. To include multiple issue security levels separate IDs with ampersand: `issueSecurityLevelId=10000&issueSecurityLevelId=10001`.
34    pub issue_security_level_id: Option<Vec<i64>>,
35    /// Use expand to include additional information in the response. This parameter accepts a comma-separated list. 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.  *  `projectRole` Returns information about the project role granted the permission.  *  `user` Returns information about the user who is granted the permission.
36    pub expand: Option<String>
37}
38
39
40/// struct for typed errors of method [`get_issue_security_level`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetIssueSecurityLevelError {
44    Status401(),
45    Status404(),
46    UnknownValue(serde_json::Value),
47}
48
49/// struct for typed errors of method [`get_issue_security_level_members`]
50#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum GetIssueSecurityLevelMembersError {
53    Status400(),
54    Status401(),
55    Status403(),
56    Status404(),
57    UnknownValue(serde_json::Value),
58}
59
60
61/// Returns details of an issue security level.  Use [Get issue security scheme](#api-rest-api-2-issuesecurityschemes-id-get) to obtain the IDs of issue security levels associated with the issue security scheme.  This operation can be accessed anonymously.  **[Permissions](#permissions) required:** None.
62pub async fn get_issue_security_level(configuration: &configuration::Configuration, params: GetIssueSecurityLevelParams) -> Result<crate::models::SecurityLevel, Error<GetIssueSecurityLevelError>> {
63    let local_var_configuration = configuration;
64
65    // unbox the parameters
66    let id = params.id;
67
68
69    let local_var_client = &local_var_configuration.client;
70
71    let local_var_uri_str = format!("{}/rest/api/2/securitylevel/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
72    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
73
74    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
75        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
76    }
77    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
78        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
79    };
80    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
81        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
82    };
83
84    let local_var_req = local_var_req_builder.build()?;
85    let local_var_resp = local_var_client.execute(local_var_req).await?;
86
87    let local_var_status = local_var_resp.status();
88    let local_var_content = local_var_resp.text().await?;
89
90    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
91        serde_json::from_str(&local_var_content).map_err(Error::from)
92    } else {
93        let local_var_entity: Option<GetIssueSecurityLevelError> = serde_json::from_str(&local_var_content).ok();
94        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
95        Err(Error::ResponseError(local_var_error))
96    }
97}
98
99/// Returns issue security level members.  Only issue security level members in context of classic projects are returned.  **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
100pub async fn get_issue_security_level_members(configuration: &configuration::Configuration, params: GetIssueSecurityLevelMembersParams) -> Result<crate::models::PageBeanIssueSecurityLevelMember, Error<GetIssueSecurityLevelMembersError>> {
101    let local_var_configuration = configuration;
102
103    // unbox the parameters
104    let issue_security_scheme_id = params.issue_security_scheme_id;
105    let start_at = params.start_at;
106    let max_results = params.max_results;
107    let issue_security_level_id = params.issue_security_level_id;
108    let expand = params.expand;
109
110
111    let local_var_client = &local_var_configuration.client;
112
113    let local_var_uri_str = format!("{}/rest/api/2/issuesecurityschemes/{issueSecuritySchemeId}/members", local_var_configuration.base_path, issueSecuritySchemeId=issue_security_scheme_id);
114    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
115
116    if let Some(ref local_var_str) = start_at {
117        local_var_req_builder = local_var_req_builder.query(&[("startAt", &local_var_str.to_string())]);
118    }
119    if let Some(ref local_var_str) = max_results {
120        local_var_req_builder = local_var_req_builder.query(&[("maxResults", &local_var_str.to_string())]);
121    }
122    if let Some(ref local_var_str) = issue_security_level_id {
123        local_var_req_builder = match "multi" {
124            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("issueSecurityLevelId".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
125            _ => local_var_req_builder.query(&[("issueSecurityLevelId", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
126        };
127    }
128    if let Some(ref local_var_str) = expand {
129        local_var_req_builder = local_var_req_builder.query(&[("expand", &local_var_str.to_string())]);
130    }
131    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
132        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
133    }
134    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
135        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
136    };
137    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
138        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
139    };
140
141    let local_var_req = local_var_req_builder.build()?;
142    let local_var_resp = local_var_client.execute(local_var_req).await?;
143
144    let local_var_status = local_var_resp.status();
145    let local_var_content = local_var_resp.text().await?;
146
147    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
148        serde_json::from_str(&local_var_content).map_err(Error::from)
149    } else {
150        let local_var_entity: Option<GetIssueSecurityLevelMembersError> = serde_json::from_str(&local_var_content).ok();
151        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
152        Err(Error::ResponseError(local_var_error))
153    }
154}
155