openapi_github/apis/rate_limit_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 [`rate_limit_slash_get`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum RateLimitSlashGetError {
22 Status404(models::BasicError),
23 UnknownValue(serde_json::Value),
24}
25
26
27/// **Note:** Accessing this endpoint does not count against your REST API rate limit. Some categories of endpoints have custom rate limits that are separate from the rate limit governing the other REST API endpoints. For this reason, the API response categorizes your rate limit. Under `resources`, you'll see objects relating to different categories: * The `core` object provides your rate limit status for all non-search-related resources in the REST API. * The `search` object provides your rate limit status for the REST API for searching (excluding code searches). For more information, see \"[Search](https://docs.github.com/rest/search/search).\" * The `code_search` object provides your rate limit status for the REST API for searching code. For more information, see \"[Search code](https://docs.github.com/rest/search/search#search-code).\" * The `graphql` object provides your rate limit status for the GraphQL API. For more information, see \"[Resource limitations](https://docs.github.com/graphql/overview/resource-limitations#rate-limit).\" * The `integration_manifest` object provides your rate limit status for the `POST /app-manifests/{code}/conversions` operation. For more information, see \"[Creating a GitHub App from a manifest](https://docs.github.com/apps/creating-github-apps/setting-up-a-github-app/creating-a-github-app-from-a-manifest#3-you-exchange-the-temporary-code-to-retrieve-the-app-configuration).\" * The `dependency_snapshots` object provides your rate limit status for submitting snapshots to the dependency graph. For more information, see \"[Dependency graph](https://docs.github.com/rest/dependency-graph).\" * The `code_scanning_upload` object provides your rate limit status for uploading SARIF results to code scanning. For more information, see \"[Uploading a SARIF file to GitHub](https://docs.github.com/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github).\" * The `actions_runner_registration` object provides your rate limit status for registering self-hosted runners in GitHub Actions. For more information, see \"[Self-hosted runners](https://docs.github.com/rest/actions/self-hosted-runners).\" * The `source_import` object is no longer in use for any API endpoints, and it will be removed in the next API version. For more information about API versions, see \"[API Versions](https://docs.github.com/rest/overview/api-versions).\" **Note:** The `rate` object is deprecated. If you're writing new API client code or updating existing code, you should use the `core` object instead of the `rate` object. The `core` object contains the same information that is present in the `rate` object.
28pub async fn rate_limit_slash_get(configuration: &configuration::Configuration, ) -> Result<models::RateLimitOverview, Error<RateLimitSlashGetError>> {
29 let local_var_configuration = configuration;
30
31 let local_var_client = &local_var_configuration.client;
32
33 let local_var_uri_str = format!("{}/rate_limit", local_var_configuration.base_path);
34 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
35
36 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
37 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
38 }
39
40 let local_var_req = local_var_req_builder.build()?;
41 let local_var_resp = local_var_client.execute(local_var_req).await?;
42
43 let local_var_status = local_var_resp.status();
44 let local_var_content = local_var_resp.text().await?;
45
46 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
47 serde_json::from_str(&local_var_content).map_err(Error::from)
48 } else {
49 let local_var_entity: Option<RateLimitSlashGetError> = serde_json::from_str(&local_var_content).ok();
50 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
51 Err(Error::ResponseError(local_var_error))
52 }
53}
54