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
use octocrate_core::*;
#[allow(unused_imports)]
use crate::types::*;
/// View various OSS licenses.
pub struct GitHubLicensesAPI {
config: SharedAPIConfig,
}
impl GitHubLicensesAPI {
pub fn new(config: &SharedAPIConfig) -> Self {
Self {
config: config.clone(),
}
}
/// **Get the license for a repository**
///
/// This method returns the contents of the repository's license file, if one is detected.
///
/// 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/vnd.github.raw+json`**: Returns the raw contents of the license.
/// - **`application/vnd.github.html+json`**: Returns the license contents in HTML. Markup languages are rendered to HTML using GitHub's open-source [Markup library](https://github.com/github/markup).
///
/// *Documentation*: [https://docs.github.com/rest/licenses/licenses#get-the-license-for-a-repository](https://docs.github.com/rest/licenses/licenses#get-the-license-for-a-repository)
pub fn get_for_repo(
&self,
owner: impl Into<String>,
repo: impl Into<String>,
) -> Request<(), LicensesGetForRepoQuery, LicenseContent> {
let owner = owner.into();
let repo = repo.into();
let url = format!("/repos/{owner}/{repo}/license");
Request::<(), LicensesGetForRepoQuery, LicenseContent>::builder(&self.config)
.get(url)
.build()
}
/// **Get a license**
///
/// Gets information about a specific license. For more information, see "[Licensing a repository ](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository)."
///
/// *Documentation*: [https://docs.github.com/rest/licenses/licenses#get-a-license](https://docs.github.com/rest/licenses/licenses#get-a-license)
pub fn get(
&self,
license: impl Into<String>,
) -> Request<(), (), License> {
let license = license.into();
let url = format!("/licenses/{license}");
Request::<(), (), License>::builder(&self.config)
.get(url)
.build()
}
/// **Get all commonly used licenses**
///
/// Lists the most commonly used licenses on GitHub. For more information, see "[Licensing a repository ](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository)."
///
/// *Documentation*: [https://docs.github.com/rest/licenses/licenses#get-all-commonly-used-licenses](https://docs.github.com/rest/licenses/licenses#get-all-commonly-used-licenses)
pub fn get_all_commonly_used(
&self,
) -> Request<(), LicensesGetAllCommonlyUsedQuery, LicenseSimpleArray> {
let url = format!("/licenses");
Request::<(), LicensesGetAllCommonlyUsedQuery, LicenseSimpleArray>::builder(&self.config)
.get(url)
.build()
}
}