octocrate 0.3.0

A comprehensive GitHub REST API library based on Rust.
Documentation
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
use octocrate_core::*;
#[allow(unused_imports)]
use crate::types::*;

/// Endpoints to manage Dependabot.
pub struct GitHubDependabotAPI {
  config: SharedAPIConfig,
}

impl GitHubDependabotAPI {
  pub fn new(config: &SharedAPIConfig) -> Self {
    Self {
      config: config.clone(),
    }
  }

  /// *** Get a Dependabot alert ***
  ///
  /// OAuth app tokens and personal access tokens (classic) need the `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/dependabot/alerts#get-a-dependabot-alert](https://docs.github.com/rest/dependabot/alerts#get-a-dependabot-alert)
  pub fn get_alert(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>,
    alert_number: impl Into<serde_json::Value>,
  ) -> Request<(), (), DependabotAlert> {
    let owner = owner.into();
    let repo = repo.into();
    let alert_number = alert_number.into();
    let url = format!("/repos/{owner}/{repo}/dependabot/alerts/{alert_number}");

    Request::<(), (), DependabotAlert>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** Update a Dependabot alert ***
  ///
  /// The authenticated user must have access to security alerts for the repository to use this endpoint. For more information, see "[Granting access to security alerts](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-security-and-analysis-settings-for-your-repository#granting-access-to-security-alerts)."
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `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/dependabot/alerts#update-a-dependabot-alert](https://docs.github.com/rest/dependabot/alerts#update-a-dependabot-alert)
  pub fn update_alert(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>,
    alert_number: impl Into<serde_json::Value>,
  ) -> Request<DependabotUpdateAlertRequest, (), DependabotAlert> {
    let owner = owner.into();
    let repo = repo.into();
    let alert_number = alert_number.into();
    let url = format!("/repos/{owner}/{repo}/dependabot/alerts/{alert_number}");

    Request::<DependabotUpdateAlertRequest, (), DependabotAlert>::builder(&self.config)
      .patch(url)
      .build()
  }

  /// *** Get a repository secret ***
  ///
  /// Gets a single repository secret without revealing its encrypted value.
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#get-a-repository-secret](https://docs.github.com/rest/dependabot/secrets#get-a-repository-secret)
  pub fn get_repo_secret(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>,
    secret_name: impl Into<String>,
  ) -> Request<(), (), DependabotSecret> {
    let owner = owner.into();
    let repo = repo.into();
    let secret_name = secret_name.into();
    let url = format!("/repos/{owner}/{repo}/dependabot/secrets/{secret_name}");

    Request::<(), (), DependabotSecret>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** Create or update a repository secret ***
  ///
  /// Creates or updates a repository secret with an encrypted value. Encrypt your secret using
  /// [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)."
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#create-or-update-a-repository-secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-a-repository-secret)
  pub fn create_or_update_repo_secret(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>,
    secret_name: impl Into<String>,
  ) -> Request<DependabotCreateOrUpdateRepoSecretRequest, (), EmptyObject> {
    let owner = owner.into();
    let repo = repo.into();
    let secret_name = secret_name.into();
    let url = format!("/repos/{owner}/{repo}/dependabot/secrets/{secret_name}");

    Request::<DependabotCreateOrUpdateRepoSecretRequest, (), EmptyObject>::builder(&self.config)
      .put(url)
      .build()
  }

  /// *** Delete a repository secret ***
  ///
  /// Deletes a secret in a repository using the secret name.
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#delete-a-repository-secret](https://docs.github.com/rest/dependabot/secrets#delete-a-repository-secret)
  pub fn delete_repo_secret(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>,
    secret_name: impl Into<String>,
  ) -> NoContentRequest<(), ()> {
    let owner = owner.into();
    let repo = repo.into();
    let secret_name = secret_name.into();
    let url = format!("/repos/{owner}/{repo}/dependabot/secrets/{secret_name}");

    NoContentRequest::<(), ()>::builder(&self.config)
      .delete(url)
      .build()
  }

  /// *** List Dependabot alerts for an enterprise ***
  ///
  /// Lists Dependabot alerts for repositories that are owned by the specified enterprise.
  /// 
  /// The authenticated user must be a member of the enterprise to use this endpoint.
  /// 
  /// Alerts are only returned for organizations in the enterprise for which you are an organization owner or a security manager. For more information about security managers, 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)."
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-an-enterprise](https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-an-enterprise)
  pub fn list_alerts_for_enterprise(
    &self,
    enterprise: impl Into<String>,
  ) -> Request<(), DependabotListAlertsForEnterpriseQuery, DependabotAlertWithRepositoryArray> {
    let enterprise = enterprise.into();
    let url = format!("/enterprises/{enterprise}/dependabot/alerts");

    Request::<(), DependabotListAlertsForEnterpriseQuery, DependabotAlertWithRepositoryArray>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** List organization secrets ***
  ///
  /// Lists all secrets available in an organization without revealing their
  /// encrypted values.
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#list-organization-secrets](https://docs.github.com/rest/dependabot/secrets#list-organization-secrets)
  pub fn list_org_secrets(
    &self,
    org: impl Into<String>,
  ) -> Request<(), DependabotListOrgSecretsQuery, DependabotListOrgSecretsResponse> {
    let org = org.into();
    let url = format!("/orgs/{org}/dependabot/secrets");

    Request::<(), DependabotListOrgSecretsQuery, DependabotListOrgSecretsResponse>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** Get a repository public key ***
  ///
  /// Gets your public key, which you need to encrypt secrets. You need to
  /// encrypt a secret before you can create or update secrets. Anyone with read access
  /// to the repository can use this endpoint.
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint if the repository is private.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#get-a-repository-public-key](https://docs.github.com/rest/dependabot/secrets#get-a-repository-public-key)
  pub fn get_repo_public_key(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>,
  ) -> Request<(), (), DependabotPublicKey> {
    let owner = owner.into();
    let repo = repo.into();
    let url = format!("/repos/{owner}/{repo}/dependabot/secrets/public-key");

    Request::<(), (), DependabotPublicKey>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** Get an organization public key ***
  ///
  /// Gets your public key, which you need to encrypt secrets. You need to
  /// encrypt a secret before you can create or update secrets.
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#get-an-organization-public-key](https://docs.github.com/rest/dependabot/secrets#get-an-organization-public-key)
  pub fn get_org_public_key(
    &self,
    org: impl Into<String>,
  ) -> Request<(), (), DependabotPublicKey> {
    let org = org.into();
    let url = format!("/orgs/{org}/dependabot/secrets/public-key");

    Request::<(), (), DependabotPublicKey>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** List Dependabot alerts for an organization ***
  ///
  /// Lists Dependabot alerts 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 `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/dependabot/alerts#list-dependabot-alerts-for-an-organization](https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-an-organization)
  pub fn list_alerts_for_org(
    &self,
    org: impl Into<String>,
  ) -> Request<(), DependabotListAlertsForOrgQuery, DependabotAlertWithRepositoryArray> {
    let org = org.into();
    let url = format!("/orgs/{org}/dependabot/alerts");

    Request::<(), DependabotListAlertsForOrgQuery, DependabotAlertWithRepositoryArray>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** Add selected repository to an organization secret ***
  ///
  /// Adds a repository to an organization secret when the `visibility` for
  /// repository access is set to `selected`. The visibility is set when you [Create or
  /// update an organization secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret).
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#add-selected-repository-to-an-organization-secret](https://docs.github.com/rest/dependabot/secrets#add-selected-repository-to-an-organization-secret)
  pub fn add_selected_repo_to_org_secret(
    &self,
    org: impl Into<String>,
    secret_name: impl Into<String>,
    repository_id: impl Into<i64>,
  ) -> NoContentRequest<(), ()> {
    let org = org.into();
    let secret_name = secret_name.into();
    let repository_id = repository_id.into();
    let url = format!("/orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}");

    NoContentRequest::<(), ()>::builder(&self.config)
      .put(url)
      .build()
  }

  /// *** Remove selected repository from an organization secret ***
  ///
  /// Removes a repository from an organization secret when the `visibility`
  /// for repository access is set to `selected`. The visibility is set when you [Create
  /// or update an organization secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret).
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#remove-selected-repository-from-an-organization-secret](https://docs.github.com/rest/dependabot/secrets#remove-selected-repository-from-an-organization-secret)
  pub fn remove_selected_repo_from_org_secret(
    &self,
    org: impl Into<String>,
    secret_name: impl Into<String>,
    repository_id: impl Into<i64>,
  ) -> NoContentRequest<(), ()> {
    let org = org.into();
    let secret_name = secret_name.into();
    let repository_id = repository_id.into();
    let url = format!("/orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}");

    NoContentRequest::<(), ()>::builder(&self.config)
      .delete(url)
      .build()
  }

  /// *** List selected repositories for an organization secret ***
  ///
  /// Lists all repositories that have been selected when the `visibility`
  /// for repository access to a secret is set to `selected`.
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#list-selected-repositories-for-an-organization-secret](https://docs.github.com/rest/dependabot/secrets#list-selected-repositories-for-an-organization-secret)
  pub fn list_selected_repos_for_org_secret(
    &self,
    org: impl Into<String>,
    secret_name: impl Into<String>,
  ) -> Request<(), DependabotListSelectedReposForOrgSecretQuery, DependabotListSelectedReposForOrgSecretResponse> {
    let org = org.into();
    let secret_name = secret_name.into();
    let url = format!("/orgs/{org}/dependabot/secrets/{secret_name}/repositories");

    Request::<(), DependabotListSelectedReposForOrgSecretQuery, DependabotListSelectedReposForOrgSecretResponse>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** Set selected repositories for an organization secret ***
  ///
  /// Replaces all repositories for an organization secret when the `visibility`
  /// for repository access is set to `selected`. The visibility is set when you [Create
  /// or update an organization secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret).
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret](https://docs.github.com/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret)
  pub fn set_selected_repos_for_org_secret(
    &self,
    org: impl Into<String>,
    secret_name: impl Into<String>,
  ) -> NoContentRequest<DependabotSetSelectedReposForOrgSecretRequest, ()> {
    let org = org.into();
    let secret_name = secret_name.into();
    let url = format!("/orgs/{org}/dependabot/secrets/{secret_name}/repositories");

    NoContentRequest::<DependabotSetSelectedReposForOrgSecretRequest, ()>::builder(&self.config)
      .put(url)
      .build()
  }

  /// *** List Dependabot alerts for a repository ***
  ///
  /// OAuth app tokens and personal access tokens (classic) need the `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/dependabot/alerts#list-dependabot-alerts-for-a-repository](https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository)
  pub fn list_alerts_for_repo(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>,
  ) -> Request<(), DependabotListAlertsForRepoQuery, DependabotAlertArray> {
    let owner = owner.into();
    let repo = repo.into();
    let url = format!("/repos/{owner}/{repo}/dependabot/alerts");

    Request::<(), DependabotListAlertsForRepoQuery, DependabotAlertArray>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** List repository secrets ***
  ///
  /// Lists all secrets available in a repository without revealing their encrypted
  /// values.
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#list-repository-secrets](https://docs.github.com/rest/dependabot/secrets#list-repository-secrets)
  pub fn list_repo_secrets(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>,
  ) -> Request<(), DependabotListRepoSecretsQuery, DependabotListRepoSecretsResponse> {
    let owner = owner.into();
    let repo = repo.into();
    let url = format!("/repos/{owner}/{repo}/dependabot/secrets");

    Request::<(), DependabotListRepoSecretsQuery, DependabotListRepoSecretsResponse>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** Get an organization secret ***
  ///
  /// Gets a single organization secret without revealing its encrypted value.
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#get-an-organization-secret](https://docs.github.com/rest/dependabot/secrets#get-an-organization-secret)
  pub fn get_org_secret(
    &self,
    org: impl Into<String>,
    secret_name: impl Into<String>,
  ) -> Request<(), (), DependabotSecretForAnOrganization> {
    let org = org.into();
    let secret_name = secret_name.into();
    let url = format!("/orgs/{org}/dependabot/secrets/{secret_name}");

    Request::<(), (), DependabotSecretForAnOrganization>::builder(&self.config)
      .get(url)
      .build()
  }

  /// *** Create or update an organization secret ***
  ///
  /// Creates or updates an organization secret with an encrypted value. Encrypt your secret using
  /// [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api)."
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret)
  pub fn create_or_update_org_secret(
    &self,
    org: impl Into<String>,
    secret_name: impl Into<String>,
  ) -> Request<DependabotCreateOrUpdateOrgSecretRequest, (), EmptyObject> {
    let org = org.into();
    let secret_name = secret_name.into();
    let url = format!("/orgs/{org}/dependabot/secrets/{secret_name}");

    Request::<DependabotCreateOrUpdateOrgSecretRequest, (), EmptyObject>::builder(&self.config)
      .put(url)
      .build()
  }

  /// *** Delete an organization secret ***
  ///
  /// Deletes a secret in an organization using the secret name.
  /// 
  /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
  ///
  /// *Documentation*: [https://docs.github.com/rest/dependabot/secrets#delete-an-organization-secret](https://docs.github.com/rest/dependabot/secrets#delete-an-organization-secret)
  pub fn delete_org_secret(
    &self,
    org: impl Into<String>,
    secret_name: impl Into<String>,
  ) -> NoContentRequest<(), ()> {
    let org = org.into();
    let secret_name = secret_name.into();
    let url = format!("/orgs/{org}/dependabot/secrets/{secret_name}");

    NoContentRequest::<(), ()>::builder(&self.config)
      .delete(url)
      .build()
  }


}