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
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 diff_range {
#[allow(unused_imports)]
use super::*;
pub type Response = DependencyGraphDiff;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Query {
/// The full path, relative to the repository root, of the dependency manifest file.
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub name: Option<String>,
}
}
pub mod export_sbom {
#[allow(unused_imports)]
use super::*;
pub type Response = DependencyGraphSpdxSbom;
}
pub mod create_repository_snapshot {
#[allow(unused_imports)]
use super::*;
pub type Request = Snapshot;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Response {
/// The time at which the snapshot was created.
pub created_at: String,
/// ID of the created snapshot.
pub id: i64,
/// A message providing further details about the result, such as why the dependencies were not updated.
pub message: String,
/// Either "SUCCESS", "ACCEPTED", or "INVALID". "SUCCESS" indicates that the snapshot was successfully created and the repository's dependencies were updated. "ACCEPTED" indicates that the snapshot was successfully created, but the repository's dependencies were not updated. "INVALID" indicates that the snapshot was malformed.
pub result: String,
}
}
pub struct GitHubDependencyGraphAPI {
config: SharedAPIConfig,
}
impl GitHubDependencyGraphAPI {
pub fn new(config: &SharedAPIConfig) -> Self {
Self {
config: config.clone(),
}
}
/// **Get a diff of the dependencies between commits**
///
/// Gets the diff of the dependency changes between two commits of a repository, based on the changes to the dependency manifests made in those commits.
///
/// *Documentation*: [https://docs.github.com/rest/dependency-graph/dependency-review#get-a-diff-of-the-dependencies-between-commits](https://docs.github.com/rest/dependency-graph/dependency-review#get-a-diff-of-the-dependencies-between-commits)
pub fn diff_range(
&self,
owner: impl Into<String>,
repo: impl Into<String>,
basehead: impl Into<String>,
) -> Request<(), diff_range::Query, diff_range::Response> {
let owner = owner.into();
let repo = repo.into();
let basehead = basehead.into();
let url = format!("/repos/{owner}/{repo}/dependency-graph/compare/{basehead}");
Request::<(), diff_range::Query, diff_range::Response>::builder(&self.config)
.get(url)
.build()
}
/// **Export a software bill of materials (SBOM) for a repository.**
///
/// Exports the software bill of materials (SBOM) for a repository in SPDX JSON format.
///
/// *Documentation*: [https://docs.github.com/rest/dependency-graph/sboms#export-a-software-bill-of-materials-sbom-for-a-repository](https://docs.github.com/rest/dependency-graph/sboms#export-a-software-bill-of-materials-sbom-for-a-repository)
pub fn export_sbom(
&self,
owner: impl Into<String>,
repo: impl Into<String>,
) -> Request<(), (), export_sbom::Response> {
let owner = owner.into();
let repo = repo.into();
let url = format!("/repos/{owner}/{repo}/dependency-graph/sbom");
Request::<(), (), export_sbom::Response>::builder(&self.config)
.get(url)
.build()
}
/// **Create a snapshot of dependencies for a repository**
///
/// Create a new snapshot of a repository's dependencies.
///
/// The authenticated user must have access to the repository.
///
/// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
///
/// *Documentation*: [https://docs.github.com/rest/dependency-graph/dependency-submission#create-a-snapshot-of-dependencies-for-a-repository](https://docs.github.com/rest/dependency-graph/dependency-submission#create-a-snapshot-of-dependencies-for-a-repository)
pub fn create_repository_snapshot(
&self,
owner: impl Into<String>,
repo: impl Into<String>,
) -> Request<create_repository_snapshot::Request, (), create_repository_snapshot::Response> {
let owner = owner.into();
let repo = repo.into();
let url = format!("/repos/{owner}/{repo}/dependency-graph/snapshots");
Request::<create_repository_snapshot::Request, (), create_repository_snapshot::Response>::builder(&self.config)
.post(url)
.build()
}
}