openapi_github/apis/
security_advisories_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 [`security_advisories_slash_create_fork`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum SecurityAdvisoriesSlashCreateForkError {
22    Status400(models::BasicError),
23    Status403(models::BasicError),
24    Status404(models::BasicError),
25    Status422(models::ValidationError),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`security_advisories_slash_create_private_vulnerability_report`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum SecurityAdvisoriesSlashCreatePrivateVulnerabilityReportError {
33    Status403(models::BasicError),
34    Status404(models::BasicError),
35    Status422(models::ValidationError),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`security_advisories_slash_create_repository_advisory`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum SecurityAdvisoriesSlashCreateRepositoryAdvisoryError {
43    Status403(models::BasicError),
44    Status404(models::BasicError),
45    Status422(models::ValidationError),
46    UnknownValue(serde_json::Value),
47}
48
49/// struct for typed errors of method [`security_advisories_slash_create_repository_advisory_cve_request`]
50#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum SecurityAdvisoriesSlashCreateRepositoryAdvisoryCveRequestError {
53    Status400(models::BasicError),
54    Status403(models::BasicError),
55    Status404(models::BasicError),
56    Status422(models::ValidationError),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`security_advisories_slash_get_global_advisory`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum SecurityAdvisoriesSlashGetGlobalAdvisoryError {
64    Status404(models::BasicError),
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`security_advisories_slash_get_repository_advisory`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum SecurityAdvisoriesSlashGetRepositoryAdvisoryError {
72    Status403(models::BasicError),
73    Status404(models::BasicError),
74    UnknownValue(serde_json::Value),
75}
76
77/// struct for typed errors of method [`security_advisories_slash_list_global_advisories`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum SecurityAdvisoriesSlashListGlobalAdvisoriesError {
81    Status422(models::ValidationErrorSimple),
82    Status429(models::BasicError),
83    UnknownValue(serde_json::Value),
84}
85
86/// struct for typed errors of method [`security_advisories_slash_list_org_repository_advisories`]
87#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum SecurityAdvisoriesSlashListOrgRepositoryAdvisoriesError {
90    Status400(models::BasicError),
91    Status404(models::BasicError),
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`security_advisories_slash_list_repository_advisories`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum SecurityAdvisoriesSlashListRepositoryAdvisoriesError {
99    Status400(models::BasicError),
100    Status404(models::BasicError),
101    UnknownValue(serde_json::Value),
102}
103
104/// struct for typed errors of method [`security_advisories_slash_update_repository_advisory`]
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum SecurityAdvisoriesSlashUpdateRepositoryAdvisoryError {
108    Status403(models::BasicError),
109    Status404(models::BasicError),
110    Status422(models::ValidationError),
111    UnknownValue(serde_json::Value),
112}
113
114
115/// Create a temporary private fork to collaborate on fixing a security vulnerability in your repository.  **Note**: Forking a repository happens asynchronously. You may have to wait up to 5 minutes before you can access the fork.
116pub async fn security_advisories_slash_create_fork(configuration: &configuration::Configuration, owner: &str, repo: &str, ghsa_id: &str) -> Result<models::FullRepository, Error<SecurityAdvisoriesSlashCreateForkError>> {
117    let local_var_configuration = configuration;
118
119    let local_var_client = &local_var_configuration.client;
120
121    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/security-advisories/{ghsa_id}/forks", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), ghsa_id=crate::apis::urlencode(ghsa_id));
122    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
123
124    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
125        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
126    }
127
128    let local_var_req = local_var_req_builder.build()?;
129    let local_var_resp = local_var_client.execute(local_var_req).await?;
130
131    let local_var_status = local_var_resp.status();
132    let local_var_content = local_var_resp.text().await?;
133
134    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
135        serde_json::from_str(&local_var_content).map_err(Error::from)
136    } else {
137        let local_var_entity: Option<SecurityAdvisoriesSlashCreateForkError> = serde_json::from_str(&local_var_content).ok();
138        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
139        Err(Error::ResponseError(local_var_error))
140    }
141}
142
143/// Report a security vulnerability to the maintainers of the repository. See \"[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)\" for more information about private vulnerability reporting.
144pub async fn security_advisories_slash_create_private_vulnerability_report(configuration: &configuration::Configuration, owner: &str, repo: &str, private_vulnerability_report_create: models::PrivateVulnerabilityReportCreate) -> Result<models::RepositoryAdvisory, Error<SecurityAdvisoriesSlashCreatePrivateVulnerabilityReportError>> {
145    let local_var_configuration = configuration;
146
147    let local_var_client = &local_var_configuration.client;
148
149    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/security-advisories/reports", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
150    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
151
152    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
153        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
154    }
155    local_var_req_builder = local_var_req_builder.json(&private_vulnerability_report_create);
156
157    let local_var_req = local_var_req_builder.build()?;
158    let local_var_resp = local_var_client.execute(local_var_req).await?;
159
160    let local_var_status = local_var_resp.status();
161    let local_var_content = local_var_resp.text().await?;
162
163    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
164        serde_json::from_str(&local_var_content).map_err(Error::from)
165    } else {
166        let local_var_entity: Option<SecurityAdvisoriesSlashCreatePrivateVulnerabilityReportError> = serde_json::from_str(&local_var_content).ok();
167        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
168        Err(Error::ResponseError(local_var_error))
169    }
170}
171
172/// Creates a new repository security advisory.  In order to create a draft repository security advisory, the authenticated user must be a security manager or administrator of that repository.  OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:write` scope to use this endpoint.
173pub async fn security_advisories_slash_create_repository_advisory(configuration: &configuration::Configuration, owner: &str, repo: &str, repository_advisory_create: models::RepositoryAdvisoryCreate) -> Result<models::RepositoryAdvisory, Error<SecurityAdvisoriesSlashCreateRepositoryAdvisoryError>> {
174    let local_var_configuration = configuration;
175
176    let local_var_client = &local_var_configuration.client;
177
178    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/security-advisories", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
179    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
180
181    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
182        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
183    }
184    local_var_req_builder = local_var_req_builder.json(&repository_advisory_create);
185
186    let local_var_req = local_var_req_builder.build()?;
187    let local_var_resp = local_var_client.execute(local_var_req).await?;
188
189    let local_var_status = local_var_resp.status();
190    let local_var_content = local_var_resp.text().await?;
191
192    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
193        serde_json::from_str(&local_var_content).map_err(Error::from)
194    } else {
195        let local_var_entity: Option<SecurityAdvisoriesSlashCreateRepositoryAdvisoryError> = serde_json::from_str(&local_var_content).ok();
196        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
197        Err(Error::ResponseError(local_var_error))
198    }
199}
200
201/// If you want a CVE identification number for the security vulnerability in your project, and don't already have one, you can request a CVE identification number from GitHub. For more information see \"[Requesting a CVE identification number](https://docs.github.com/code-security/security-advisories/repository-security-advisories/publishing-a-repository-security-advisory#requesting-a-cve-identification-number-optional).\"  You may request a CVE for public repositories, but cannot do so for private repositories.  In order to request a CVE for a repository security advisory, the authenticated user must be a security manager or administrator of that repository.  OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:write` scope to use this endpoint.
202pub async fn security_advisories_slash_create_repository_advisory_cve_request(configuration: &configuration::Configuration, owner: &str, repo: &str, ghsa_id: &str) -> Result<serde_json::Value, Error<SecurityAdvisoriesSlashCreateRepositoryAdvisoryCveRequestError>> {
203    let local_var_configuration = configuration;
204
205    let local_var_client = &local_var_configuration.client;
206
207    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/security-advisories/{ghsa_id}/cve", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), ghsa_id=crate::apis::urlencode(ghsa_id));
208    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
209
210    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
211        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
212    }
213
214    let local_var_req = local_var_req_builder.build()?;
215    let local_var_resp = local_var_client.execute(local_var_req).await?;
216
217    let local_var_status = local_var_resp.status();
218    let local_var_content = local_var_resp.text().await?;
219
220    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
221        serde_json::from_str(&local_var_content).map_err(Error::from)
222    } else {
223        let local_var_entity: Option<SecurityAdvisoriesSlashCreateRepositoryAdvisoryCveRequestError> = serde_json::from_str(&local_var_content).ok();
224        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
225        Err(Error::ResponseError(local_var_error))
226    }
227}
228
229/// Gets a global security advisory using its GitHub Security Advisory (GHSA) identifier.
230pub async fn security_advisories_slash_get_global_advisory(configuration: &configuration::Configuration, ghsa_id: &str) -> Result<models::GlobalAdvisory, Error<SecurityAdvisoriesSlashGetGlobalAdvisoryError>> {
231    let local_var_configuration = configuration;
232
233    let local_var_client = &local_var_configuration.client;
234
235    let local_var_uri_str = format!("{}/advisories/{ghsa_id}", local_var_configuration.base_path, ghsa_id=crate::apis::urlencode(ghsa_id));
236    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
237
238    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
239        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
240    }
241
242    let local_var_req = local_var_req_builder.build()?;
243    let local_var_resp = local_var_client.execute(local_var_req).await?;
244
245    let local_var_status = local_var_resp.status();
246    let local_var_content = local_var_resp.text().await?;
247
248    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
249        serde_json::from_str(&local_var_content).map_err(Error::from)
250    } else {
251        let local_var_entity: Option<SecurityAdvisoriesSlashGetGlobalAdvisoryError> = serde_json::from_str(&local_var_content).ok();
252        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
253        Err(Error::ResponseError(local_var_error))
254    }
255}
256
257/// Get a repository security advisory using its GitHub Security Advisory (GHSA) identifier.  Anyone can access any published security advisory on a public repository.  The authenticated user can access an unpublished security advisory from a repository if they are a security manager or administrator of that repository, or if they are a collaborator on the security advisory.  OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:read` scope to to get a published security advisory in a private repository, or any unpublished security advisory that the authenticated user has access to.
258pub async fn security_advisories_slash_get_repository_advisory(configuration: &configuration::Configuration, owner: &str, repo: &str, ghsa_id: &str) -> Result<models::RepositoryAdvisory, Error<SecurityAdvisoriesSlashGetRepositoryAdvisoryError>> {
259    let local_var_configuration = configuration;
260
261    let local_var_client = &local_var_configuration.client;
262
263    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/security-advisories/{ghsa_id}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), ghsa_id=crate::apis::urlencode(ghsa_id));
264    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
265
266    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
267        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
268    }
269
270    let local_var_req = local_var_req_builder.build()?;
271    let local_var_resp = local_var_client.execute(local_var_req).await?;
272
273    let local_var_status = local_var_resp.status();
274    let local_var_content = local_var_resp.text().await?;
275
276    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
277        serde_json::from_str(&local_var_content).map_err(Error::from)
278    } else {
279        let local_var_entity: Option<SecurityAdvisoriesSlashGetRepositoryAdvisoryError> = serde_json::from_str(&local_var_content).ok();
280        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
281        Err(Error::ResponseError(local_var_error))
282    }
283}
284
285/// Lists all global security advisories that match the specified parameters. If no other parameters are defined, the request will return only GitHub-reviewed advisories that are not malware.  By default, all responses will exclude advisories for malware, because malware are not standard vulnerabilities. To list advisories for malware, you must include the `type` parameter in your request, with the value `malware`. For more information about the different types of security advisories, see \"[About the GitHub Advisory database](https://docs.github.com/code-security/security-advisories/global-security-advisories/about-the-github-advisory-database#about-types-of-security-advisories).\"
286pub async fn security_advisories_slash_list_global_advisories(configuration: &configuration::Configuration, ghsa_id: Option<&str>, r#type: Option<&str>, cve_id: Option<&str>, ecosystem: Option<models::SecurityAdvisoryEcosystems>, severity: Option<&str>, cwes: Option<models::SecurityAdvisoriesListGlobalAdvisoriesCwesParameter>, is_withdrawn: Option<bool>, affects: Option<models::SecurityAdvisoriesListGlobalAdvisoriesAffectsParameter>, published: Option<&str>, updated: Option<&str>, modified: Option<&str>, before: Option<&str>, after: Option<&str>, direction: Option<&str>, per_page: Option<i32>, sort: Option<&str>) -> Result<Vec<models::GlobalAdvisory>, Error<SecurityAdvisoriesSlashListGlobalAdvisoriesError>> {
287    let local_var_configuration = configuration;
288
289    let local_var_client = &local_var_configuration.client;
290
291    let local_var_uri_str = format!("{}/advisories", local_var_configuration.base_path);
292    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
293
294    if let Some(ref local_var_str) = ghsa_id {
295        local_var_req_builder = local_var_req_builder.query(&[("ghsa_id", &local_var_str.to_string())]);
296    }
297    if let Some(ref local_var_str) = r#type {
298        local_var_req_builder = local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
299    }
300    if let Some(ref local_var_str) = cve_id {
301        local_var_req_builder = local_var_req_builder.query(&[("cve_id", &local_var_str.to_string())]);
302    }
303    if let Some(ref local_var_str) = ecosystem {
304        local_var_req_builder = local_var_req_builder.query(&[("ecosystem", &local_var_str.to_string())]);
305    }
306    if let Some(ref local_var_str) = severity {
307        local_var_req_builder = local_var_req_builder.query(&[("severity", &local_var_str.to_string())]);
308    }
309    if let Some(ref local_var_str) = cwes {
310        local_var_req_builder = local_var_req_builder.query(&[("cwes", &local_var_str.to_string())]);
311    }
312    if let Some(ref local_var_str) = is_withdrawn {
313        local_var_req_builder = local_var_req_builder.query(&[("is_withdrawn", &local_var_str.to_string())]);
314    }
315    if let Some(ref local_var_str) = affects {
316        local_var_req_builder = local_var_req_builder.query(&[("affects", &local_var_str.to_string())]);
317    }
318    if let Some(ref local_var_str) = published {
319        local_var_req_builder = local_var_req_builder.query(&[("published", &local_var_str.to_string())]);
320    }
321    if let Some(ref local_var_str) = updated {
322        local_var_req_builder = local_var_req_builder.query(&[("updated", &local_var_str.to_string())]);
323    }
324    if let Some(ref local_var_str) = modified {
325        local_var_req_builder = local_var_req_builder.query(&[("modified", &local_var_str.to_string())]);
326    }
327    if let Some(ref local_var_str) = before {
328        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
329    }
330    if let Some(ref local_var_str) = after {
331        local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
332    }
333    if let Some(ref local_var_str) = direction {
334        local_var_req_builder = local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
335    }
336    if let Some(ref local_var_str) = per_page {
337        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
338    }
339    if let Some(ref local_var_str) = sort {
340        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
341    }
342    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
343        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
344    }
345
346    let local_var_req = local_var_req_builder.build()?;
347    let local_var_resp = local_var_client.execute(local_var_req).await?;
348
349    let local_var_status = local_var_resp.status();
350    let local_var_content = local_var_resp.text().await?;
351
352    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
353        serde_json::from_str(&local_var_content).map_err(Error::from)
354    } else {
355        let local_var_entity: Option<SecurityAdvisoriesSlashListGlobalAdvisoriesError> = serde_json::from_str(&local_var_content).ok();
356        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
357        Err(Error::ResponseError(local_var_error))
358    }
359}
360
361/// Lists repository security advisories for an 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 `repo` or `repository_advisories:write` scope to use this endpoint.
362pub async fn security_advisories_slash_list_org_repository_advisories(configuration: &configuration::Configuration, org: &str, direction: Option<&str>, sort: Option<&str>, before: Option<&str>, after: Option<&str>, per_page: Option<i32>, state: Option<&str>) -> Result<Vec<models::RepositoryAdvisory>, Error<SecurityAdvisoriesSlashListOrgRepositoryAdvisoriesError>> {
363    let local_var_configuration = configuration;
364
365    let local_var_client = &local_var_configuration.client;
366
367    let local_var_uri_str = format!("{}/orgs/{org}/security-advisories", local_var_configuration.base_path, org=crate::apis::urlencode(org));
368    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
369
370    if let Some(ref local_var_str) = direction {
371        local_var_req_builder = local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
372    }
373    if let Some(ref local_var_str) = sort {
374        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
375    }
376    if let Some(ref local_var_str) = before {
377        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
378    }
379    if let Some(ref local_var_str) = after {
380        local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
381    }
382    if let Some(ref local_var_str) = per_page {
383        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
384    }
385    if let Some(ref local_var_str) = state {
386        local_var_req_builder = local_var_req_builder.query(&[("state", &local_var_str.to_string())]);
387    }
388    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
389        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
390    }
391
392    let local_var_req = local_var_req_builder.build()?;
393    let local_var_resp = local_var_client.execute(local_var_req).await?;
394
395    let local_var_status = local_var_resp.status();
396    let local_var_content = local_var_resp.text().await?;
397
398    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
399        serde_json::from_str(&local_var_content).map_err(Error::from)
400    } else {
401        let local_var_entity: Option<SecurityAdvisoriesSlashListOrgRepositoryAdvisoriesError> = serde_json::from_str(&local_var_content).ok();
402        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
403        Err(Error::ResponseError(local_var_error))
404    }
405}
406
407/// Lists security advisories in a repository.  The authenticated user can access unpublished security advisories from a repository if they are a security manager or administrator of that repository, or if they are a collaborator on any security advisory.  OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:read` scope to to get a published security advisory in a private repository, or any unpublished security advisory that the authenticated user has access to.
408pub async fn security_advisories_slash_list_repository_advisories(configuration: &configuration::Configuration, owner: &str, repo: &str, direction: Option<&str>, sort: Option<&str>, before: Option<&str>, after: Option<&str>, per_page: Option<i32>, state: Option<&str>) -> Result<Vec<models::RepositoryAdvisory>, Error<SecurityAdvisoriesSlashListRepositoryAdvisoriesError>> {
409    let local_var_configuration = configuration;
410
411    let local_var_client = &local_var_configuration.client;
412
413    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/security-advisories", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
414    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
415
416    if let Some(ref local_var_str) = direction {
417        local_var_req_builder = local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
418    }
419    if let Some(ref local_var_str) = sort {
420        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
421    }
422    if let Some(ref local_var_str) = before {
423        local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
424    }
425    if let Some(ref local_var_str) = after {
426        local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
427    }
428    if let Some(ref local_var_str) = per_page {
429        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
430    }
431    if let Some(ref local_var_str) = state {
432        local_var_req_builder = local_var_req_builder.query(&[("state", &local_var_str.to_string())]);
433    }
434    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
435        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
436    }
437
438    let local_var_req = local_var_req_builder.build()?;
439    let local_var_resp = local_var_client.execute(local_var_req).await?;
440
441    let local_var_status = local_var_resp.status();
442    let local_var_content = local_var_resp.text().await?;
443
444    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
445        serde_json::from_str(&local_var_content).map_err(Error::from)
446    } else {
447        let local_var_entity: Option<SecurityAdvisoriesSlashListRepositoryAdvisoriesError> = serde_json::from_str(&local_var_content).ok();
448        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
449        Err(Error::ResponseError(local_var_error))
450    }
451}
452
453/// Update a repository security advisory using its GitHub Security Advisory (GHSA) identifier.  In order to update any security advisory, the authenticated user must be a security manager or administrator of that repository, or a collaborator on the repository security advisory.  OAuth app tokens and personal access tokens (classic) need the `repo` or `repository_advisories:write` scope to use this endpoint.
454pub async fn security_advisories_slash_update_repository_advisory(configuration: &configuration::Configuration, owner: &str, repo: &str, ghsa_id: &str, repository_advisory_update: models::RepositoryAdvisoryUpdate) -> Result<models::RepositoryAdvisory, Error<SecurityAdvisoriesSlashUpdateRepositoryAdvisoryError>> {
455    let local_var_configuration = configuration;
456
457    let local_var_client = &local_var_configuration.client;
458
459    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/security-advisories/{ghsa_id}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), ghsa_id=crate::apis::urlencode(ghsa_id));
460    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
461
462    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
463        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
464    }
465    local_var_req_builder = local_var_req_builder.json(&repository_advisory_update);
466
467    let local_var_req = local_var_req_builder.build()?;
468    let local_var_resp = local_var_client.execute(local_var_req).await?;
469
470    let local_var_status = local_var_resp.status();
471    let local_var_content = local_var_resp.text().await?;
472
473    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
474        serde_json::from_str(&local_var_content).map_err(Error::from)
475    } else {
476        let local_var_entity: Option<SecurityAdvisoriesSlashUpdateRepositoryAdvisoryError> = serde_json::from_str(&local_var_content).ok();
477        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
478        Err(Error::ResponseError(local_var_error))
479    }
480}
481