openapi_github/apis/
code_scanning_api.rs

1/*
2 * GitHub's official OpenAPI spec + Octokit extension
3 *
4 * OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
5 *
6 * The version of the OpenAPI document: 16.6.0
7 * 
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 [`code_scanning_slash_delete_analysis`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CodeScanningSlashDeleteAnalysisError {
22    Status400(models::BasicError),
23    Status403(models::BasicError),
24    Status404(models::BasicError),
25    Status503(models::SecretScanningListAlertsForEnterprise503Response),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`code_scanning_slash_get_alert`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum CodeScanningSlashGetAlertError {
33    Status403(models::BasicError),
34    Status404(models::BasicError),
35    Status503(models::SecretScanningListAlertsForEnterprise503Response),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`code_scanning_slash_get_analysis`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum CodeScanningSlashGetAnalysisError {
43    Status403(models::BasicError),
44    Status404(models::BasicError),
45    Status503(models::SecretScanningListAlertsForEnterprise503Response),
46    UnknownValue(serde_json::Value),
47}
48
49/// struct for typed errors of method [`code_scanning_slash_get_codeql_database`]
50#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum CodeScanningSlashGetCodeqlDatabaseError {
53    Status403(models::BasicError),
54    Status404(models::BasicError),
55    Status503(models::SecretScanningListAlertsForEnterprise503Response),
56    UnknownValue(serde_json::Value),
57}
58
59/// struct for typed errors of method [`code_scanning_slash_get_default_setup`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum CodeScanningSlashGetDefaultSetupError {
63    Status403(models::BasicError),
64    Status404(models::BasicError),
65    Status503(models::SecretScanningListAlertsForEnterprise503Response),
66    UnknownValue(serde_json::Value),
67}
68
69/// struct for typed errors of method [`code_scanning_slash_get_sarif`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum CodeScanningSlashGetSarifError {
73    Status403(models::BasicError),
74    Status404(),
75    Status503(models::SecretScanningListAlertsForEnterprise503Response),
76    UnknownValue(serde_json::Value),
77}
78
79/// struct for typed errors of method [`code_scanning_slash_list_alert_instances`]
80#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum CodeScanningSlashListAlertInstancesError {
83    Status403(models::BasicError),
84    Status404(models::BasicError),
85    Status503(models::SecretScanningListAlertsForEnterprise503Response),
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`code_scanning_slash_list_alerts_for_org`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum CodeScanningSlashListAlertsForOrgError {
93    Status404(models::BasicError),
94    Status503(models::SecretScanningListAlertsForEnterprise503Response),
95    UnknownValue(serde_json::Value),
96}
97
98/// struct for typed errors of method [`code_scanning_slash_list_alerts_for_repo`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum CodeScanningSlashListAlertsForRepoError {
102    Status403(models::BasicError),
103    Status404(models::BasicError),
104    Status503(models::SecretScanningListAlertsForEnterprise503Response),
105    UnknownValue(serde_json::Value),
106}
107
108/// struct for typed errors of method [`code_scanning_slash_list_codeql_databases`]
109#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum CodeScanningSlashListCodeqlDatabasesError {
112    Status403(models::BasicError),
113    Status404(models::BasicError),
114    Status503(models::SecretScanningListAlertsForEnterprise503Response),
115    UnknownValue(serde_json::Value),
116}
117
118/// struct for typed errors of method [`code_scanning_slash_list_recent_analyses`]
119#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum CodeScanningSlashListRecentAnalysesError {
122    Status403(models::BasicError),
123    Status404(models::BasicError),
124    Status503(models::SecretScanningListAlertsForEnterprise503Response),
125    UnknownValue(serde_json::Value),
126}
127
128/// struct for typed errors of method [`code_scanning_slash_update_alert`]
129#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum CodeScanningSlashUpdateAlertError {
132    Status403(models::BasicError),
133    Status404(models::BasicError),
134    Status503(models::SecretScanningListAlertsForEnterprise503Response),
135    UnknownValue(serde_json::Value),
136}
137
138/// struct for typed errors of method [`code_scanning_slash_update_default_setup`]
139#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum CodeScanningSlashUpdateDefaultSetupError {
142    Status403(models::BasicError),
143    Status404(models::BasicError),
144    Status409(models::BasicError),
145    Status503(models::SecretScanningListAlertsForEnterprise503Response),
146    UnknownValue(serde_json::Value),
147}
148
149/// struct for typed errors of method [`code_scanning_slash_upload_sarif`]
150#[derive(Debug, Clone, Serialize, Deserialize)]
151#[serde(untagged)]
152pub enum CodeScanningSlashUploadSarifError {
153    Status400(),
154    Status403(models::BasicError),
155    Status404(models::BasicError),
156    Status413(),
157    Status503(models::SecretScanningListAlertsForEnterprise503Response),
158    UnknownValue(serde_json::Value),
159}
160
161
162/// Deletes a specified code scanning analysis from a repository.  You can delete one analysis at a time. To delete a series of analyses, start with the most recent analysis and work backwards. Conceptually, the process is similar to the undo function in a text editor.  When you list the analyses for a repository, one or more will be identified as deletable in the response:  ``` \"deletable\": true ```  An analysis is deletable when it's the most recent in a set of analyses. Typically, a repository will have multiple sets of analyses for each enabled code scanning tool, where a set is determined by a unique combination of analysis values:  * `ref` * `tool` * `category`  If you attempt to delete an analysis that is not the most recent in a set, you'll get a 400 response with the message:  ``` Analysis specified is not deletable. ```  The response from a successful `DELETE` operation provides you with two alternative URLs for deleting the next analysis in the set: `next_analysis_url` and `confirm_delete_url`. Use the `next_analysis_url` URL if you want to avoid accidentally deleting the final analysis in a set. This is a useful option if you want to preserve at least one analysis for the specified tool in your repository. Use the `confirm_delete_url` URL if you are content to remove all analyses for a tool. When you delete the last analysis in a set, the value of `next_analysis_url` and `confirm_delete_url` in the 200 response is `null`.  As an example of the deletion process, let's imagine that you added a workflow that configured a particular code scanning tool to analyze the code in a repository. This tool has added 15 analyses: 10 on the default branch, and another 5 on a topic branch. You therefore have two separate sets of analyses for this tool. You've now decided that you want to remove all of the analyses for the tool. To do this you must make 15 separate deletion requests. To start, you must find an analysis that's identified as deletable. Each set of analyses always has one that's identified as deletable. Having found the deletable analysis for one of the two sets, delete this analysis and then continue deleting the next analysis in the set until they're all deleted. Then repeat the process for the second set. The procedure therefore consists of a nested loop:  **Outer loop**: * List the analyses for the repository, filtered by tool. * Parse this list to find a deletable analysis. If found:    **Inner loop**:   * Delete the identified analysis.   * Parse the response for the value of `confirm_delete_url` and, if found, use this in the next iteration.  The above process assumes that you want to remove all trace of the tool's analyses from the GitHub user interface, for the specified repository, and it therefore uses the `confirm_delete_url` value. Alternatively, you could use the `next_analysis_url` value, which would leave the last analysis in each set undeleted to avoid removing a tool's analysis entirely.  OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
163pub async fn code_scanning_slash_delete_analysis(configuration: &configuration::Configuration, owner: &str, repo: &str, analysis_id: i32, confirm_delete: Option<&str>) -> Result<models::CodeScanningAnalysisDeletion, Error<CodeScanningSlashDeleteAnalysisError>> {
164    let local_var_configuration = configuration;
165
166    let local_var_client = &local_var_configuration.client;
167
168    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), analysis_id=analysis_id);
169    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
170
171    if let Some(ref local_var_str) = confirm_delete {
172        local_var_req_builder = local_var_req_builder.query(&[("confirm_delete", &local_var_str.to_string())]);
173    }
174    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
175        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
176    }
177
178    let local_var_req = local_var_req_builder.build()?;
179    let local_var_resp = local_var_client.execute(local_var_req).await?;
180
181    let local_var_status = local_var_resp.status();
182    let local_var_content = local_var_resp.text().await?;
183
184    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
185        serde_json::from_str(&local_var_content).map_err(Error::from)
186    } else {
187        let local_var_entity: Option<CodeScanningSlashDeleteAnalysisError> = serde_json::from_str(&local_var_content).ok();
188        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
189        Err(Error::ResponseError(local_var_error))
190    }
191}
192
193/// Gets a single code scanning alert.  OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
194pub async fn code_scanning_slash_get_alert(configuration: &configuration::Configuration, owner: &str, repo: &str, alert_number: i32) -> Result<models::CodeScanningAlert, Error<CodeScanningSlashGetAlertError>> {
195    let local_var_configuration = configuration;
196
197    let local_var_client = &local_var_configuration.client;
198
199    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), alert_number=alert_number);
200    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
201
202    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
203        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
204    }
205
206    let local_var_req = local_var_req_builder.build()?;
207    let local_var_resp = local_var_client.execute(local_var_req).await?;
208
209    let local_var_status = local_var_resp.status();
210    let local_var_content = local_var_resp.text().await?;
211
212    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
213        serde_json::from_str(&local_var_content).map_err(Error::from)
214    } else {
215        let local_var_entity: Option<CodeScanningSlashGetAlertError> = serde_json::from_str(&local_var_content).ok();
216        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
217        Err(Error::ResponseError(local_var_error))
218    }
219}
220
221/// Gets a specified code scanning analysis for a repository.  The default JSON response contains fields that describe the analysis. This includes the Git reference and commit SHA to which the analysis relates, the datetime of the analysis, the name of the code scanning tool, and the number of alerts.  The `rules_count` field in the default response give the number of rules that were run in the analysis. For very old analyses this data is not available, and `0` is returned in this field.  This endpoint supports the following custom media types. For more information, see \"[Media types](https://docs.github.com/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types).\"  - **`application/sarif+json`**: Instead of returning a summary of the analysis, this endpoint returns a subset of the analysis data that was uploaded. The data is formatted as [SARIF version 2.1.0](https://docs.oasis-open.org/sarif/sarif/v2.1.0/cs01/sarif-v2.1.0-cs01.html). It also returns additional data such as the `github/alertNumber` and `github/alertUrl` properties.  OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
222pub async fn code_scanning_slash_get_analysis(configuration: &configuration::Configuration, owner: &str, repo: &str, analysis_id: i32) -> Result<models::CodeScanningAnalysis, Error<CodeScanningSlashGetAnalysisError>> {
223    let local_var_configuration = configuration;
224
225    let local_var_client = &local_var_configuration.client;
226
227    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), analysis_id=analysis_id);
228    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
229
230    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
231        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
232    }
233
234    let local_var_req = local_var_req_builder.build()?;
235    let local_var_resp = local_var_client.execute(local_var_req).await?;
236
237    let local_var_status = local_var_resp.status();
238    let local_var_content = local_var_resp.text().await?;
239
240    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
241        serde_json::from_str(&local_var_content).map_err(Error::from)
242    } else {
243        let local_var_entity: Option<CodeScanningSlashGetAnalysisError> = serde_json::from_str(&local_var_content).ok();
244        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
245        Err(Error::ResponseError(local_var_error))
246    }
247}
248
249/// Gets a CodeQL database for a language in a repository.  By default this endpoint returns JSON metadata about the CodeQL database. To download the CodeQL database binary content, set the `Accept` header of the request to [`application/zip`](https://docs.github.com/rest/overview/media-types), and make sure your HTTP client is configured to follow redirects or use the `Location` header to make a second request to get the redirect URL.  OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
250pub async fn code_scanning_slash_get_codeql_database(configuration: &configuration::Configuration, owner: &str, repo: &str, language: &str) -> Result<models::CodeScanningCodeqlDatabase, Error<CodeScanningSlashGetCodeqlDatabaseError>> {
251    let local_var_configuration = configuration;
252
253    let local_var_client = &local_var_configuration.client;
254
255    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/codeql/databases/{language}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), language=crate::apis::urlencode(language));
256    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
257
258    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
259        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
260    }
261
262    let local_var_req = local_var_req_builder.build()?;
263    let local_var_resp = local_var_client.execute(local_var_req).await?;
264
265    let local_var_status = local_var_resp.status();
266    let local_var_content = local_var_resp.text().await?;
267
268    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
269        serde_json::from_str(&local_var_content).map_err(Error::from)
270    } else {
271        let local_var_entity: Option<CodeScanningSlashGetCodeqlDatabaseError> = serde_json::from_str(&local_var_content).ok();
272        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
273        Err(Error::ResponseError(local_var_error))
274    }
275}
276
277/// Gets a code scanning default setup configuration.  OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
278pub async fn code_scanning_slash_get_default_setup(configuration: &configuration::Configuration, owner: &str, repo: &str) -> Result<models::CodeScanningDefaultSetup, Error<CodeScanningSlashGetDefaultSetupError>> {
279    let local_var_configuration = configuration;
280
281    let local_var_client = &local_var_configuration.client;
282
283    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/default-setup", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
284    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
285
286    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
287        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
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        serde_json::from_str(&local_var_content).map_err(Error::from)
298    } else {
299        let local_var_entity: Option<CodeScanningSlashGetDefaultSetupError> = serde_json::from_str(&local_var_content).ok();
300        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
301        Err(Error::ResponseError(local_var_error))
302    }
303}
304
305/// Gets information about a SARIF upload, including the status and the URL of the analysis that was uploaded so that you can retrieve details of the analysis. For more information, see \"[Get a code scanning analysis for a repository](/rest/code-scanning/code-scanning#get-a-code-scanning-analysis-for-a-repository).\" OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
306pub async fn code_scanning_slash_get_sarif(configuration: &configuration::Configuration, owner: &str, repo: &str, sarif_id: &str) -> Result<models::CodeScanningSarifsStatus, Error<CodeScanningSlashGetSarifError>> {
307    let local_var_configuration = configuration;
308
309    let local_var_client = &local_var_configuration.client;
310
311    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), sarif_id=crate::apis::urlencode(sarif_id));
312    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
313
314    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
315        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
316    }
317
318    let local_var_req = local_var_req_builder.build()?;
319    let local_var_resp = local_var_client.execute(local_var_req).await?;
320
321    let local_var_status = local_var_resp.status();
322    let local_var_content = local_var_resp.text().await?;
323
324    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
325        serde_json::from_str(&local_var_content).map_err(Error::from)
326    } else {
327        let local_var_entity: Option<CodeScanningSlashGetSarifError> = serde_json::from_str(&local_var_content).ok();
328        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
329        Err(Error::ResponseError(local_var_error))
330    }
331}
332
333/// Lists all instances of the specified code scanning alert.  OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
334pub async fn code_scanning_slash_list_alert_instances(configuration: &configuration::Configuration, owner: &str, repo: &str, alert_number: i32, page: Option<i32>, per_page: Option<i32>, r#ref: Option<&str>) -> Result<Vec<models::CodeScanningAlertInstance>, Error<CodeScanningSlashListAlertInstancesError>> {
335    let local_var_configuration = configuration;
336
337    let local_var_client = &local_var_configuration.client;
338
339    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), alert_number=alert_number);
340    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
341
342    if let Some(ref local_var_str) = page {
343        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
344    }
345    if let Some(ref local_var_str) = per_page {
346        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
347    }
348    if let Some(ref local_var_str) = r#ref {
349        local_var_req_builder = local_var_req_builder.query(&[("ref", &local_var_str.to_string())]);
350    }
351    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
352        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
353    }
354
355    let local_var_req = local_var_req_builder.build()?;
356    let local_var_resp = local_var_client.execute(local_var_req).await?;
357
358    let local_var_status = local_var_resp.status();
359    let local_var_content = local_var_resp.text().await?;
360
361    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
362        serde_json::from_str(&local_var_content).map_err(Error::from)
363    } else {
364        let local_var_entity: Option<CodeScanningSlashListAlertInstancesError> = serde_json::from_str(&local_var_content).ok();
365        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
366        Err(Error::ResponseError(local_var_error))
367    }
368}
369
370/// Lists code scanning alerts for the default branch for all eligible repositories in an organization. Eligible repositories are repositories that are owned by organizations that you own or for which you are a security manager. For more information, see \"[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization).\"  The authenticated user must be an owner or security manager for the organization to use this endpoint.  OAuth app tokens and personal access tokens (classic) need the `security_events` or `repo`s cope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
371pub async fn code_scanning_slash_list_alerts_for_org(configuration: &configuration::Configuration, org: &str, tool_name: Option<&str>, tool_guid: Option<&str>, before: Option<&str>, after: Option<&str>, page: Option<i32>, per_page: Option<i32>, direction: Option<&str>, state: Option<models::CodeScanningAlertStateQuery>, sort: Option<&str>, severity: Option<models::CodeScanningAlertSeverity>) -> Result<Vec<models::CodeScanningOrganizationAlertItems>, Error<CodeScanningSlashListAlertsForOrgError>> {
372    let local_var_configuration = configuration;
373
374    let local_var_client = &local_var_configuration.client;
375
376    let local_var_uri_str = format!("{}/orgs/{org}/code-scanning/alerts", local_var_configuration.base_path, org=crate::apis::urlencode(org));
377    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
378
379    if let Some(ref local_var_str) = tool_name {
380        local_var_req_builder = local_var_req_builder.query(&[("tool_name", &local_var_str.to_string())]);
381    }
382    if let Some(ref local_var_str) = tool_guid {
383        local_var_req_builder = local_var_req_builder.query(&[("tool_guid", &local_var_str.to_string())]);
384    }
385    if let Some(ref local_var_str) = before {
386        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
387    }
388    if let Some(ref local_var_str) = after {
389        local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
390    }
391    if let Some(ref local_var_str) = page {
392        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
393    }
394    if let Some(ref local_var_str) = per_page {
395        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
396    }
397    if let Some(ref local_var_str) = direction {
398        local_var_req_builder = local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
399    }
400    if let Some(ref local_var_str) = state {
401        local_var_req_builder = local_var_req_builder.query(&[("state", &local_var_str.to_string())]);
402    }
403    if let Some(ref local_var_str) = sort {
404        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
405    }
406    if let Some(ref local_var_str) = severity {
407        local_var_req_builder = local_var_req_builder.query(&[("severity", &local_var_str.to_string())]);
408    }
409    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
410        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
411    }
412
413    let local_var_req = local_var_req_builder.build()?;
414    let local_var_resp = local_var_client.execute(local_var_req).await?;
415
416    let local_var_status = local_var_resp.status();
417    let local_var_content = local_var_resp.text().await?;
418
419    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
420        serde_json::from_str(&local_var_content).map_err(Error::from)
421    } else {
422        let local_var_entity: Option<CodeScanningSlashListAlertsForOrgError> = serde_json::from_str(&local_var_content).ok();
423        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
424        Err(Error::ResponseError(local_var_error))
425    }
426}
427
428/// Lists all open code scanning alerts for the default branch (usually `main` or `master`). You must use an access token with the `security_events` scope to use this endpoint with private repos, the `public_repo` scope also grants permission to read security events on public repos only. GitHub Apps must have the `security_events` read permission to use this endpoint.  The response includes a `most_recent_instance` object. This provides details of the most recent instance of this alert for the default branch or for the specified Git reference (if you used `ref` in the request).
429pub async fn code_scanning_slash_list_alerts_for_repo(configuration: &configuration::Configuration, owner: &str, repo: &str, tool_name: Option<&str>, tool_guid: Option<&str>, page: Option<i32>, per_page: Option<i32>, r#ref: Option<&str>, direction: Option<&str>, sort: Option<&str>, state: Option<models::CodeScanningAlertState>) -> Result<Vec<models::CodeScanningAlertItems>, Error<CodeScanningSlashListAlertsForRepoError>> {
430    let local_var_configuration = configuration;
431
432    let local_var_client = &local_var_configuration.client;
433
434    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/alerts", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
435    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
436
437    if let Some(ref local_var_str) = tool_name {
438        local_var_req_builder = local_var_req_builder.query(&[("tool_name", &local_var_str.to_string())]);
439    }
440    if let Some(ref local_var_str) = tool_guid {
441        local_var_req_builder = local_var_req_builder.query(&[("tool_guid", &local_var_str.to_string())]);
442    }
443    if let Some(ref local_var_str) = page {
444        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
445    }
446    if let Some(ref local_var_str) = per_page {
447        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
448    }
449    if let Some(ref local_var_str) = r#ref {
450        local_var_req_builder = local_var_req_builder.query(&[("ref", &local_var_str.to_string())]);
451    }
452    if let Some(ref local_var_str) = direction {
453        local_var_req_builder = local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
454    }
455    if let Some(ref local_var_str) = sort {
456        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
457    }
458    if let Some(ref local_var_str) = state {
459        local_var_req_builder = local_var_req_builder.query(&[("state", &local_var_str.to_string())]);
460    }
461    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
462        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
463    }
464
465    let local_var_req = local_var_req_builder.build()?;
466    let local_var_resp = local_var_client.execute(local_var_req).await?;
467
468    let local_var_status = local_var_resp.status();
469    let local_var_content = local_var_resp.text().await?;
470
471    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
472        serde_json::from_str(&local_var_content).map_err(Error::from)
473    } else {
474        let local_var_entity: Option<CodeScanningSlashListAlertsForRepoError> = serde_json::from_str(&local_var_content).ok();
475        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
476        Err(Error::ResponseError(local_var_error))
477    }
478}
479
480/// Lists the CodeQL databases that are available in a repository.  OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
481pub async fn code_scanning_slash_list_codeql_databases(configuration: &configuration::Configuration, owner: &str, repo: &str) -> Result<Vec<models::CodeScanningCodeqlDatabase>, Error<CodeScanningSlashListCodeqlDatabasesError>> {
482    let local_var_configuration = configuration;
483
484    let local_var_client = &local_var_configuration.client;
485
486    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/codeql/databases", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
487    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
488
489    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
490        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
491    }
492
493    let local_var_req = local_var_req_builder.build()?;
494    let local_var_resp = local_var_client.execute(local_var_req).await?;
495
496    let local_var_status = local_var_resp.status();
497    let local_var_content = local_var_resp.text().await?;
498
499    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
500        serde_json::from_str(&local_var_content).map_err(Error::from)
501    } else {
502        let local_var_entity: Option<CodeScanningSlashListCodeqlDatabasesError> = serde_json::from_str(&local_var_content).ok();
503        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
504        Err(Error::ResponseError(local_var_error))
505    }
506}
507
508/// Lists the details of all code scanning analyses for a repository, starting with the most recent. The response is paginated and you can use the `page` and `per_page` parameters to list the analyses you're interested in. By default 30 analyses are listed per page.  The `rules_count` field in the response give the number of rules that were run in the analysis. For very old analyses this data is not available, and `0` is returned in this field.  **Deprecation notice**: The `tool_name` field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field.  OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
509pub async fn code_scanning_slash_list_recent_analyses(configuration: &configuration::Configuration, owner: &str, repo: &str, tool_name: Option<&str>, tool_guid: Option<&str>, page: Option<i32>, per_page: Option<i32>, r#ref: Option<&str>, sarif_id: Option<&str>, direction: Option<&str>, sort: Option<&str>) -> Result<Vec<models::CodeScanningAnalysis>, Error<CodeScanningSlashListRecentAnalysesError>> {
510    let local_var_configuration = configuration;
511
512    let local_var_client = &local_var_configuration.client;
513
514    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/analyses", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
515    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
516
517    if let Some(ref local_var_str) = tool_name {
518        local_var_req_builder = local_var_req_builder.query(&[("tool_name", &local_var_str.to_string())]);
519    }
520    if let Some(ref local_var_str) = tool_guid {
521        local_var_req_builder = local_var_req_builder.query(&[("tool_guid", &local_var_str.to_string())]);
522    }
523    if let Some(ref local_var_str) = page {
524        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
525    }
526    if let Some(ref local_var_str) = per_page {
527        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
528    }
529    if let Some(ref local_var_str) = r#ref {
530        local_var_req_builder = local_var_req_builder.query(&[("ref", &local_var_str.to_string())]);
531    }
532    if let Some(ref local_var_str) = sarif_id {
533        local_var_req_builder = local_var_req_builder.query(&[("sarif_id", &local_var_str.to_string())]);
534    }
535    if let Some(ref local_var_str) = direction {
536        local_var_req_builder = local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
537    }
538    if let Some(ref local_var_str) = sort {
539        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
540    }
541    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
542        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
543    }
544
545    let local_var_req = local_var_req_builder.build()?;
546    let local_var_resp = local_var_client.execute(local_var_req).await?;
547
548    let local_var_status = local_var_resp.status();
549    let local_var_content = local_var_resp.text().await?;
550
551    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
552        serde_json::from_str(&local_var_content).map_err(Error::from)
553    } else {
554        let local_var_entity: Option<CodeScanningSlashListRecentAnalysesError> = serde_json::from_str(&local_var_content).ok();
555        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
556        Err(Error::ResponseError(local_var_error))
557    }
558}
559
560/// Updates the status of a single code scanning alert. OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
561pub async fn code_scanning_slash_update_alert(configuration: &configuration::Configuration, owner: &str, repo: &str, alert_number: i32, code_scanning_update_alert_request: models::CodeScanningUpdateAlertRequest) -> Result<models::CodeScanningAlert, Error<CodeScanningSlashUpdateAlertError>> {
562    let local_var_configuration = configuration;
563
564    let local_var_client = &local_var_configuration.client;
565
566    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), alert_number=alert_number);
567    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
568
569    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
570        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
571    }
572    local_var_req_builder = local_var_req_builder.json(&code_scanning_update_alert_request);
573
574    let local_var_req = local_var_req_builder.build()?;
575    let local_var_resp = local_var_client.execute(local_var_req).await?;
576
577    let local_var_status = local_var_resp.status();
578    let local_var_content = local_var_resp.text().await?;
579
580    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
581        serde_json::from_str(&local_var_content).map_err(Error::from)
582    } else {
583        let local_var_entity: Option<CodeScanningSlashUpdateAlertError> = serde_json::from_str(&local_var_content).ok();
584        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
585        Err(Error::ResponseError(local_var_error))
586    }
587}
588
589/// Updates a code scanning default setup configuration.  OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
590pub async fn code_scanning_slash_update_default_setup(configuration: &configuration::Configuration, owner: &str, repo: &str, code_scanning_default_setup_update: models::CodeScanningDefaultSetupUpdate) -> Result<serde_json::Value, Error<CodeScanningSlashUpdateDefaultSetupError>> {
591    let local_var_configuration = configuration;
592
593    let local_var_client = &local_var_configuration.client;
594
595    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/default-setup", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
596    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
597
598    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
599        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
600    }
601    local_var_req_builder = local_var_req_builder.json(&code_scanning_default_setup_update);
602
603    let local_var_req = local_var_req_builder.build()?;
604    let local_var_resp = local_var_client.execute(local_var_req).await?;
605
606    let local_var_status = local_var_resp.status();
607    let local_var_content = local_var_resp.text().await?;
608
609    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
610        serde_json::from_str(&local_var_content).map_err(Error::from)
611    } else {
612        let local_var_entity: Option<CodeScanningSlashUpdateDefaultSetupError> = serde_json::from_str(&local_var_content).ok();
613        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
614        Err(Error::ResponseError(local_var_error))
615    }
616}
617
618/// Uploads SARIF data containing the results of a code scanning analysis to make the results available in a repository. For troubleshooting information, see \"[Troubleshooting SARIF uploads](https://docs.github.com/code-security/code-scanning/troubleshooting-sarif).\"  There are two places where you can upload code scanning results.  - If you upload to a pull request, for example `--ref refs/pull/42/merge` or `--ref refs/pull/42/head`, then the results appear as alerts in a pull request check. For more information, see \"[Triaging code scanning alerts in pull requests](/code-security/secure-coding/triaging-code-scanning-alerts-in-pull-requests).\"  - If you upload to a branch, for example `--ref refs/heads/my-branch`, then the results appear in the **Security** tab for your repository. For more information, see \"[Managing code scanning alerts for your repository](/code-security/secure-coding/managing-code-scanning-alerts-for-your-repository#viewing-the-alerts-for-a-repository).\"  You must compress the SARIF-formatted analysis data that you want to upload, using `gzip`, and then encode it as a Base64 format string. For example:  ``` gzip -c analysis-data.sarif | base64 -w0 ```  SARIF upload supports a maximum number of entries per the following data objects, and an analysis will be rejected if any of these objects is above its maximum value. For some objects, there are additional values over which the entries will be ignored while keeping the most important entries whenever applicable. To get the most out of your analysis when it includes data above the supported limits, try to optimize the analysis configuration. For example, for the CodeQL tool, identify and remove the most noisy queries. For more information, see \"[SARIF results exceed one or more limits](https://docs.github.com/code-security/code-scanning/troubleshooting-sarif/results-exceed-limit).\"   | **SARIF data**                   | **Maximum values** | **Additional limits**                                                            | |----------------------------------|:------------------:|----------------------------------------------------------------------------------| | Runs per file                    |         20         |                                                                                  | | Results per run                  |       25,000       | Only the top 5,000 results will be included, prioritized by severity.            | | Rules per run                    |       25,000       |                                                                                  | | Tool extensions per run          |        100         |                                                                                  | | Thread Flow Locations per result |       10,000       | Only the top 1,000 Thread Flow Locations will be included, using prioritization. | | Location per result              |       1,000        | Only 100 locations will be included.                                             | | Tags per rule                    |         20         | Only 10 tags will be included.                                                   |   The `202 Accepted` response includes an `id` value. You can use this ID to check the status of the upload by using it in the `/sarifs/{sarif_id}` endpoint. For more information, see \"[Get information about a SARIF upload](/rest/code-scanning/code-scanning#get-information-about-a-sarif-upload).\"  OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories.
619pub async fn code_scanning_slash_upload_sarif(configuration: &configuration::Configuration, owner: &str, repo: &str, code_scanning_upload_sarif_request: models::CodeScanningUploadSarifRequest) -> Result<models::CodeScanningSarifsReceipt, Error<CodeScanningSlashUploadSarifError>> {
620    let local_var_configuration = configuration;
621
622    let local_var_client = &local_var_configuration.client;
623
624    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/code-scanning/sarifs", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
625    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
626
627    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
628        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
629    }
630    local_var_req_builder = local_var_req_builder.json(&code_scanning_upload_sarif_request);
631
632    let local_var_req = local_var_req_builder.build()?;
633    let local_var_resp = local_var_client.execute(local_var_req).await?;
634
635    let local_var_status = local_var_resp.status();
636    let local_var_content = local_var_resp.text().await?;
637
638    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
639        serde_json::from_str(&local_var_content).map_err(Error::from)
640    } else {
641        let local_var_entity: Option<CodeScanningSlashUploadSarifError> = serde_json::from_str(&local_var_content).ok();
642        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
643        Err(Error::ResponseError(local_var_error))
644    }
645}
646