23 Commits

Author SHA1 Message Date
431db65471 Add basic example 2025-06-03 19:45:31 -03:00
7cbe6e451d Add wrapper struct 2025-06-03 19:45:24 -03:00
0b32ab460c Generate api client with openapi-generator 2025-06-03 19:09:41 -03:00
Guilherme Werner
e701f20c1a Delete rust.yml 2024-01-24 21:11:32 -03:00
Guilherme Werner
7c2ce3bcb6 Update rust.yml 2024-01-24 20:12:55 -03:00
Guilherme Werner
bff0dc0344 Create rust.yml 2024-01-24 20:10:38 -03:00
Guilherme Werner
d9c4c40749 Update lib.rs 2024-01-12 16:26:46 -03:00
Guilherme Werner
9861f51733 Update lib.rs 2024-01-12 15:55:52 -03:00
Guilherme Werner
890c899a8b Create servers.rs 2024-01-12 15:55:50 -03:00
Guilherme Werner
0168cd14e7 Update users.rs 2024-01-12 15:55:49 -03:00
Guilherme Werner
d29a5f6216 Update readme and license 2023-12-31 16:22:35 -03:00
Guilherme Werner
a2dec0eaa5 Update README.md 2023-12-31 15:47:33 -03:00
Guilherme Werner
b583d26e44 Fix readme 2023-12-31 15:32:36 -03:00
Guilherme Werner
40a5cd78f8 Update Cargo.toml 2023-12-31 15:31:27 -03:00
Guilherme Werner
8947084800 Update Cargo.toml 2023-12-31 15:31:11 -03:00
Guilherme Werner
f702516ad1 Update publish.ps1 2023-12-31 15:30:11 -03:00
Guilherme Werner
ddca33b5ee Bump versions to 0.1.0 2023-12-31 15:29:57 -03:00
Guilherme Werner
7e8c8d1d4c Create publish.ps1 2023-12-31 15:29:32 -03:00
Guilherme Werner
f1219f0fa3 Update lib.rs 2023-12-31 15:28:35 -03:00
Guilherme Werner
a7d4bc3fe3 Update lib.rs 2023-12-31 15:28:34 -03:00
Guilherme Werner
f63f64103c Create initial api wrapper (#2)
* Api v0.1?

* Split crates

* Update api
2023-12-31 15:26:24 -03:00
Guilherme Werner
21daa668f8 Prototype API (#1)
* Add oauth2 client

* Update LICENSE.txt

* Create .env.example

* Add dotenv to example

* Add oauth2 types

* Update lib.rs

* Update Cargo.toml

* Update lib.rs

* Add games routes
2023-12-24 08:23:10 -03:00
Guilherme Werner
92d5adc03b Update README.md 2023-12-03 10:31:21 -03:00
65 changed files with 6971 additions and 620 deletions

View File

@@ -1,3 +1,2 @@
CLIENT_ID=
CLIENT_SECRET=
TRIBUFU_API_URL=https://api.tribufu.com
TRIBUFU_API_KEY=""
TRIBUFU_API_URL="https://api.tribufu.com"

View File

@@ -0,0 +1,8 @@
docs/
.gitignore
.travis.yml
Cargo.toml
git_push.sh
README.md
src/lib.rs

46
.openapi-generator/FILES Normal file
View File

@@ -0,0 +1,46 @@
src/apis/configuration.rs
src/apis/mod.rs
src/apis/tribufu_generated_api.rs
src/models/account.rs
src/models/application.rs
src/models/application_type.rs
src/models/authorize_request.rs
src/models/code_challenge_method.rs
src/models/crypto_view_model.rs
src/models/game.rs
src/models/game_server.rs
src/models/game_server_cluster.rs
src/models/grant_type.rs
src/models/group.rs
src/models/group_game.rs
src/models/group_member.rs
src/models/group_rank.rs
src/models/hash_view_model.rs
src/models/introspect_request.rs
src/models/ip_address.rs
src/models/leaderboard_item.rs
src/models/leaderboard_order.rs
src/models/login_provider.rs
src/models/login_request.rs
src/models/login_response.rs
src/models/mod.rs
src/models/package.rs
src/models/profile.rs
src/models/profile_game.rs
src/models/profile_group.rs
src/models/refresh_request.rs
src/models/register_request.rs
src/models/response_type.rs
src/models/revoke_request.rs
src/models/search_request.rs
src/models/search_type.rs
src/models/server_metrics.rs
src/models/server_status.rs
src/models/subscription.rs
src/models/token_hint_type.rs
src/models/token_request.rs
src/models/token_response.rs
src/models/token_type.rs
src/models/update_profile.rs
src/models/user_info.rs
src/models/user_type.rs

View File

@@ -0,0 +1 @@
7.12.0

View File

@@ -1,15 +1,26 @@
[package]
name = "tribufu"
version = "0.0.4"
description = "Tribufu SDK"
repository = "https://github.com/Tribufu/SDK-Rust"
version = "1.1.0"
description = "REST API to access Tribufu services."
repository = "https://github.com/tribufu/tribufu-rust"
authors = ["Tribufu <contact@tribufu.com>"]
license = "Apache-2.0"
license = "MIT"
readme = "README.md"
edition = "2021"
publish = true
exclude = [".github/", ".vscode/", ".editorconfig", ".gitattributes"]
exclude = [
".editorconfig",
".env*",
".gitattributes",
".github/",
".openapi-generator-ignore",
".openapi-generator/",
".vscode/",
"examples/",
"scripts/",
"scripts/",
]
[lib]
name = "tribufu"
@@ -17,15 +28,19 @@ crate-type = ["rlib"]
path = "src/lib.rs"
[dependencies]
alnilam-consts = { version = "0.0.4" }
anyhow = "1.0.75"
chrono = { version = "0.4.22", features = ["serde", "rustc-serialize"] }
derive_more = "0.99.17"
reqwest = { version = "0.11.18", features = ["json", "stream"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
serde_with = "3.4.0"
async-trait = "^0.1"
reqwest = { version = "^0.12", features = ["json", "multipart"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
serde_with = { version = "^3.8", default-features = false, features = [
"base64",
"std",
"macros",
] }
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
[dev-dependencies]
dotenv = "0.15.0"
tokio = { version = "1", features = ["full"] }
tokio = { version = "1.45.1", features = ["full"] }

View File

@@ -1,201 +1,21 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
MIT License
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
Copyright (c) Tribufu. All Rights Reserved.
1. Definitions.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright (c) Tribufu. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1 +1,23 @@
# Rust SDK
# Tribufu Rust
Rust SDK to access Tribufu APIs and services.
[![Crates.io][crates-badge]][crates-url]
[![MIT License][mit-badge]][mit-url]
[![Discord Chat][discord-badge]][discord-url]
[crates-badge]: https://img.shields.io/crates/v/tribufu.svg
[crates-url]: https://crates.io/crates/tribufu
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[mit-url]: https://github.com/Tribufu/TribufuRust/blob/main/LICENSE.txt
[discord-badge]: https://img.shields.io/discord/276504514616623104.svg?logo=discord&style=flat-square
[discord-url]: https://www.tribufu.com/discord
[Website](https://www.tribufu.com) |
[Discord](https://www.tribufu.com/discord)
## License
This project is licensed under the [MIT License].
[MIT License]: https://github.com/Tribufu/TribufuRust/blob/main/LICENSE.txt

14
examples/api.rs Normal file
View File

@@ -0,0 +1,14 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
use dotenv::dotenv;
use tribufu::apis::tribufu_generated_api::TribufuGeneratedApi;
use tribufu::TribufuApi;
#[tokio::main]
async fn main() {
dotenv().unwrap();
let tribufu = TribufuApi::from_env_or_default(None);
let user_info = tribufu.get_user_info().await.unwrap();
println!("{:?}", user_info);
}

View File

@@ -1,11 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved
use tribufu::*;
#[tokio::main]
async fn main() {
match TribufuClient::new(0, "client_secret") {
Ok(client) => println!("client_id: {}", client.id()),
Err(e) => println!("error: {:?}", e),
}
}

View File

@@ -1,23 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved
use dotenv::dotenv;
use std::env;
use tribufu::*;
#[tokio::main]
async fn main() {
dotenv().ok();
let client_id = env::var("CLIENT_ID").unwrap().parse::<u64>().unwrap();
let client_secret = env::var("CLIENT_SECRET").unwrap();
let mut client = TribufuClient::new(client_id, client_secret).unwrap();
client.get_token(None).await.unwrap();
let games = client.get_games().await.unwrap();
games.iter().for_each(|game| {
println!("{}", game.name);
});
}

10
scripts/generate.ps1 Normal file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env pwsh
java -jar ./vendor/openapi-generator/openapi-generator-cli.jar generate `
-i https://api.tribufu.com/openapi.json `
-g rust `
-o . `
--global-property apis,models,supportingFiles,apiDocs=false,modelDocs=false,apiTests=false,modelTests=false `
--additional-properties=packageName=tribufu,library=reqwest-trait,supportAsync=true,preferUnsignedInt=true `
--openapi-normalizer SET_TAGS_FOR_ALL_OPERATIONS=TribufuGenerated `
--skip-validate-spec

34
scripts/publish.ps1 Normal file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env pwsh
$crates = @(
"tribufu-types",
"tribufu-constants",
"tribufu-api",
"tribufu"
)
$batchSize = 6
$waitTime = 300
function Process-Batch {
param (
[Parameter(Mandatory=$true)]
[array]$batch
)
foreach ($element in $batch) {
Write-Output "Processing element $element"
cargo publish --package $element
}
}
for ($i = 0; $i -lt $crates.Count; $i += $batchSize) {
$currentBatch = $crates[$i..($i + $batchSize - 1)]
Process-Batch -batch $currentBatch
if ($i -lt ($crates.Count - $batchSize)) {
Write-Output "Waiting for $waitTime seconds..."
Start-Sleep -Seconds $waitTime
}
}

51
src/apis/configuration.rs Normal file
View File

@@ -0,0 +1,51 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
#[derive(Debug, Clone)]
pub struct Configuration {
pub base_path: String,
pub user_agent: Option<String>,
pub client: reqwest::Client,
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
}
pub type BasicAuth = (String, Option<String>);
#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}
impl Configuration {
pub fn new() -> Configuration {
Configuration::default()
}
}
impl Default for Configuration {
fn default() -> Self {
Configuration {
base_path: "http://localhost".to_owned(),
user_agent: Some("OpenAPI-Generator/1.1.0/rust".to_owned()),
client: reqwest::Client::new(),
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
}
}
}

117
src/apis/mod.rs Normal file
View File

@@ -0,0 +1,117 @@
use std::error;
use std::fmt;
#[derive(Debug, Clone)]
pub struct ResponseContent<T> {
pub status: reqwest::StatusCode,
pub content: String,
pub entity: Option<T>,
}
#[derive(Debug)]
pub enum Error<T> {
Reqwest(reqwest::Error),
Serde(serde_json::Error),
Io(std::io::Error),
ResponseError(ResponseContent<T>),
}
impl <T> fmt::Display for Error<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (module, e) = match self {
Error::Reqwest(e) => ("reqwest", e.to_string()),
Error::Serde(e) => ("serde", e.to_string()),
Error::Io(e) => ("IO", e.to_string()),
Error::ResponseError(e) => ("response", format!("status code {}", e.status)),
};
write!(f, "error in {}: {}", module, e)
}
}
impl <T: fmt::Debug> error::Error for Error<T> {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
Some(match self {
Error::Reqwest(e) => e,
Error::Serde(e) => e,
Error::Io(e) => e,
Error::ResponseError(_) => return None,
})
}
}
impl <T> From<reqwest::Error> for Error<T> {
fn from(e: reqwest::Error) -> Self {
Error::Reqwest(e)
}
}
impl <T> From<serde_json::Error> for Error<T> {
fn from(e: serde_json::Error) -> Self {
Error::Serde(e)
}
}
impl <T> From<std::io::Error> for Error<T> {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
}
pub fn urlencode<T: AsRef<str>>(s: T) -> String {
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
}
pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
if let serde_json::Value::Object(object) = value {
let mut params = vec![];
for (key, value) in object {
match value {
serde_json::Value::Object(_) => params.append(&mut parse_deep_object(
&format!("{}[{}]", prefix, key),
value,
)),
serde_json::Value::Array(array) => {
for (i, value) in array.iter().enumerate() {
params.append(&mut parse_deep_object(
&format!("{}[{}][{}]", prefix, key, i),
value,
));
}
},
serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())),
_ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
}
}
return params;
}
unimplemented!("Only objects are supported with style=deepObject")
}
/// Internal use only
/// A content type supported by this client.
#[allow(dead_code)]
enum ContentType {
Json,
Text,
Unsupported(String)
}
impl From<&str> for ContentType {
fn from(content_type: &str) -> Self {
if content_type.starts_with("application") && content_type.contains("json") {
return Self::Json;
} else if content_type.starts_with("text/plain") {
return Self::Text;
} else {
return Self::Unsupported(content_type.to_string());
}
}
}
pub mod tribufu_generated_api;
pub mod configuration;

File diff suppressed because it is too large Load Diff

View File

@@ -1,171 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
use crate::games::Game;
use crate::oauth2::*;
use crate::VERSION;
use alnilam_consts::TARGET_TRIPLE;
use anyhow::{Error, Result};
use reqwest::header;
use reqwest::header::{HeaderMap, HeaderValue};
use reqwest::Client;
#[derive(Clone)]
pub struct TribufuClient {
client_id: u64,
client_secret: String,
token: Option<OAuth2TokenResponse>,
}
impl TribufuClient {
//const BASE_URL: &'static str = "https://api.tribufu.com";
const BASE_URL: &'static str = "http://localhost:5000";
pub fn new(id: u64, secret: impl Into<String>) -> Result<TribufuClient> {
Ok(TribufuClient {
client_id: id,
client_secret: secret.into(),
token: None,
})
}
#[inline]
pub fn id(&self) -> u64 {
self.client_id
}
#[inline]
pub fn user_agent() -> String {
format!(
"Tribufu/{} (+https://api.tribufu.com; {})",
VERSION, TARGET_TRIPLE
)
}
#[inline]
fn default_headers() -> HeaderMap {
let mut headers = HeaderMap::new();
headers.insert("X-Tribufu-Language", HeaderValue::from_static("rust"));
headers.insert("X-Tribufu-Version", HeaderValue::from_static(VERSION));
headers
}
fn http_client(&self) -> Result<Client> {
let user_agent = Self::user_agent();
let mut headers = Self::default_headers();
if let Some(token) = &self.token {
headers.insert(
header::AUTHORIZATION,
HeaderValue::from_str(&format!("Bearer {}", token.access_token))?,
);
}
let http = Client::builder()
.user_agent(user_agent)
.default_headers(headers)
.build()?;
Ok(http)
}
pub async fn get_token(&mut self, server_id: Option<u64>) -> Result<()> {
let server_id = if let Some(server_id) = server_id {
Some(server_id.to_string())
} else {
None
};
let body = OAuth2TokenRequest {
grant_type: OAuth2GrantType::ClientCredentials,
code: None,
refresh_token: None,
username: None,
password: None,
client_id: Some(self.client_id.to_string()),
client_secret: Some(self.client_secret.clone()),
redirect_uri: None,
server_id,
};
let url = format!("{}/v1/oauth2/token", Self::BASE_URL);
let response = self.http_client()?.post(url).form(&body).send().await?;
if response.status() != 200 {
return Err(Error::msg(format!(
"Failed to get token: {}",
response.status()
)));
}
self.token = Some(response.json().await?);
Ok(())
}
pub async fn refresh_token_token(&mut self) -> Result<()> {
let token = if let Some(token) = &self.token {
token
} else {
return Err(Error::msg(
format!("Failed to refresh: self.token == None",),
));
};
if token.refresh_token.is_none() {
return Err(Error::msg(format!(
"Failed to refresh: self.token.refresh_token == None",
)));
}
let body = OAuth2TokenRequest {
grant_type: OAuth2GrantType::RefreshToken,
code: None,
refresh_token: token.refresh_token.clone(),
username: None,
password: None,
client_id: Some(self.client_id.to_string()),
client_secret: Some(self.client_secret.clone()),
redirect_uri: None,
server_id: None,
};
let url = format!("{}/v1/oauth2/token", Self::BASE_URL);
let response = self.http_client()?.post(url).form(&body).send().await?;
if response.status() != 200 {
return Err(Error::msg(format!(
"Failed to get token: {}",
response.status()
)));
}
self.token = Some(response.json().await?);
Ok(())
}
pub async fn get_games(&self) -> Result<Vec<Game>> {
let url = format!("{}/v1/packages", Self::BASE_URL);
let response = self.http_client()?.get(url).send().await?;
Ok(response.json().await?)
}
pub async fn get_game(&self, id: u64) -> Result<Game> {
let url = format!("{}/v1/packages/{}", Self::BASE_URL, id);
let response = self.http_client()?.get(url).send().await?;
Ok(response.json().await?)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_client() {
let client = TribufuClient::new(0, "client_secret").unwrap();
assert_eq!(client.id(), 0);
}
}

View File

@@ -1,29 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
#[serde_as]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Game {
#[serde_as(as = "DisplayFromStr")]
pub id: u64,
pub name: String,
pub description: Option<String>,
pub icon_url: Option<String>,
pub banner_url: Option<String>,
pub capsule_image_url: Option<String>,
pub library_image_url: Option<String>,
pub slug: Option<String>,
pub game_port: Option<u16>,
pub query_port: Option<u16>,
pub rcon_port: Option<u16>,
pub steam_app_id: Option<u32>,
pub steam_server_app_id: Option<u32>,
pub rust_gamedig_id: Option<String>,
pub node_gamedig_id: Option<String>,
pub server_connect_url: Option<String>,
pub created: NaiveDateTime,
pub updated: Option<NaiveDateTime>,
}

View File

@@ -1,12 +1,111 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
use crate::apis::configuration::{ApiKey, Configuration};
use crate::apis::tribufu_generated_api::TribufuGeneratedApiClient;
use reqwest::Client;
use std::env::{self, consts};
use std::sync::Arc;
pub mod client;
pub mod games;
pub mod oauth2;
pub mod token;
pub mod apis;
pub mod models;
pub use client::*;
/// Use this to interact with the Tribufu API.
pub struct TribufuApi;
impl TribufuApi {
/// The default base URL for the Tribufu API.
pub const DEFAULT_BASE_URL: &'static str = "https://api.tribufu.com";
/// Create a TribufuApi instance.
pub fn new(api_key: Option<String>) -> TribufuGeneratedApiClient {
let configuration = Self::create_configuration(api_key);
let configuration_arc = Arc::new(configuration);
TribufuGeneratedApiClient::new(configuration_arc)
}
/// Create a TribufuApi with the default options.
pub fn default() -> TribufuGeneratedApiClient {
Self::new(None)
}
/// Create a TribufuApi with the given API key.
///
/// An API key gives you public read only access to the Tribufu API.
pub fn with_api_key(api_key: String) -> TribufuGeneratedApiClient {
Self::new(Some(api_key))
}
/// Try to create a TribufuApi from environment variables.
///
/// This will only work if the environment variables are set.
pub fn from_env(prefix: Option<&str>) -> Option<TribufuGeneratedApiClient> {
let prefix = prefix.unwrap_or("TRIBUFU");
let api_key_var = format!("{}_API_KEY", prefix);
if let Ok(api_key) = env::var(api_key_var) {
if !api_key.trim().is_empty() {
return Some(Self::with_api_key(api_key));
}
}
None
}
/// Create a TribufuApi from environment variables or the default API.
///
/// This will fallback to the default API if the environment variables are not set.
pub fn from_env_or_default(prefix: Option<&str>) -> TribufuGeneratedApiClient {
Self::from_env(prefix).unwrap_or_else(Self::default)
}
/// Gets the version of the Tribufu API client.
pub fn get_version() -> String {
env!("CARGO_PKG_VERSION").to_owned()
}
/// Gets the user agent string for the Tribufu API client.
pub fn get_user_agent() -> String {
let version = Self::get_version();
format!("Tribufu/{} ({}; {})", version, consts::OS, consts::ARCH)
}
/// Checks if debug mode is enabled.
pub fn debug_enabled() -> bool {
cfg!(debug_assertions)
}
/// Get the base URL for the Tribufu API.
fn get_base_url() -> String {
if let Ok(base_url) = env::var("TRIBUFU_API_URL") {
if Self::debug_enabled() && !base_url.trim().is_empty() {
return base_url;
}
}
Self::DEFAULT_BASE_URL.to_string()
}
/// Creates a configuration for the Tribufu API client.
fn create_configuration(api_key: Option<String>) -> Configuration {
let base_path = Self::get_base_url();
let user_agent = Some(Self::get_user_agent());
let api_key_obj = if let Some(api_key) = api_key {
Some(ApiKey {
prefix: Some("ApiKey".to_owned()),
key: api_key,
})
} else {
None
};
Configuration {
base_path,
user_agent,
api_key: api_key_obj,
..Default::default()
}
}
}

48
src/models/account.rs Normal file
View File

@@ -0,0 +1,48 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Account {
#[serde(rename = "id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub id: Option<Option<String>>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "provider", skip_serializing_if = "Option::is_none")]
pub provider: Option<models::LoginProvider>,
#[serde(rename = "user_id", skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
#[serde(rename = "authorized", skip_serializing_if = "Option::is_none")]
pub authorized: Option<bool>,
#[serde(rename = "fields", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub fields: Option<Option<serde_json::Value>>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl Account {
pub fn new() -> Account {
Account {
id: None,
name: None,
provider: None,
user_id: None,
authorized: None,
fields: None,
created: None,
updated: None,
}
}
}

84
src/models/application.rs Normal file
View File

@@ -0,0 +1,84 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Application {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub description: Option<Option<String>>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<models::ApplicationType>,
#[serde(rename = "organization_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub organization_id: Option<Option<String>>,
#[serde(rename = "icon_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub icon_url: Option<Option<String>>,
#[serde(rename = "banner_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub banner_url: Option<Option<String>>,
#[serde(rename = "capsule_image_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub capsule_image_url: Option<Option<String>>,
#[serde(rename = "library_image_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub library_image_url: Option<Option<String>>,
#[serde(rename = "parent_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub parent_id: Option<Option<String>>,
#[serde(rename = "slug", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub slug: Option<Option<String>>,
#[serde(rename = "visibility", skip_serializing_if = "Option::is_none")]
pub visibility: Option<i32>,
#[serde(rename = "password", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub password: Option<Option<String>>,
#[serde(rename = "primary", skip_serializing_if = "Option::is_none")]
pub primary: Option<i32>,
#[serde(rename = "user_count", skip_serializing_if = "Option::is_none")]
pub user_count: Option<i32>,
#[serde(rename = "achievement_count", skip_serializing_if = "Option::is_none")]
pub achievement_count: Option<i32>,
#[serde(rename = "badge_count", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub badge_count: Option<Option<i32>>,
#[serde(rename = "download_count", skip_serializing_if = "Option::is_none")]
pub download_count: Option<i32>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl Application {
pub fn new() -> Application {
Application {
id: None,
name: None,
description: None,
r#type: None,
organization_id: None,
icon_url: None,
banner_url: None,
capsule_image_url: None,
library_image_url: None,
parent_id: None,
slug: None,
visibility: None,
password: None,
primary: None,
user_count: None,
achievement_count: None,
badge_count: None,
download_count: None,
created: None,
updated: None,
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ApplicationType {
#[serde(rename = "application")]
Application,
#[serde(rename = "game")]
Game,
}
impl std::fmt::Display for ApplicationType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Application => write!(f, "application"),
Self::Game => write!(f, "game"),
}
}
}
impl Default for ApplicationType {
fn default() -> ApplicationType {
Self::Application
}
}

View File

@@ -0,0 +1,45 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AuthorizeRequest {
#[serde(rename = "response_type", skip_serializing_if = "Option::is_none")]
pub response_type: Option<models::ResponseType>,
#[serde(rename = "client_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub client_id: Option<Option<String>>,
#[serde(rename = "code_challenge", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub code_challenge: Option<Option<String>>,
#[serde(rename = "code_challenge_method", skip_serializing_if = "Option::is_none")]
pub code_challenge_method: Option<models::CodeChallengeMethod>,
#[serde(rename = "redirect_uri", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub redirect_uri: Option<Option<String>>,
#[serde(rename = "scope", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub scope: Option<Option<String>>,
#[serde(rename = "state", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub state: Option<Option<String>>,
}
impl AuthorizeRequest {
pub fn new() -> AuthorizeRequest {
AuthorizeRequest {
response_type: None,
client_id: None,
code_challenge: None,
code_challenge_method: None,
redirect_uri: None,
scope: None,
state: None,
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum CodeChallengeMethod {
#[serde(rename = "plain")]
Plain,
#[serde(rename = "S256")]
S256,
}
impl std::fmt::Display for CodeChallengeMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Plain => write!(f, "plain"),
Self::S256 => write!(f, "S256"),
}
}
}
impl Default for CodeChallengeMethod {
fn default() -> CodeChallengeMethod {
Self::Plain
}
}

View File

@@ -0,0 +1,30 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CryptoViewModel {
#[serde(rename = "encoded", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub encoded: Option<Option<String>>,
#[serde(rename = "decoded", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub decoded: Option<Option<String>>,
}
impl CryptoViewModel {
pub fn new() -> CryptoViewModel {
CryptoViewModel {
encoded: None,
decoded: None,
}
}
}

117
src/models/game.rs Normal file
View File

@@ -0,0 +1,117 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Game {
#[serde(rename = "game_port", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub game_port: Option<Option<i32>>,
#[serde(rename = "query_port", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub query_port: Option<Option<i32>>,
#[serde(rename = "rcon_port", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub rcon_port: Option<Option<i32>>,
#[serde(rename = "server_count", skip_serializing_if = "Option::is_none")]
pub server_count: Option<i32>,
#[serde(rename = "steam_app_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub steam_app_id: Option<Option<i32>>,
#[serde(rename = "steam_server_app_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub steam_server_app_id: Option<Option<i32>>,
#[serde(rename = "enable_servers", skip_serializing_if = "Option::is_none")]
pub enable_servers: Option<bool>,
#[serde(rename = "rust_gamedig_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub rust_gamedig_id: Option<Option<String>>,
#[serde(rename = "node_gamedig_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub node_gamedig_id: Option<Option<String>>,
#[serde(rename = "server_connect_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub server_connect_url: Option<Option<String>>,
#[serde(rename = "server_tags", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub server_tags: Option<Option<String>>,
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub description: Option<Option<String>>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<models::ApplicationType>,
#[serde(rename = "organization_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub organization_id: Option<Option<String>>,
#[serde(rename = "icon_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub icon_url: Option<Option<String>>,
#[serde(rename = "banner_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub banner_url: Option<Option<String>>,
#[serde(rename = "capsule_image_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub capsule_image_url: Option<Option<String>>,
#[serde(rename = "library_image_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub library_image_url: Option<Option<String>>,
#[serde(rename = "parent_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub parent_id: Option<Option<String>>,
#[serde(rename = "slug", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub slug: Option<Option<String>>,
#[serde(rename = "visibility", skip_serializing_if = "Option::is_none")]
pub visibility: Option<i32>,
#[serde(rename = "password", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub password: Option<Option<String>>,
#[serde(rename = "primary", skip_serializing_if = "Option::is_none")]
pub primary: Option<i32>,
#[serde(rename = "user_count", skip_serializing_if = "Option::is_none")]
pub user_count: Option<i32>,
#[serde(rename = "achievement_count", skip_serializing_if = "Option::is_none")]
pub achievement_count: Option<i32>,
#[serde(rename = "badge_count", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub badge_count: Option<Option<i32>>,
#[serde(rename = "download_count", skip_serializing_if = "Option::is_none")]
pub download_count: Option<i32>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl Game {
pub fn new() -> Game {
Game {
game_port: None,
query_port: None,
rcon_port: None,
server_count: None,
steam_app_id: None,
steam_server_app_id: None,
enable_servers: None,
rust_gamedig_id: None,
node_gamedig_id: None,
server_connect_url: None,
server_tags: None,
id: None,
name: None,
description: None,
r#type: None,
organization_id: None,
icon_url: None,
banner_url: None,
capsule_image_url: None,
library_image_url: None,
parent_id: None,
slug: None,
visibility: None,
password: None,
primary: None,
user_count: None,
achievement_count: None,
badge_count: None,
download_count: None,
created: None,
updated: None,
}
}
}

117
src/models/game_server.rs Normal file
View File

@@ -0,0 +1,117 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct GameServer {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub description: Option<Option<String>>,
#[serde(rename = "address", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub address: Option<Option<String>>,
#[serde(rename = "game_port", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub game_port: Option<Option<i32>>,
#[serde(rename = "query_port", skip_serializing_if = "Option::is_none")]
pub query_port: Option<i32>,
#[serde(rename = "game_id", skip_serializing_if = "Option::is_none")]
pub game_id: Option<String>,
#[serde(rename = "game_icon_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub game_icon_url: Option<Option<String>>,
#[serde(rename = "version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub version: Option<Option<String>>,
#[serde(rename = "featured", skip_serializing_if = "Option::is_none")]
pub featured: Option<bool>,
#[serde(rename = "cluster_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub cluster_id: Option<Option<String>>,
#[serde(rename = "website_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub website_url: Option<Option<String>>,
#[serde(rename = "banner_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub banner_url: Option<Option<String>>,
#[serde(rename = "owner_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub owner_id: Option<Option<String>>,
#[serde(rename = "uptime", skip_serializing_if = "Option::is_none")]
pub uptime: Option<f64>,
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
pub status: Option<models::ServerStatus>,
#[serde(rename = "ping", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub ping: Option<Option<i32>>,
#[serde(rename = "map", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub map: Option<Option<String>>,
#[serde(rename = "used_slots", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub used_slots: Option<Option<i32>>,
#[serde(rename = "max_slots", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub max_slots: Option<Option<i32>>,
#[serde(rename = "motd", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub motd: Option<Option<String>>,
#[serde(rename = "players", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub players: Option<Option<String>>,
#[serde(rename = "last_online", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub last_online: Option<Option<String>>,
#[serde(rename = "country", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub country: Option<Option<String>>,
#[serde(rename = "steam", skip_serializing_if = "Option::is_none")]
pub steam: Option<bool>,
#[serde(rename = "discord_server_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub discord_server_id: Option<Option<String>>,
#[serde(rename = "youtube_video_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub youtube_video_url: Option<Option<String>>,
#[serde(rename = "tags", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub tags: Option<Option<String>>,
#[serde(rename = "comment_count", skip_serializing_if = "Option::is_none")]
pub comment_count: Option<i32>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl GameServer {
pub fn new() -> GameServer {
GameServer {
id: None,
name: None,
description: None,
address: None,
game_port: None,
query_port: None,
game_id: None,
game_icon_url: None,
version: None,
featured: None,
cluster_id: None,
website_url: None,
banner_url: None,
owner_id: None,
uptime: None,
status: None,
ping: None,
map: None,
used_slots: None,
max_slots: None,
motd: None,
players: None,
last_online: None,
country: None,
steam: None,
discord_server_id: None,
youtube_video_url: None,
tags: None,
comment_count: None,
created: None,
updated: None,
}
}
}

View File

@@ -0,0 +1,66 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct GameServerCluster {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub description: Option<Option<String>>,
#[serde(rename = "game_id", skip_serializing_if = "Option::is_none")]
pub game_id: Option<String>,
#[serde(rename = "website_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub website_url: Option<Option<String>>,
#[serde(rename = "banner_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub banner_url: Option<Option<String>>,
#[serde(rename = "owner_id", skip_serializing_if = "Option::is_none")]
pub owner_id: Option<String>,
#[serde(rename = "discord_server_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub discord_server_id: Option<Option<String>>,
#[serde(rename = "youtube_video_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub youtube_video_url: Option<Option<String>>,
#[serde(rename = "tags", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub tags: Option<Option<String>>,
#[serde(rename = "comment_count", skip_serializing_if = "Option::is_none")]
pub comment_count: Option<i32>,
#[serde(rename = "server_count", skip_serializing_if = "Option::is_none")]
pub server_count: Option<i32>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl GameServerCluster {
pub fn new() -> GameServerCluster {
GameServerCluster {
id: None,
name: None,
description: None,
game_id: None,
website_url: None,
banner_url: None,
owner_id: None,
discord_server_id: None,
youtube_video_url: None,
tags: None,
comment_count: None,
server_count: None,
created: None,
updated: None,
}
}
}

44
src/models/grant_type.rs Normal file
View File

@@ -0,0 +1,44 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum GrantType {
#[serde(rename = "authorization_code")]
AuthorizationCode,
#[serde(rename = "client_credentials")]
ClientCredentials,
#[serde(rename = "password")]
Password,
#[serde(rename = "refresh_token")]
RefreshToken,
}
impl std::fmt::Display for GrantType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::AuthorizationCode => write!(f, "authorization_code"),
Self::ClientCredentials => write!(f, "client_credentials"),
Self::Password => write!(f, "password"),
Self::RefreshToken => write!(f, "refresh_token"),
}
}
}
impl Default for GrantType {
fn default() -> GrantType {
Self::AuthorizationCode
}
}

72
src/models/group.rs Normal file
View File

@@ -0,0 +1,72 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Group {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "uuid", skip_serializing_if = "Option::is_none")]
pub uuid: Option<uuid::Uuid>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "tag", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub tag: Option<Option<String>>,
#[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub description: Option<Option<String>>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<i32>,
#[serde(rename = "privacy", skip_serializing_if = "Option::is_none")]
pub privacy: Option<i32>,
#[serde(rename = "owner_id", skip_serializing_if = "Option::is_none")]
pub owner_id: Option<String>,
#[serde(rename = "verified", skip_serializing_if = "Option::is_none")]
pub verified: Option<bool>,
#[serde(rename = "photo_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub photo_url: Option<Option<String>>,
#[serde(rename = "banner_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub banner_url: Option<Option<String>>,
#[serde(rename = "member_count", skip_serializing_if = "Option::is_none")]
pub member_count: Option<i32>,
#[serde(rename = "follower_count", skip_serializing_if = "Option::is_none")]
pub follower_count: Option<i32>,
#[serde(rename = "view_count", skip_serializing_if = "Option::is_none")]
pub view_count: Option<i32>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl Group {
pub fn new() -> Group {
Group {
id: None,
uuid: None,
name: None,
tag: None,
description: None,
r#type: None,
privacy: None,
owner_id: None,
verified: None,
photo_url: None,
banner_url: None,
member_count: None,
follower_count: None,
view_count: None,
created: None,
updated: None,
}
}
}

45
src/models/group_game.rs Normal file
View File

@@ -0,0 +1,45 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct GroupGame {
#[serde(rename = "group_id", skip_serializing_if = "Option::is_none")]
pub group_id: Option<String>,
#[serde(rename = "group", skip_serializing_if = "Option::is_none")]
pub group: Option<Box<models::Group>>,
#[serde(rename = "application_id", skip_serializing_if = "Option::is_none")]
pub application_id: Option<String>,
#[serde(rename = "application", skip_serializing_if = "Option::is_none")]
pub application: Option<Box<models::Application>>,
#[serde(rename = "stats", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub stats: Option<Option<serde_json::Value>>,
#[serde(rename = "acquired", skip_serializing_if = "Option::is_none")]
pub acquired: Option<String>,
#[serde(rename = "last_used", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub last_used: Option<Option<String>>,
}
impl GroupGame {
pub fn new() -> GroupGame {
GroupGame {
group_id: None,
group: None,
application_id: None,
application: None,
stats: None,
acquired: None,
last_used: None,
}
}
}

View File

@@ -0,0 +1,51 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct GroupMember {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "uuid", skip_serializing_if = "Option::is_none")]
pub uuid: Option<uuid::Uuid>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "display_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub display_name: Option<Option<String>>,
#[serde(rename = "verified", skip_serializing_if = "Option::is_none")]
pub verified: Option<bool>,
#[serde(rename = "photo_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub photo_url: Option<Option<String>>,
#[serde(rename = "last_online", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub last_online: Option<Option<String>>,
#[serde(rename = "rank", skip_serializing_if = "Option::is_none")]
pub rank: Option<models::GroupRank>,
#[serde(rename = "since", skip_serializing_if = "Option::is_none")]
pub since: Option<String>,
}
impl GroupMember {
pub fn new() -> GroupMember {
GroupMember {
id: None,
uuid: None,
name: None,
display_name: None,
verified: None,
photo_url: None,
last_online: None,
rank: None,
since: None,
}
}
}

41
src/models/group_rank.rs Normal file
View File

@@ -0,0 +1,41 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum GroupRank {
#[serde(rename = "member")]
Member,
#[serde(rename = "leader")]
Leader,
#[serde(rename = "owner")]
Owner,
}
impl std::fmt::Display for GroupRank {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Member => write!(f, "member"),
Self::Leader => write!(f, "leader"),
Self::Owner => write!(f, "owner"),
}
}
}
impl Default for GroupRank {
fn default() -> GroupRank {
Self::Member
}
}

View File

@@ -0,0 +1,27 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct HashViewModel {
#[serde(rename = "value", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub value: Option<Option<String>>,
}
impl HashViewModel {
pub fn new() -> HashViewModel {
HashViewModel {
value: None,
}
}
}

View File

@@ -0,0 +1,30 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct IntrospectRequest {
#[serde(rename = "token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub token: Option<Option<String>>,
#[serde(rename = "token_type_hint", skip_serializing_if = "Option::is_none")]
pub token_type_hint: Option<models::TokenHintType>,
}
impl IntrospectRequest {
pub fn new() -> IntrospectRequest {
IntrospectRequest {
token: None,
token_type_hint: None,
}
}
}

78
src/models/ip_address.rs Normal file
View File

@@ -0,0 +1,78 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct IpAddress {
#[serde(rename = "address", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub address: Option<Option<String>>,
#[serde(rename = "version", skip_serializing_if = "Option::is_none")]
pub version: Option<i32>,
#[serde(rename = "network", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub network: Option<Option<String>>,
#[serde(rename = "reserved", skip_serializing_if = "Option::is_none")]
pub reserved: Option<bool>,
#[serde(rename = "asn", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub asn: Option<Option<String>>,
#[serde(rename = "isp", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub isp: Option<Option<String>>,
#[serde(rename = "continent", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub continent: Option<Option<String>>,
#[serde(rename = "country", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub country: Option<Option<String>>,
#[serde(rename = "region", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub region: Option<Option<String>>,
#[serde(rename = "city", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub city: Option<Option<String>>,
#[serde(rename = "postal_code", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub postal_code: Option<Option<String>>,
#[serde(rename = "calling_code", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub calling_code: Option<Option<String>>,
#[serde(rename = "tld", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub tld: Option<Option<String>>,
#[serde(rename = "language", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub language: Option<Option<String>>,
#[serde(rename = "timezone", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub timezone: Option<Option<String>>,
#[serde(rename = "currency", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub currency: Option<Option<String>>,
#[serde(rename = "latitude", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub latitude: Option<Option<f32>>,
#[serde(rename = "longitude", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub longitude: Option<Option<f32>>,
}
impl IpAddress {
pub fn new() -> IpAddress {
IpAddress {
address: None,
version: None,
network: None,
reserved: None,
asn: None,
isp: None,
continent: None,
country: None,
region: None,
city: None,
postal_code: None,
calling_code: None,
tld: None,
language: None,
timezone: None,
currency: None,
latitude: None,
longitude: None,
}
}
}

View File

@@ -0,0 +1,42 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct LeaderboardItem {
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "display_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub display_name: Option<Option<String>>,
#[serde(rename = "photo_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub photo_url: Option<Option<String>>,
#[serde(rename = "level", skip_serializing_if = "Option::is_none")]
pub level: Option<i32>,
#[serde(rename = "experience", skip_serializing_if = "Option::is_none")]
pub experience: Option<f64>,
#[serde(rename = "points", skip_serializing_if = "Option::is_none")]
pub points: Option<f64>,
}
impl LeaderboardItem {
pub fn new() -> LeaderboardItem {
LeaderboardItem {
name: None,
display_name: None,
photo_url: None,
level: None,
experience: None,
points: None,
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum LeaderboardOrder {
#[serde(rename = "level")]
Level,
#[serde(rename = "points")]
Points,
}
impl std::fmt::Display for LeaderboardOrder {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Level => write!(f, "level"),
Self::Points => write!(f, "points"),
}
}
}
impl Default for LeaderboardOrder {
fn default() -> LeaderboardOrder {
Self::Level
}
}

View File

@@ -0,0 +1,53 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum LoginProvider {
#[serde(rename = "steam")]
Steam,
#[serde(rename = "epic")]
Epic,
#[serde(rename = "discord")]
Discord,
#[serde(rename = "microsoft")]
Microsoft,
#[serde(rename = "playstation")]
Playstation,
#[serde(rename = "google")]
Google,
#[serde(rename = "apple")]
Apple,
}
impl std::fmt::Display for LoginProvider {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Steam => write!(f, "steam"),
Self::Epic => write!(f, "epic"),
Self::Discord => write!(f, "discord"),
Self::Microsoft => write!(f, "microsoft"),
Self::Playstation => write!(f, "playstation"),
Self::Google => write!(f, "google"),
Self::Apple => write!(f, "apple"),
}
}
}
impl Default for LoginProvider {
fn default() -> LoginProvider {
Self::Steam
}
}

View File

@@ -0,0 +1,30 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct LoginRequest {
#[serde(rename = "login", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub login: Option<Option<String>>,
#[serde(rename = "password", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub password: Option<Option<String>>,
}
impl LoginRequest {
pub fn new() -> LoginRequest {
LoginRequest {
login: None,
password: None,
}
}
}

View File

@@ -0,0 +1,36 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct LoginResponse {
#[serde(rename = "user", skip_serializing_if = "Option::is_none")]
pub user: Option<Box<models::UserInfo>>,
#[serde(rename = "access_token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub access_token: Option<Option<String>>,
#[serde(rename = "refresh_token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<Option<String>>,
#[serde(rename = "expires_in", skip_serializing_if = "Option::is_none")]
pub expires_in: Option<i64>,
}
impl LoginResponse {
pub fn new() -> LoginResponse {
LoginResponse {
user: None,
access_token: None,
refresh_token: None,
expires_in: None,
}
}
}

84
src/models/mod.rs Normal file
View File

@@ -0,0 +1,84 @@
pub mod account;
pub use self::account::Account;
pub mod application;
pub use self::application::Application;
pub mod application_type;
pub use self::application_type::ApplicationType;
pub mod authorize_request;
pub use self::authorize_request::AuthorizeRequest;
pub mod code_challenge_method;
pub use self::code_challenge_method::CodeChallengeMethod;
pub mod crypto_view_model;
pub use self::crypto_view_model::CryptoViewModel;
pub mod game;
pub use self::game::Game;
pub mod game_server;
pub use self::game_server::GameServer;
pub mod game_server_cluster;
pub use self::game_server_cluster::GameServerCluster;
pub mod grant_type;
pub use self::grant_type::GrantType;
pub mod group;
pub use self::group::Group;
pub mod group_game;
pub use self::group_game::GroupGame;
pub mod group_member;
pub use self::group_member::GroupMember;
pub mod group_rank;
pub use self::group_rank::GroupRank;
pub mod hash_view_model;
pub use self::hash_view_model::HashViewModel;
pub mod introspect_request;
pub use self::introspect_request::IntrospectRequest;
pub mod ip_address;
pub use self::ip_address::IpAddress;
pub mod leaderboard_item;
pub use self::leaderboard_item::LeaderboardItem;
pub mod leaderboard_order;
pub use self::leaderboard_order::LeaderboardOrder;
pub mod login_provider;
pub use self::login_provider::LoginProvider;
pub mod login_request;
pub use self::login_request::LoginRequest;
pub mod login_response;
pub use self::login_response::LoginResponse;
pub mod package;
pub use self::package::Package;
pub mod profile;
pub use self::profile::Profile;
pub mod profile_game;
pub use self::profile_game::ProfileGame;
pub mod profile_group;
pub use self::profile_group::ProfileGroup;
pub mod refresh_request;
pub use self::refresh_request::RefreshRequest;
pub mod register_request;
pub use self::register_request::RegisterRequest;
pub mod response_type;
pub use self::response_type::ResponseType;
pub mod revoke_request;
pub use self::revoke_request::RevokeRequest;
pub mod search_request;
pub use self::search_request::SearchRequest;
pub mod search_type;
pub use self::search_type::SearchType;
pub mod server_metrics;
pub use self::server_metrics::ServerMetrics;
pub mod server_status;
pub use self::server_status::ServerStatus;
pub mod subscription;
pub use self::subscription::Subscription;
pub mod token_hint_type;
pub use self::token_hint_type::TokenHintType;
pub mod token_request;
pub use self::token_request::TokenRequest;
pub mod token_response;
pub use self::token_response::TokenResponse;
pub mod token_type;
pub use self::token_type::TokenType;
pub mod update_profile;
pub use self::update_profile::UpdateProfile;
pub mod user_info;
pub use self::user_info::UserInfo;
pub mod user_type;
pub use self::user_type::UserType;

60
src/models/package.rs Normal file
View File

@@ -0,0 +1,60 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Package {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub description: Option<Option<String>>,
#[serde(rename = "image_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub image_url: Option<Option<String>>,
#[serde(rename = "author_id", skip_serializing_if = "Option::is_none")]
pub author_id: Option<String>,
#[serde(rename = "version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub version: Option<Option<String>>,
#[serde(rename = "file_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub file_url: Option<Option<String>>,
#[serde(rename = "raw_size", skip_serializing_if = "Option::is_none")]
pub raw_size: Option<f64>,
#[serde(rename = "download_count", skip_serializing_if = "Option::is_none")]
pub download_count: Option<i32>,
#[serde(rename = "last_download", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub last_download: Option<Option<String>>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl Package {
pub fn new() -> Package {
Package {
id: None,
name: None,
description: None,
image_url: None,
author_id: None,
version: None,
file_url: None,
raw_size: None,
download_count: None,
last_download: None,
created: None,
updated: None,
}
}
}

78
src/models/profile.rs Normal file
View File

@@ -0,0 +1,78 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Profile {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "uuid", skip_serializing_if = "Option::is_none")]
pub uuid: Option<uuid::Uuid>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "display_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub display_name: Option<Option<String>>,
#[serde(rename = "verified", skip_serializing_if = "Option::is_none")]
pub verified: Option<bool>,
#[serde(rename = "level", skip_serializing_if = "Option::is_none")]
pub level: Option<i32>,
#[serde(rename = "experience", skip_serializing_if = "Option::is_none")]
pub experience: Option<f64>,
#[serde(rename = "public_birthday", skip_serializing_if = "Option::is_none")]
pub public_birthday: Option<bool>,
#[serde(rename = "birthday", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub birthday: Option<Option<String>>,
#[serde(rename = "points", skip_serializing_if = "Option::is_none")]
pub points: Option<f64>,
#[serde(rename = "location", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub location: Option<Option<String>>,
#[serde(rename = "photo_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub photo_url: Option<Option<String>>,
#[serde(rename = "banner_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub banner_url: Option<Option<String>>,
#[serde(rename = "last_online", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub last_online: Option<Option<String>>,
#[serde(rename = "biography", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub biography: Option<Option<String>>,
#[serde(rename = "view_count", skip_serializing_if = "Option::is_none")]
pub view_count: Option<i32>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl Profile {
pub fn new() -> Profile {
Profile {
id: None,
uuid: None,
name: None,
display_name: None,
verified: None,
level: None,
experience: None,
public_birthday: None,
birthday: None,
points: None,
location: None,
photo_url: None,
banner_url: None,
last_online: None,
biography: None,
view_count: None,
created: None,
updated: None,
}
}
}

View File

@@ -0,0 +1,57 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ProfileGame {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "capsule_image_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub capsule_image_url: Option<Option<String>>,
#[serde(rename = "library_image_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub library_image_url: Option<Option<String>>,
#[serde(rename = "slug", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub slug: Option<Option<String>>,
#[serde(rename = "time_used", skip_serializing_if = "Option::is_none")]
pub time_used: Option<f64>,
#[serde(rename = "unlocked_achievements", skip_serializing_if = "Option::is_none")]
pub unlocked_achievements: Option<i32>,
#[serde(rename = "total_achievements", skip_serializing_if = "Option::is_none")]
pub total_achievements: Option<i32>,
#[serde(rename = "stats", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub stats: Option<Option<serde_json::Value>>,
#[serde(rename = "acquired", skip_serializing_if = "Option::is_none")]
pub acquired: Option<String>,
#[serde(rename = "last_used", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub last_used: Option<Option<String>>,
}
impl ProfileGame {
pub fn new() -> ProfileGame {
ProfileGame {
id: None,
name: None,
capsule_image_url: None,
library_image_url: None,
slug: None,
time_used: None,
unlocked_achievements: None,
total_achievements: None,
stats: None,
acquired: None,
last_used: None,
}
}
}

View File

@@ -0,0 +1,54 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ProfileGroup {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "uuid", skip_serializing_if = "Option::is_none")]
pub uuid: Option<uuid::Uuid>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "tag", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub tag: Option<Option<String>>,
#[serde(rename = "privacy", skip_serializing_if = "Option::is_none")]
pub privacy: Option<i32>,
#[serde(rename = "verified", skip_serializing_if = "Option::is_none")]
pub verified: Option<bool>,
#[serde(rename = "photo_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub photo_url: Option<Option<String>>,
#[serde(rename = "member_count", skip_serializing_if = "Option::is_none")]
pub member_count: Option<i32>,
#[serde(rename = "rank", skip_serializing_if = "Option::is_none")]
pub rank: Option<models::GroupRank>,
#[serde(rename = "since", skip_serializing_if = "Option::is_none")]
pub since: Option<String>,
}
impl ProfileGroup {
pub fn new() -> ProfileGroup {
ProfileGroup {
id: None,
uuid: None,
name: None,
tag: None,
privacy: None,
verified: None,
photo_url: None,
member_count: None,
rank: None,
since: None,
}
}
}

View File

@@ -0,0 +1,27 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct RefreshRequest {
#[serde(rename = "refresh_token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<Option<String>>,
}
impl RefreshRequest {
pub fn new() -> RefreshRequest {
RefreshRequest {
refresh_token: None,
}
}
}

View File

@@ -0,0 +1,36 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct RegisterRequest {
#[serde(rename = "uuid", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub uuid: Option<Option<uuid::Uuid>>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "email", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub email: Option<Option<String>>,
#[serde(rename = "password")]
pub password: String,
}
impl RegisterRequest {
pub fn new(name: String, password: String) -> RegisterRequest {
RegisterRequest {
uuid: None,
name,
email: None,
password,
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ResponseType {
#[serde(rename = "code")]
Code,
#[serde(rename = "token")]
Token,
}
impl std::fmt::Display for ResponseType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Code => write!(f, "code"),
Self::Token => write!(f, "token"),
}
}
}
impl Default for ResponseType {
fn default() -> ResponseType {
Self::Code
}
}

View File

@@ -0,0 +1,30 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct RevokeRequest {
#[serde(rename = "token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub token: Option<Option<String>>,
#[serde(rename = "token_type_hint", skip_serializing_if = "Option::is_none")]
pub token_type_hint: Option<models::TokenHintType>,
}
impl RevokeRequest {
pub fn new() -> RevokeRequest {
RevokeRequest {
token: None,
token_type_hint: None,
}
}
}

View File

@@ -0,0 +1,36 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct SearchRequest {
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<models::SearchType>,
#[serde(rename = "query", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub query: Option<Option<String>>,
#[serde(rename = "page", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub page: Option<Option<i32>>,
#[serde(rename = "game_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub game_id: Option<Option<String>>,
}
impl SearchRequest {
pub fn new() -> SearchRequest {
SearchRequest {
r#type: None,
query: None,
page: None,
game_id: None,
}
}
}

44
src/models/search_type.rs Normal file
View File

@@ -0,0 +1,44 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum SearchType {
#[serde(rename = "user")]
User,
#[serde(rename = "group")]
Group,
#[serde(rename = "server")]
Server,
#[serde(rename = "cluster")]
Cluster,
}
impl std::fmt::Display for SearchType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::User => write!(f, "user"),
Self::Group => write!(f, "group"),
Self::Server => write!(f, "server"),
Self::Cluster => write!(f, "cluster"),
}
}
}
impl Default for SearchType {
fn default() -> SearchType {
Self::User
}
}

View File

@@ -0,0 +1,33 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ServerMetrics {
#[serde(rename = "server_count", skip_serializing_if = "Option::is_none")]
pub server_count: Option<i32>,
#[serde(rename = "package_count", skip_serializing_if = "Option::is_none")]
pub package_count: Option<i32>,
#[serde(rename = "country_count", skip_serializing_if = "Option::is_none")]
pub country_count: Option<i32>,
}
impl ServerMetrics {
pub fn new() -> ServerMetrics {
ServerMetrics {
server_count: None,
package_count: None,
country_count: None,
}
}
}

View File

@@ -0,0 +1,41 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ServerStatus {
#[serde(rename = "unknown")]
Unknown,
#[serde(rename = "offline")]
Offline,
#[serde(rename = "online")]
Online,
}
impl std::fmt::Display for ServerStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Unknown => write!(f, "unknown"),
Self::Offline => write!(f, "offline"),
Self::Online => write!(f, "online"),
}
}
}
impl Default for ServerStatus {
fn default() -> ServerStatus {
Self::Unknown
}
}

View File

@@ -0,0 +1,45 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Subscription {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "description", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub description: Option<Option<String>>,
#[serde(rename = "image_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub image_url: Option<Option<String>>,
#[serde(rename = "prices", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub prices: Option<Option<std::collections::HashMap<String, f64>>>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl Subscription {
pub fn new() -> Subscription {
Subscription {
id: None,
name: None,
description: None,
image_url: None,
prices: None,
created: None,
updated: None,
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum TokenHintType {
#[serde(rename = "access_token")]
AccessToken,
#[serde(rename = "refresh_token")]
RefreshToken,
}
impl std::fmt::Display for TokenHintType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::AccessToken => write!(f, "access_token"),
Self::RefreshToken => write!(f, "refresh_token"),
}
}
}
impl Default for TokenHintType {
fn default() -> TokenHintType {
Self::AccessToken
}
}

View File

@@ -0,0 +1,48 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TokenRequest {
#[serde(rename = "grant_type", skip_serializing_if = "Option::is_none")]
pub grant_type: Option<models::GrantType>,
#[serde(rename = "code", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub code: Option<Option<String>>,
#[serde(rename = "username", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub username: Option<Option<String>>,
#[serde(rename = "password", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub password: Option<Option<String>>,
#[serde(rename = "refresh_token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<Option<String>>,
#[serde(rename = "client_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub client_id: Option<Option<String>>,
#[serde(rename = "redirect_uri", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub redirect_uri: Option<Option<String>>,
#[serde(rename = "code_verifier", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub code_verifier: Option<Option<String>>,
}
impl TokenRequest {
pub fn new() -> TokenRequest {
TokenRequest {
grant_type: None,
code: None,
username: None,
password: None,
refresh_token: None,
client_id: None,
redirect_uri: None,
code_verifier: None,
}
}
}

View File

@@ -0,0 +1,42 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TokenResponse {
#[serde(rename = "token_type", skip_serializing_if = "Option::is_none")]
pub token_type: Option<models::TokenType>,
#[serde(rename = "access_token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub access_token: Option<Option<String>>,
#[serde(rename = "refresh_token", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<Option<String>>,
#[serde(rename = "scope", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub scope: Option<Option<String>>,
#[serde(rename = "state", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub state: Option<Option<String>>,
#[serde(rename = "expires_in", skip_serializing_if = "Option::is_none")]
pub expires_in: Option<i64>,
}
impl TokenResponse {
pub fn new() -> TokenResponse {
TokenResponse {
token_type: None,
access_token: None,
refresh_token: None,
scope: None,
state: None,
expires_in: None,
}
}
}

35
src/models/token_type.rs Normal file
View File

@@ -0,0 +1,35 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum TokenType {
#[serde(rename = "bearer")]
Bearer,
}
impl std::fmt::Display for TokenType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Bearer => write!(f, "bearer"),
}
}
}
impl Default for TokenType {
fn default() -> TokenType {
Self::Bearer
}
}

View File

@@ -0,0 +1,30 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UpdateProfile {
#[serde(rename = "display_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub display_name: Option<Option<String>>,
#[serde(rename = "biography", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub biography: Option<Option<String>>,
}
impl UpdateProfile {
pub fn new() -> UpdateProfile {
UpdateProfile {
display_name: None,
biography: None,
}
}
}

99
src/models/user_info.rs Normal file
View File

@@ -0,0 +1,99 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UserInfo {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "uuid", skip_serializing_if = "Option::is_none")]
pub uuid: Option<uuid::Uuid>,
#[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub name: Option<Option<String>>,
#[serde(rename = "display_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub display_name: Option<Option<String>>,
#[serde(rename = "email", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub email: Option<Option<String>>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<models::UserType>,
#[serde(rename = "flags", skip_serializing_if = "Option::is_none")]
pub flags: Option<String>,
#[serde(rename = "permissions", skip_serializing_if = "Option::is_none")]
pub permissions: Option<String>,
#[serde(rename = "verified", skip_serializing_if = "Option::is_none")]
pub verified: Option<bool>,
#[serde(rename = "level", skip_serializing_if = "Option::is_none")]
pub level: Option<i32>,
#[serde(rename = "experience", skip_serializing_if = "Option::is_none")]
pub experience: Option<f64>,
#[serde(rename = "public_birthday", skip_serializing_if = "Option::is_none")]
pub public_birthday: Option<bool>,
#[serde(rename = "birthday", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub birthday: Option<Option<String>>,
#[serde(rename = "points", skip_serializing_if = "Option::is_none")]
pub points: Option<f64>,
#[serde(rename = "location", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub location: Option<Option<String>>,
#[serde(rename = "language", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub language: Option<Option<String>>,
#[serde(rename = "timezone", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub timezone: Option<Option<String>>,
#[serde(rename = "currency", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub currency: Option<Option<String>>,
#[serde(rename = "photo_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub photo_url: Option<Option<String>>,
#[serde(rename = "banner_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub banner_url: Option<Option<String>>,
#[serde(rename = "last_online", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub last_online: Option<Option<String>>,
#[serde(rename = "biography", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub biography: Option<Option<String>>,
#[serde(rename = "view_count", skip_serializing_if = "Option::is_none")]
pub view_count: Option<i32>,
#[serde(rename = "created", skip_serializing_if = "Option::is_none")]
pub created: Option<String>,
#[serde(rename = "updated", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub updated: Option<Option<String>>,
}
impl UserInfo {
pub fn new() -> UserInfo {
UserInfo {
id: None,
uuid: None,
name: None,
display_name: None,
email: None,
r#type: None,
flags: None,
permissions: None,
verified: None,
level: None,
experience: None,
public_birthday: None,
birthday: None,
points: None,
location: None,
language: None,
timezone: None,
currency: None,
photo_url: None,
banner_url: None,
last_online: None,
biography: None,
view_count: None,
created: None,
updated: None,
}
}
}

38
src/models/user_type.rs Normal file
View File

@@ -0,0 +1,38 @@
/*
* Tribufu API
*
* REST API to access Tribufu services.
*
* The version of the OpenAPI document: 1.1.0
* Contact: contact@tribufu.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum UserType {
#[serde(rename = "user")]
User,
#[serde(rename = "bot")]
Bot,
}
impl std::fmt::Display for UserType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::User => write!(f, "user"),
Self::Bot => write!(f, "bot"),
}
}
}
impl Default for UserType {
fn default() -> UserType {
Self::User
}
}

View File

@@ -1,153 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
use serde::{Deserialize, Serialize};
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OAuth2ResponseType {
Code,
Token,
}
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OAuth2ClientType {
Confidential,
Public,
}
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OAuth2TokenHintType {
AccessToken,
RefreshToken,
}
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OAuth2GrantType {
AuthorizationCode,
ClientCredentials,
DeviceCode,
Password,
RefreshToken,
}
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OAuth2AuthorizeError {
AccessDenied,
InvalidRequest,
InvalidScope,
ServerError,
TemporarilyUnavailable,
UnauthorizedClient,
UnsupportedResponseType,
}
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OAuth2TokenType {
Bearer,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OAuth2AuthorizeRequest {
pub response_type: OAuth2ResponseType,
pub client_id: String,
pub client_secret: Option<String>,
pub redirect_uri: String,
pub scope: Option<String>,
pub state: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OAuth2CodeResponse {
pub code: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OAuth2ErrorResponse {
pub error: OAuth2AuthorizeError,
#[serde(skip_serializing_if = "Option::is_none")]
pub error_description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub error_uri: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OAuth2TokenRequest {
pub grant_type: OAuth2GrantType,
#[serde(skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub password: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub client_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub client_secret: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub redirect_uri: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub server_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OAuth2TokenResponse {
pub token_type: OAuth2TokenType,
pub access_token: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub scope: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
pub expires_in: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OAuth2RevokeRequest {
pub token: String,
pub token_type_hint: OAuth2TokenHintType,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OAuth2IntrospectionResponse {
pub active: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub client_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub scope: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub exp: Option<i64>,
}
impl OAuth2IntrospectionResponse {
fn inative() -> Self {
Self {
active: false,
client_id: None,
username: None,
scope: None,
exp: None,
}
}
}

View File

@@ -1,11 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
use crate::oauth2::OAuth2TokenResponse;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Credentials {
ApiKey(String),
Token(OAuth2TokenResponse),
}

202
vendor/openapi-generator/LICENSE vendored Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
Copyright 2018 SmartBear Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Binary file not shown.