openapi_github/apis/
billing_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 [`billing_slash_get_github_actions_billing_org`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BillingSlashGetGithubActionsBillingOrgError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`billing_slash_get_github_actions_billing_user`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum BillingSlashGetGithubActionsBillingUserError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`billing_slash_get_github_packages_billing_org`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum BillingSlashGetGithubPackagesBillingOrgError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`billing_slash_get_github_packages_billing_user`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum BillingSlashGetGithubPackagesBillingUserError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`billing_slash_get_shared_storage_billing_org`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum BillingSlashGetSharedStorageBillingOrgError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`billing_slash_get_shared_storage_billing_user`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum BillingSlashGetSharedStorageBillingUserError {
57    UnknownValue(serde_json::Value),
58}
59
60
61/// Gets the summary of the free and paid GitHub Actions minutes used.  Paid minutes only apply to workflows in private repositories that use GitHub-hosted runners. Minutes used is listed for each GitHub-hosted runner operating system. Any job re-runs are also included in the usage. The usage returned includes any minute multipliers for macOS and Windows runners, and is rounded up to the nearest whole minute. For more information, see \"[Managing billing for GitHub Actions](https://docs.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-actions)\".  OAuth app tokens and personal access tokens (classic) need the `repo` or `admin:org` scope to use this endpoint.
62pub async fn billing_slash_get_github_actions_billing_org(configuration: &configuration::Configuration, org: &str) -> Result<models::ActionsBillingUsage, Error<BillingSlashGetGithubActionsBillingOrgError>> {
63    let local_var_configuration = configuration;
64
65    let local_var_client = &local_var_configuration.client;
66
67    let local_var_uri_str = format!("{}/orgs/{org}/settings/billing/actions", local_var_configuration.base_path, org=crate::apis::urlencode(org));
68    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
69
70    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
71        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
72    }
73
74    let local_var_req = local_var_req_builder.build()?;
75    let local_var_resp = local_var_client.execute(local_var_req).await?;
76
77    let local_var_status = local_var_resp.status();
78    let local_var_content = local_var_resp.text().await?;
79
80    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
81        serde_json::from_str(&local_var_content).map_err(Error::from)
82    } else {
83        let local_var_entity: Option<BillingSlashGetGithubActionsBillingOrgError> = serde_json::from_str(&local_var_content).ok();
84        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
85        Err(Error::ResponseError(local_var_error))
86    }
87}
88
89/// Gets the summary of the free and paid GitHub Actions minutes used.  Paid minutes only apply to workflows in private repositories that use GitHub-hosted runners. Minutes used is listed for each GitHub-hosted runner operating system. Any job re-runs are also included in the usage. The usage returned includes any minute multipliers for macOS and Windows runners, and is rounded up to the nearest whole minute. For more information, see \"[Managing billing for GitHub Actions](https://docs.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-actions)\".  OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
90pub async fn billing_slash_get_github_actions_billing_user(configuration: &configuration::Configuration, username: &str) -> Result<models::ActionsBillingUsage, Error<BillingSlashGetGithubActionsBillingUserError>> {
91    let local_var_configuration = configuration;
92
93    let local_var_client = &local_var_configuration.client;
94
95    let local_var_uri_str = format!("{}/users/{username}/settings/billing/actions", local_var_configuration.base_path, username=crate::apis::urlencode(username));
96    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
97
98    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
99        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
100    }
101
102    let local_var_req = local_var_req_builder.build()?;
103    let local_var_resp = local_var_client.execute(local_var_req).await?;
104
105    let local_var_status = local_var_resp.status();
106    let local_var_content = local_var_resp.text().await?;
107
108    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
109        serde_json::from_str(&local_var_content).map_err(Error::from)
110    } else {
111        let local_var_entity: Option<BillingSlashGetGithubActionsBillingUserError> = serde_json::from_str(&local_var_content).ok();
112        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
113        Err(Error::ResponseError(local_var_error))
114    }
115}
116
117/// Gets the free and paid storage used for GitHub Packages in gigabytes.  Paid minutes only apply to packages stored for private repositories. For more information, see \"[Managing billing for GitHub Packages](https://docs.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages).\"  OAuth app tokens and personal access tokens (classic) need the `repo` or `admin:org` scope to use this endpoint.
118pub async fn billing_slash_get_github_packages_billing_org(configuration: &configuration::Configuration, org: &str) -> Result<models::PackagesBillingUsage, Error<BillingSlashGetGithubPackagesBillingOrgError>> {
119    let local_var_configuration = configuration;
120
121    let local_var_client = &local_var_configuration.client;
122
123    let local_var_uri_str = format!("{}/orgs/{org}/settings/billing/packages", local_var_configuration.base_path, org=crate::apis::urlencode(org));
124    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
125
126    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
127        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
128    }
129
130    let local_var_req = local_var_req_builder.build()?;
131    let local_var_resp = local_var_client.execute(local_var_req).await?;
132
133    let local_var_status = local_var_resp.status();
134    let local_var_content = local_var_resp.text().await?;
135
136    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
137        serde_json::from_str(&local_var_content).map_err(Error::from)
138    } else {
139        let local_var_entity: Option<BillingSlashGetGithubPackagesBillingOrgError> = serde_json::from_str(&local_var_content).ok();
140        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
141        Err(Error::ResponseError(local_var_error))
142    }
143}
144
145/// Gets the free and paid storage used for GitHub Packages in gigabytes.  Paid minutes only apply to packages stored for private repositories. For more information, see \"[Managing billing for GitHub Packages](https://docs.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages).\"  OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
146pub async fn billing_slash_get_github_packages_billing_user(configuration: &configuration::Configuration, username: &str) -> Result<models::PackagesBillingUsage, Error<BillingSlashGetGithubPackagesBillingUserError>> {
147    let local_var_configuration = configuration;
148
149    let local_var_client = &local_var_configuration.client;
150
151    let local_var_uri_str = format!("{}/users/{username}/settings/billing/packages", local_var_configuration.base_path, username=crate::apis::urlencode(username));
152    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
153
154    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
155        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
156    }
157
158    let local_var_req = local_var_req_builder.build()?;
159    let local_var_resp = local_var_client.execute(local_var_req).await?;
160
161    let local_var_status = local_var_resp.status();
162    let local_var_content = local_var_resp.text().await?;
163
164    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
165        serde_json::from_str(&local_var_content).map_err(Error::from)
166    } else {
167        let local_var_entity: Option<BillingSlashGetGithubPackagesBillingUserError> = serde_json::from_str(&local_var_content).ok();
168        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
169        Err(Error::ResponseError(local_var_error))
170    }
171}
172
173/// Gets the estimated paid and estimated total storage used for GitHub Actions and GitHub Packages.  Paid minutes only apply to packages stored for private repositories. For more information, see \"[Managing billing for GitHub Packages](https://docs.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages).\"  OAuth app tokens and personal access tokens (classic) need the `repo` or `admin:org` scope to use this endpoint.
174pub async fn billing_slash_get_shared_storage_billing_org(configuration: &configuration::Configuration, org: &str) -> Result<models::CombinedBillingUsage, Error<BillingSlashGetSharedStorageBillingOrgError>> {
175    let local_var_configuration = configuration;
176
177    let local_var_client = &local_var_configuration.client;
178
179    let local_var_uri_str = format!("{}/orgs/{org}/settings/billing/shared-storage", local_var_configuration.base_path, org=crate::apis::urlencode(org));
180    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
181
182    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
183        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
184    }
185
186    let local_var_req = local_var_req_builder.build()?;
187    let local_var_resp = local_var_client.execute(local_var_req).await?;
188
189    let local_var_status = local_var_resp.status();
190    let local_var_content = local_var_resp.text().await?;
191
192    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
193        serde_json::from_str(&local_var_content).map_err(Error::from)
194    } else {
195        let local_var_entity: Option<BillingSlashGetSharedStorageBillingOrgError> = serde_json::from_str(&local_var_content).ok();
196        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
197        Err(Error::ResponseError(local_var_error))
198    }
199}
200
201/// Gets the estimated paid and estimated total storage used for GitHub Actions and GitHub Packages.  Paid minutes only apply to packages stored for private repositories. For more information, see \"[Managing billing for GitHub Packages](https://docs.github.com/github/setting-up-and-managing-billing-and-payments-on-github/managing-billing-for-github-packages).\"  OAuth app tokens and personal access tokens (classic) need the `user` scope to use this endpoint.
202pub async fn billing_slash_get_shared_storage_billing_user(configuration: &configuration::Configuration, username: &str) -> Result<models::CombinedBillingUsage, Error<BillingSlashGetSharedStorageBillingUserError>> {
203    let local_var_configuration = configuration;
204
205    let local_var_client = &local_var_configuration.client;
206
207    let local_var_uri_str = format!("{}/users/{username}/settings/billing/shared-storage", local_var_configuration.base_path, username=crate::apis::urlencode(username));
208    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
209
210    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
211        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
212    }
213
214    let local_var_req = local_var_req_builder.build()?;
215    let local_var_resp = local_var_client.execute(local_var_req).await?;
216
217    let local_var_status = local_var_resp.status();
218    let local_var_content = local_var_resp.text().await?;
219
220    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
221        serde_json::from_str(&local_var_content).map_err(Error::from)
222    } else {
223        let local_var_entity: Option<BillingSlashGetSharedStorageBillingUserError> = serde_json::from_str(&local_var_content).ok();
224        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
225        Err(Error::ResponseError(local_var_error))
226    }
227}
228