openapi_github/apis/
meta_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 [`meta_slash_get`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum MetaSlashGetError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`meta_slash_get_all_versions`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum MetaSlashGetAllVersionsError {
29    Status404(models::BasicError),
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`meta_slash_get_octocat`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum MetaSlashGetOctocatError {
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`meta_slash_get_zen`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum MetaSlashGetZenError {
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`meta_slash_root`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum MetaSlashRootError {
51    UnknownValue(serde_json::Value),
52}
53
54
55/// Returns meta information about GitHub, including a list of GitHub's IP addresses. For more information, see \"[About GitHub's IP addresses](https://docs.github.com/articles/about-github-s-ip-addresses/).\"  The API's response also includes a list of GitHub's domain names.  The values shown in the documentation's response are example values. You must always query the API directly to get the latest values.  **Note:** This endpoint returns both IPv4 and IPv6 addresses. However, not all features support IPv6. You should refer to the specific documentation for each feature to determine if IPv6 is supported.
56pub async fn meta_slash_get(configuration: &configuration::Configuration, ) -> Result<models::ApiOverview, Error<MetaSlashGetError>> {
57    let local_var_configuration = configuration;
58
59    let local_var_client = &local_var_configuration.client;
60
61    let local_var_uri_str = format!("{}/meta", local_var_configuration.base_path);
62    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
63
64    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
65        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
66    }
67
68    let local_var_req = local_var_req_builder.build()?;
69    let local_var_resp = local_var_client.execute(local_var_req).await?;
70
71    let local_var_status = local_var_resp.status();
72    let local_var_content = local_var_resp.text().await?;
73
74    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
75        serde_json::from_str(&local_var_content).map_err(Error::from)
76    } else {
77        let local_var_entity: Option<MetaSlashGetError> = serde_json::from_str(&local_var_content).ok();
78        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
79        Err(Error::ResponseError(local_var_error))
80    }
81}
82
83/// Get all supported GitHub API versions.
84pub async fn meta_slash_get_all_versions(configuration: &configuration::Configuration, ) -> Result<Vec<String>, Error<MetaSlashGetAllVersionsError>> {
85    let local_var_configuration = configuration;
86
87    let local_var_client = &local_var_configuration.client;
88
89    let local_var_uri_str = format!("{}/versions", local_var_configuration.base_path);
90    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
91
92    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
93        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
94    }
95
96    let local_var_req = local_var_req_builder.build()?;
97    let local_var_resp = local_var_client.execute(local_var_req).await?;
98
99    let local_var_status = local_var_resp.status();
100    let local_var_content = local_var_resp.text().await?;
101
102    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
103        serde_json::from_str(&local_var_content).map_err(Error::from)
104    } else {
105        let local_var_entity: Option<MetaSlashGetAllVersionsError> = serde_json::from_str(&local_var_content).ok();
106        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
107        Err(Error::ResponseError(local_var_error))
108    }
109}
110
111/// Get the octocat as ASCII art
112pub async fn meta_slash_get_octocat(configuration: &configuration::Configuration, s: Option<&str>) -> Result<String, Error<MetaSlashGetOctocatError>> {
113    let local_var_configuration = configuration;
114
115    let local_var_client = &local_var_configuration.client;
116
117    let local_var_uri_str = format!("{}/octocat", local_var_configuration.base_path);
118    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
119
120    if let Some(ref local_var_str) = s {
121        local_var_req_builder = local_var_req_builder.query(&[("s", &local_var_str.to_string())]);
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<MetaSlashGetOctocatError> = 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/// Get a random sentence from the Zen of GitHub
143pub async fn meta_slash_get_zen(configuration: &configuration::Configuration, ) -> Result<String, Error<MetaSlashGetZenError>> {
144    let local_var_configuration = configuration;
145
146    let local_var_client = &local_var_configuration.client;
147
148    let local_var_uri_str = format!("{}/zen", local_var_configuration.base_path);
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<MetaSlashGetZenError> = 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/// Get Hypermedia links to resources accessible in GitHub's REST API
171pub async fn meta_slash_root(configuration: &configuration::Configuration, ) -> Result<models::Root, Error<MetaSlashRootError>> {
172    let local_var_configuration = configuration;
173
174    let local_var_client = &local_var_configuration.client;
175
176    let local_var_uri_str = format!("{}/", local_var_configuration.base_path);
177    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, 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        serde_json::from_str(&local_var_content).map_err(Error::from)
191    } else {
192        let local_var_entity: Option<MetaSlashRootError> = 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