1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
use octocrate_core::*;
#[allow(unused_imports)]
use octocrate_types::*;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[allow(unused_imports)]
use typed_builder::TypedBuilder;
pub mod list_alerts_for_enterprise {
#[allow(unused_imports)]
use super::*;
pub type Response = Vec<OrganizationSecretScanningAlert>;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Query {
/// Set to `open` or `resolved` to only list secret scanning alerts in a specific state.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub state: Option<parameters::SecretScanningAlertState>,
/// A comma-separated list of secret types to return. By default all secret types are returned.
/// See "[Secret scanning patterns](https://docs.github.com/code-security/secret-scanning/secret-scanning-patterns#supported-secrets-for-advanced-security)"
/// for a complete list of secret types.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub secret_type: Option<String>,
/// A comma-separated list of resolutions. Only secret scanning alerts with one of these resolutions are listed. Valid resolutions are `false_positive`, `wont_fix`, `revoked`, `pattern_edited`, `pattern_deleted` or `used_in_tests`.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub resolution: Option<String>,
/// The property to sort the results by. `created` means when the alert was created. `updated` means when the alert was updated or resolved.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub sort: Option<parameters::SecretScanningAlertSort>,
/// The direction to sort the results by.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub direction: Option<parameters::Direction>,
/// The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub per_page: Option<i64>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub before: Option<String>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub after: Option<String>,
/// A comma-separated list of validities that, when present, will return alerts that match the validities in this list. Valid options are `active`, `inactive`, and `unknown`.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub validity: Option<String>,
}
}
pub mod list_alerts_for_org {
#[allow(unused_imports)]
use super::*;
pub type Response = Vec<OrganizationSecretScanningAlert>;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Query {
/// Set to `open` or `resolved` to only list secret scanning alerts in a specific state.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub state: Option<parameters::SecretScanningAlertState>,
/// A comma-separated list of secret types to return. By default all secret types are returned.
/// See "[Secret scanning patterns](https://docs.github.com/code-security/secret-scanning/secret-scanning-patterns#supported-secrets-for-advanced-security)"
/// for a complete list of secret types.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub secret_type: Option<String>,
/// A comma-separated list of resolutions. Only secret scanning alerts with one of these resolutions are listed. Valid resolutions are `false_positive`, `wont_fix`, `revoked`, `pattern_edited`, `pattern_deleted` or `used_in_tests`.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub resolution: Option<String>,
/// The property to sort the results by. `created` means when the alert was created. `updated` means when the alert was updated or resolved.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub sort: Option<parameters::SecretScanningAlertSort>,
/// The direction to sort the results by.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub direction: Option<parameters::Direction>,
/// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub page: Option<i64>,
/// The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub per_page: Option<i64>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for events before this cursor. To receive an initial cursor on your first request, include an empty "before" query string.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub before: Option<String>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for events after this cursor. To receive an initial cursor on your first request, include an empty "after" query string.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub after: Option<String>,
/// A comma-separated list of validities that, when present, will return alerts that match the validities in this list. Valid options are `active`, `inactive`, and `unknown`.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub validity: Option<String>,
}
}
pub mod list_alerts_for_repo {
#[allow(unused_imports)]
use super::*;
pub type Response = Vec<SecretScanningAlert>;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Query {
/// Set to `open` or `resolved` to only list secret scanning alerts in a specific state.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub state: Option<parameters::SecretScanningAlertState>,
/// A comma-separated list of secret types to return. By default all secret types are returned.
/// See "[Secret scanning patterns](https://docs.github.com/code-security/secret-scanning/secret-scanning-patterns#supported-secrets-for-advanced-security)"
/// for a complete list of secret types.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub secret_type: Option<String>,
/// A comma-separated list of resolutions. Only secret scanning alerts with one of these resolutions are listed. Valid resolutions are `false_positive`, `wont_fix`, `revoked`, `pattern_edited`, `pattern_deleted` or `used_in_tests`.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub resolution: Option<String>,
/// The property to sort the results by. `created` means when the alert was created. `updated` means when the alert was updated or resolved.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub sort: Option<parameters::SecretScanningAlertSort>,
/// The direction to sort the results by.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub direction: Option<parameters::Direction>,
/// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub page: Option<i64>,
/// The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub per_page: Option<i64>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for events before this cursor. To receive an initial cursor on your first request, include an empty "before" query string.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub before: Option<String>,
/// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for events after this cursor. To receive an initial cursor on your first request, include an empty "after" query string.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub after: Option<String>,
/// A comma-separated list of validities that, when present, will return alerts that match the validities in this list. Valid options are `active`, `inactive`, and `unknown`.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub validity: Option<String>,
}
}
pub mod get_alert {
#[allow(unused_imports)]
use super::*;
pub type Response = SecretScanningAlert;
}
pub mod update_alert {
#[allow(unused_imports)]
use super::*;
pub type Response = SecretScanningAlert;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Request {
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub resolution: Option<SecretScanningAlertResolution>,
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub resolution_comment: Option<String>,
pub state: SecretScanningAlertState,
}
}
pub mod list_locations_for_alert {
#[allow(unused_imports)]
use super::*;
pub type Response = Vec<SecretScanningLocation>;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Query {
/// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub page: Option<i64>,
/// The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub per_page: Option<i64>,
}
}
pub struct GitHubSecretScanningAPI {
config: SharedAPIConfig,
}
impl GitHubSecretScanningAPI {
pub fn new(config: &SharedAPIConfig) -> Self {
Self {
config: config.clone(),
}
}
/// **List secret scanning alerts for an enterprise**
///
/// Lists secret scanning alerts for eligible repositories in an enterprise, from newest to oldest.
///
/// Alerts are only returned for organizations in the enterprise for which the authenticated user is an organization owner or a [security manager](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization).
///
/// The authenticated user must be a member of the enterprise in order to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope or `security_events` scope to use this endpoint.
///
/// *Documentation*: [https://docs.github.com/rest/secret-scanning/secret-scanning#list-secret-scanning-alerts-for-an-enterprise](https://docs.github.com/rest/secret-scanning/secret-scanning#list-secret-scanning-alerts-for-an-enterprise)
pub fn list_alerts_for_enterprise(
&self,
enterprise: impl Into<String>,
) -> Request<(), list_alerts_for_enterprise::Query, list_alerts_for_enterprise::Response> {
let enterprise = enterprise.into();
let url = format!("/enterprises/{enterprise}/secret-scanning/alerts");
Request::<(), list_alerts_for_enterprise::Query, list_alerts_for_enterprise::Response>::builder(
&self.config,
)
.get(url)
.build()
}
/// **List secret scanning alerts for an organization**
///
/// Lists secret scanning alerts for eligible repositories in an organization, from newest to oldest.
///
/// The authenticated user must be an administrator or security manager for the organization to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead.
///
/// *Documentation*: [https://docs.github.com/rest/secret-scanning/secret-scanning#list-secret-scanning-alerts-for-an-organization](https://docs.github.com/rest/secret-scanning/secret-scanning#list-secret-scanning-alerts-for-an-organization)
pub fn list_alerts_for_org(
&self,
org: impl Into<String>,
) -> Request<(), list_alerts_for_org::Query, list_alerts_for_org::Response> {
let org = org.into();
let url = format!("/orgs/{org}/secret-scanning/alerts");
Request::<(), list_alerts_for_org::Query, list_alerts_for_org::Response>::builder(&self.config)
.get(url)
.build()
}
/// **List secret scanning alerts for a repository**
///
/// Lists secret scanning alerts for an eligible repository, from newest to oldest.
///
/// The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead.
///
/// *Documentation*: [https://docs.github.com/rest/secret-scanning/secret-scanning#list-secret-scanning-alerts-for-a-repository](https://docs.github.com/rest/secret-scanning/secret-scanning#list-secret-scanning-alerts-for-a-repository)
pub fn list_alerts_for_repo(
&self,
owner: impl Into<String>,
repo: impl Into<String>,
) -> Request<(), list_alerts_for_repo::Query, list_alerts_for_repo::Response> {
let owner = owner.into();
let repo = repo.into();
let url = format!("/repos/{owner}/{repo}/secret-scanning/alerts");
Request::<(), list_alerts_for_repo::Query, list_alerts_for_repo::Response>::builder(
&self.config,
)
.get(url)
.build()
}
/// **Get a secret scanning alert**
///
/// Gets a single secret scanning alert detected in an eligible repository.
///
/// The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead.
///
/// *Documentation*: [https://docs.github.com/rest/secret-scanning/secret-scanning#get-a-secret-scanning-alert](https://docs.github.com/rest/secret-scanning/secret-scanning#get-a-secret-scanning-alert)
pub fn get_alert(
&self,
owner: impl Into<String>,
repo: impl Into<String>,
alert_number: impl Into<i64>,
) -> Request<(), (), get_alert::Response> {
let owner = owner.into();
let repo = repo.into();
let alert_number = alert_number.into();
let url = format!("/repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}");
Request::<(), (), get_alert::Response>::builder(&self.config)
.get(url)
.build()
}
/// **Update a secret scanning alert**
///
/// Updates the status of a secret scanning alert in an eligible repository.
///
/// The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead.
///
/// *Documentation*: [https://docs.github.com/rest/secret-scanning/secret-scanning#update-a-secret-scanning-alert](https://docs.github.com/rest/secret-scanning/secret-scanning#update-a-secret-scanning-alert)
pub fn update_alert(
&self,
owner: impl Into<String>,
repo: impl Into<String>,
alert_number: impl Into<i64>,
) -> Request<update_alert::Request, (), update_alert::Response> {
let owner = owner.into();
let repo = repo.into();
let alert_number = alert_number.into();
let url = format!("/repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}");
Request::<update_alert::Request, (), update_alert::Response>::builder(&self.config)
.patch(url)
.build()
}
/// **List locations for a secret scanning alert**
///
/// Lists all locations for a given secret scanning alert for an eligible repository.
///
/// The authenticated user must be an administrator for the repository or for the organization that owns the repository to use this endpoint.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead.
///
/// *Documentation*: [https://docs.github.com/rest/secret-scanning/secret-scanning#list-locations-for-a-secret-scanning-alert](https://docs.github.com/rest/secret-scanning/secret-scanning#list-locations-for-a-secret-scanning-alert)
pub fn list_locations_for_alert(
&self,
owner: impl Into<String>,
repo: impl Into<String>,
alert_number: impl Into<i64>,
) -> Request<(), list_locations_for_alert::Query, list_locations_for_alert::Response> {
let owner = owner.into();
let repo = repo.into();
let alert_number = alert_number.into();
let url = format!("/repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations");
Request::<(), list_locations_for_alert::Query, list_locations_for_alert::Response>::builder(
&self.config,
)
.get(url)
.build()
}
}