openapi_github/apis/
interactions_api.rs

1/*
2 * GitHub's official OpenAPI spec + Octokit extension
3 *
4 * OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
5 *
6 * The version of the OpenAPI document: 16.6.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`interactions_slash_get_restrictions_for_authenticated_user`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum InteractionsSlashGetRestrictionsForAuthenticatedUserError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`interactions_slash_get_restrictions_for_org`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum InteractionsSlashGetRestrictionsForOrgError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`interactions_slash_get_restrictions_for_repo`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum InteractionsSlashGetRestrictionsForRepoError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`interactions_slash_remove_restrictions_for_authenticated_user`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum InteractionsSlashRemoveRestrictionsForAuthenticatedUserError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`interactions_slash_remove_restrictions_for_org`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum InteractionsSlashRemoveRestrictionsForOrgError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`interactions_slash_remove_restrictions_for_repo`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum InteractionsSlashRemoveRestrictionsForRepoError {
57    Status409(),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`interactions_slash_set_restrictions_for_authenticated_user`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum InteractionsSlashSetRestrictionsForAuthenticatedUserError {
65    Status422(models::ValidationError),
66    UnknownValue(serde_json::Value),
67}
68
69/// struct for typed errors of method [`interactions_slash_set_restrictions_for_org`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum InteractionsSlashSetRestrictionsForOrgError {
73    Status422(models::ValidationError),
74    UnknownValue(serde_json::Value),
75}
76
77/// struct for typed errors of method [`interactions_slash_set_restrictions_for_repo`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum InteractionsSlashSetRestrictionsForRepoError {
81    Status409(),
82    UnknownValue(serde_json::Value),
83}
84
85
86/// Shows which type of GitHub user can interact with your public repositories and when the restriction expires.
87pub async fn interactions_slash_get_restrictions_for_authenticated_user(configuration: &configuration::Configuration, ) -> Result<models::InteractionsGetRestrictionsForOrg200Response, Error<InteractionsSlashGetRestrictionsForAuthenticatedUserError>> {
88    let local_var_configuration = configuration;
89
90    let local_var_client = &local_var_configuration.client;
91
92    let local_var_uri_str = format!("{}/user/interaction-limits", local_var_configuration.base_path);
93    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
94
95    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
96        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
97    }
98
99    let local_var_req = local_var_req_builder.build()?;
100    let local_var_resp = local_var_client.execute(local_var_req).await?;
101
102    let local_var_status = local_var_resp.status();
103    let local_var_content = local_var_resp.text().await?;
104
105    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
106        serde_json::from_str(&local_var_content).map_err(Error::from)
107    } else {
108        let local_var_entity: Option<InteractionsSlashGetRestrictionsForAuthenticatedUserError> = serde_json::from_str(&local_var_content).ok();
109        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
110        Err(Error::ResponseError(local_var_error))
111    }
112}
113
114/// Shows which type of GitHub user can interact with this organization and when the restriction expires. If there is no restrictions, you will see an empty response.
115pub async fn interactions_slash_get_restrictions_for_org(configuration: &configuration::Configuration, org: &str) -> Result<models::InteractionsGetRestrictionsForOrg200Response, Error<InteractionsSlashGetRestrictionsForOrgError>> {
116    let local_var_configuration = configuration;
117
118    let local_var_client = &local_var_configuration.client;
119
120    let local_var_uri_str = format!("{}/orgs/{org}/interaction-limits", local_var_configuration.base_path, org=crate::apis::urlencode(org));
121    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
122
123    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
124        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
125    }
126
127    let local_var_req = local_var_req_builder.build()?;
128    let local_var_resp = local_var_client.execute(local_var_req).await?;
129
130    let local_var_status = local_var_resp.status();
131    let local_var_content = local_var_resp.text().await?;
132
133    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
134        serde_json::from_str(&local_var_content).map_err(Error::from)
135    } else {
136        let local_var_entity: Option<InteractionsSlashGetRestrictionsForOrgError> = serde_json::from_str(&local_var_content).ok();
137        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
138        Err(Error::ResponseError(local_var_error))
139    }
140}
141
142/// Shows which type of GitHub user can interact with this repository and when the restriction expires. If there are no restrictions, you will see an empty response.
143pub async fn interactions_slash_get_restrictions_for_repo(configuration: &configuration::Configuration, owner: &str, repo: &str) -> Result<models::InteractionsGetRestrictionsForOrg200Response, Error<InteractionsSlashGetRestrictionsForRepoError>> {
144    let local_var_configuration = configuration;
145
146    let local_var_client = &local_var_configuration.client;
147
148    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/interaction-limits", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
149    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
150
151    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
152        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
153    }
154
155    let local_var_req = local_var_req_builder.build()?;
156    let local_var_resp = local_var_client.execute(local_var_req).await?;
157
158    let local_var_status = local_var_resp.status();
159    let local_var_content = local_var_resp.text().await?;
160
161    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
162        serde_json::from_str(&local_var_content).map_err(Error::from)
163    } else {
164        let local_var_entity: Option<InteractionsSlashGetRestrictionsForRepoError> = serde_json::from_str(&local_var_content).ok();
165        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
166        Err(Error::ResponseError(local_var_error))
167    }
168}
169
170/// Removes any interaction restrictions from your public repositories.
171pub async fn interactions_slash_remove_restrictions_for_authenticated_user(configuration: &configuration::Configuration, ) -> Result<(), Error<InteractionsSlashRemoveRestrictionsForAuthenticatedUserError>> {
172    let local_var_configuration = configuration;
173
174    let local_var_client = &local_var_configuration.client;
175
176    let local_var_uri_str = format!("{}/user/interaction-limits", local_var_configuration.base_path);
177    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
178
179    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
180        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
181    }
182
183    let local_var_req = local_var_req_builder.build()?;
184    let local_var_resp = local_var_client.execute(local_var_req).await?;
185
186    let local_var_status = local_var_resp.status();
187    let local_var_content = local_var_resp.text().await?;
188
189    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
190        Ok(())
191    } else {
192        let local_var_entity: Option<InteractionsSlashRemoveRestrictionsForAuthenticatedUserError> = serde_json::from_str(&local_var_content).ok();
193        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
194        Err(Error::ResponseError(local_var_error))
195    }
196}
197
198/// Removes all interaction restrictions from public repositories in the given organization. You must be an organization owner to remove restrictions.
199pub async fn interactions_slash_remove_restrictions_for_org(configuration: &configuration::Configuration, org: &str) -> Result<(), Error<InteractionsSlashRemoveRestrictionsForOrgError>> {
200    let local_var_configuration = configuration;
201
202    let local_var_client = &local_var_configuration.client;
203
204    let local_var_uri_str = format!("{}/orgs/{org}/interaction-limits", local_var_configuration.base_path, org=crate::apis::urlencode(org));
205    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
206
207    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
208        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
209    }
210
211    let local_var_req = local_var_req_builder.build()?;
212    let local_var_resp = local_var_client.execute(local_var_req).await?;
213
214    let local_var_status = local_var_resp.status();
215    let local_var_content = local_var_resp.text().await?;
216
217    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
218        Ok(())
219    } else {
220        let local_var_entity: Option<InteractionsSlashRemoveRestrictionsForOrgError> = serde_json::from_str(&local_var_content).ok();
221        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
222        Err(Error::ResponseError(local_var_error))
223    }
224}
225
226/// Removes all interaction restrictions from the given repository. You must have owner or admin access to remove restrictions. If the interaction limit is set for the user or organization that owns this repository, you will receive a `409 Conflict` response and will not be able to use this endpoint to change the interaction limit for a single repository.
227pub async fn interactions_slash_remove_restrictions_for_repo(configuration: &configuration::Configuration, owner: &str, repo: &str) -> Result<(), Error<InteractionsSlashRemoveRestrictionsForRepoError>> {
228    let local_var_configuration = configuration;
229
230    let local_var_client = &local_var_configuration.client;
231
232    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/interaction-limits", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
233    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
234
235    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
236        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
237    }
238
239    let local_var_req = local_var_req_builder.build()?;
240    let local_var_resp = local_var_client.execute(local_var_req).await?;
241
242    let local_var_status = local_var_resp.status();
243    let local_var_content = local_var_resp.text().await?;
244
245    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
246        Ok(())
247    } else {
248        let local_var_entity: Option<InteractionsSlashRemoveRestrictionsForRepoError> = serde_json::from_str(&local_var_content).ok();
249        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
250        Err(Error::ResponseError(local_var_error))
251    }
252}
253
254/// Temporarily restricts which type of GitHub user can interact with your public repositories. Setting the interaction limit at the user level will overwrite any interaction limits that are set for individual repositories owned by the user.
255pub async fn interactions_slash_set_restrictions_for_authenticated_user(configuration: &configuration::Configuration, interaction_limit: models::InteractionLimit) -> Result<models::InteractionLimitResponse, Error<InteractionsSlashSetRestrictionsForAuthenticatedUserError>> {
256    let local_var_configuration = configuration;
257
258    let local_var_client = &local_var_configuration.client;
259
260    let local_var_uri_str = format!("{}/user/interaction-limits", local_var_configuration.base_path);
261    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
262
263    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
264        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
265    }
266    local_var_req_builder = local_var_req_builder.json(&interaction_limit);
267
268    let local_var_req = local_var_req_builder.build()?;
269    let local_var_resp = local_var_client.execute(local_var_req).await?;
270
271    let local_var_status = local_var_resp.status();
272    let local_var_content = local_var_resp.text().await?;
273
274    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
275        serde_json::from_str(&local_var_content).map_err(Error::from)
276    } else {
277        let local_var_entity: Option<InteractionsSlashSetRestrictionsForAuthenticatedUserError> = serde_json::from_str(&local_var_content).ok();
278        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
279        Err(Error::ResponseError(local_var_error))
280    }
281}
282
283/// Temporarily restricts interactions to a certain type of GitHub user in any public repository in the given organization. You must be an organization owner to set these restrictions. Setting the interaction limit at the organization level will overwrite any interaction limits that are set for individual repositories owned by the organization.
284pub async fn interactions_slash_set_restrictions_for_org(configuration: &configuration::Configuration, org: &str, interaction_limit: models::InteractionLimit) -> Result<models::InteractionLimitResponse, Error<InteractionsSlashSetRestrictionsForOrgError>> {
285    let local_var_configuration = configuration;
286
287    let local_var_client = &local_var_configuration.client;
288
289    let local_var_uri_str = format!("{}/orgs/{org}/interaction-limits", local_var_configuration.base_path, org=crate::apis::urlencode(org));
290    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
291
292    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
293        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
294    }
295    local_var_req_builder = local_var_req_builder.json(&interaction_limit);
296
297    let local_var_req = local_var_req_builder.build()?;
298    let local_var_resp = local_var_client.execute(local_var_req).await?;
299
300    let local_var_status = local_var_resp.status();
301    let local_var_content = local_var_resp.text().await?;
302
303    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
304        serde_json::from_str(&local_var_content).map_err(Error::from)
305    } else {
306        let local_var_entity: Option<InteractionsSlashSetRestrictionsForOrgError> = serde_json::from_str(&local_var_content).ok();
307        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
308        Err(Error::ResponseError(local_var_error))
309    }
310}
311
312/// Temporarily restricts interactions to a certain type of GitHub user within the given repository. You must have owner or admin access to set these restrictions. If an interaction limit is set for the user or organization that owns this repository, you will receive a `409 Conflict` response and will not be able to use this endpoint to change the interaction limit for a single repository.
313pub async fn interactions_slash_set_restrictions_for_repo(configuration: &configuration::Configuration, owner: &str, repo: &str, interaction_limit: models::InteractionLimit) -> Result<models::InteractionLimitResponse, Error<InteractionsSlashSetRestrictionsForRepoError>> {
314    let local_var_configuration = configuration;
315
316    let local_var_client = &local_var_configuration.client;
317
318    let local_var_uri_str = format!("{}/repos/{owner}/{repo}/interaction-limits", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
319    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
320
321    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
322        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
323    }
324    local_var_req_builder = local_var_req_builder.json(&interaction_limit);
325
326    let local_var_req = local_var_req_builder.build()?;
327    let local_var_resp = local_var_client.execute(local_var_req).await?;
328
329    let local_var_status = local_var_resp.status();
330    let local_var_content = local_var_resp.text().await?;
331
332    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
333        serde_json::from_str(&local_var_content).map_err(Error::from)
334    } else {
335        let local_var_entity: Option<InteractionsSlashSetRestrictionsForRepoError> = serde_json::from_str(&local_var_content).ok();
336        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
337        Err(Error::ResponseError(local_var_error))
338    }
339}
340