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
use crate::{actions::ActionsHandler, models::actions::OidcCustomSub, Octocrab, Result};
impl<'octo> ActionsHandler<'octo> {
/// Gets the customization template for an OpenID Connect (OIDC) subject claim for an organization.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#get-the-customization-template-for-an-oidc-subject-claim-for-an-organization)
///
/// # Examples
///
/// ```no_run
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let custom_sub = octocrab.actions().get_org_oidc_custom_sub("org").await?;
/// # Ok(())
/// # }
/// ```
pub async fn get_org_oidc_custom_sub(&self, org: impl AsRef<str>) -> Result<OidcCustomSub> {
let route = format!(
"/orgs/{org}/actions/oidc/customization/sub",
org = org.as_ref(),
);
self.crab.get(route, None::<&()>).await
}
/// Sets the customization template for an OpenID Connect (OIDC) subject claim for an organization.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#set-the-customization-template-for-an-oidc-subject-claim-for-an-organization)
///
/// # Examples
///
/// ```no_run
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let custom_sub = octocrab.actions().get_org_oidc_custom_sub("org").await?;
/// octocrab.actions().set_org_oidc_custom_sub("org", &custom_sub).await?;
/// # Ok(())
/// # }
/// ```
pub async fn set_org_oidc_custom_sub(
&self,
org: impl AsRef<str>,
oidc_custom_sub: &OidcCustomSub,
) -> Result<()> {
let route = format!(
"/orgs/{org}/actions/oidc/customization/sub",
org = org.as_ref(),
);
crate::map_github_error(self.crab._put(route, Some(oidc_custom_sub)).await?)
.await
.map(drop)
}
/// Gets the customization template for an OpenID Connect (OIDC) subject claim for a repository.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#get-the-customization-template-for-an-oidc-subject-claim-for-a-repository)
///
/// # Examples
///
/// ```no_run
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let custom_sub = octocrab.actions().get_repo_oidc_custom_sub("owner", "repo").await?;
/// # Ok(())
/// # }
/// ```
pub async fn get_repo_oidc_custom_sub(
&self,
owner: impl AsRef<str>,
repo: impl AsRef<str>,
) -> Result<OidcCustomSub> {
let route = format!(
"/repos/{owner}/{repo}/actions/oidc/customization/sub",
owner = owner.as_ref(),
repo = repo.as_ref(),
);
self.crab.get(route, None::<&()>).await
}
/// Sets the customization template for an OpenID Connect (OIDC) subject claim for a repository.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#set-the-customization-template-for-an-oidc-subject-claim-for-a-repository)
///
/// # Examples
///
/// ```no_run
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let custom_sub = octocrab.actions().get_repo_oidc_custom_sub("owner", "repo").await?;
/// octocrab.actions().set_repo_oidc_custom_sub("owner", "repo", &custom_sub).await?;
/// # Ok(())
/// # }
/// ```
pub async fn set_repo_oidc_custom_sub(
&self,
owner: impl AsRef<str>,
repo: impl AsRef<str>,
oidc_custom_sub: &OidcCustomSub,
) -> Result<()> {
let route = format!(
"/repos/{owner}/{repo}/actions/oidc/customization/sub",
owner = owner.as_ref(),
repo = repo.as_ref(),
);
crate::map_github_error(self.crab._put(route, Some(oidc_custom_sub)).await?)
.await
.map(drop)
}
}
/// Handler for GitHub Actions OIDC customization for an enterprise.
pub struct EnterpriseActionsOidcHandler<'octo> {
crab: &'octo Octocrab,
enterprise: String,
}
impl<'octo> EnterpriseActionsOidcHandler<'octo> {
pub(crate) fn new(crab: &'octo Octocrab, enterprise: String) -> Self {
Self { crab, enterprise }
}
/// List OIDC custom property inclusions for an enterprise.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#list-oidc-custom-property-inclusions-for-an-enterprise)
pub async fn list_repo_properties(&self) -> Result<serde_json::Value> {
let route = format!(
"/enterprises/{}/actions/oidc/customization/properties/repo",
self.enterprise
);
self.crab.get(route, None::<&()>).await
}
/// Create an OIDC custom property inclusion for an enterprise.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#create-an-oidc-custom-property-inclusion-for-an-enterprise)
pub async fn create_repo_property(
&self,
custom_property_name: impl Into<String>,
) -> Result<serde_json::Value> {
let route = format!(
"/enterprises/{}/actions/oidc/customization/properties/repo",
self.enterprise
);
let body = serde_json::json!({ "custom_property_name": custom_property_name.into() });
self.crab.post(route, Some(&body)).await
}
/// Delete an OIDC custom property inclusion for an enterprise.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#delete-an-oidc-custom-property-inclusion-for-an-enterprise)
pub async fn delete_repo_property(&self, custom_property_name: impl AsRef<str>) -> Result<()> {
let route = format!(
"/enterprises/{}/actions/oidc/customization/properties/repo/{}",
self.enterprise,
custom_property_name.as_ref()
);
let response = self.crab._delete(route, None::<&()>).await?;
if !response.status().is_success() {
return Err(crate::map_github_error(response).await.unwrap_err());
}
Ok(())
}
}
/// Handler for GitHub Actions OIDC customization for an organization.
pub struct OrgActionsOidcHandler<'octo> {
crab: &'octo Octocrab,
org: String,
}
impl<'octo> OrgActionsOidcHandler<'octo> {
pub(crate) fn new(crab: &'octo Octocrab, org: String) -> Self {
Self { crab, org }
}
/// List OIDC custom property inclusions for an organization.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#list-oidc-custom-property-inclusions-for-an-organization)
pub async fn list_repo_properties(&self) -> Result<serde_json::Value> {
let route = format!(
"/orgs/{}/actions/oidc/customization/properties/repo",
self.org
);
self.crab.get(route, None::<&()>).await
}
/// Create an OIDC custom property inclusion for an organization.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#create-an-oidc-custom-property-inclusion-for-an-organization)
pub async fn create_repo_property(
&self,
custom_property_name: impl Into<String>,
) -> Result<serde_json::Value> {
let route = format!(
"/orgs/{}/actions/oidc/customization/properties/repo",
self.org
);
let body = serde_json::json!({ "custom_property_name": custom_property_name.into() });
self.crab.post(route, Some(&body)).await
}
/// Delete an OIDC custom property inclusion for an organization.
///
/// See: [GitHub API Documentation](https://docs.github.com/en/rest/actions/oidc?apiVersion=2022-11-28#delete-an-oidc-custom-property-inclusion-for-an-organization)
pub async fn delete_repo_property(&self, custom_property_name: impl AsRef<str>) -> Result<()> {
let route = format!(
"/orgs/{}/actions/oidc/customization/properties/repo/{}",
self.org,
custom_property_name.as_ref()
);
let response = self.crab._delete(route, None::<&()>).await?;
if !response.status().is_success() {
return Err(crate::map_github_error(response).await.unwrap_err());
}
Ok(())
}
}