thunderstore_api/apis/
configuration.rs

1////////////////////////////////////////////////////////////////////////////////
2// This Source Code Form is subject to the terms of the Mozilla Public         /
3// License, v. 2.0. If a copy of the MPL was not distributed with this         /
4// file, You can obtain one at https://mozilla.org/MPL/2.0/.                   /
5////////////////////////////////////////////////////////////////////////////////
6use reqwest;
7
8#[derive(Debug, Clone)]
9pub struct Configuration {
10    pub base_path: String,
11    pub user_agent: Option<String>,
12    pub client: reqwest::Client,
13    pub basic_auth: Option<BasicAuth>,
14    pub oauth_access_token: Option<String>,
15    pub bearer_access_token: Option<String>,
16    pub api_key: Option<ApiKey>,
17    // TODO: take an oauth2 token source, similar to the go one
18}
19
20pub type BasicAuth = (String, Option<String>);
21
22#[derive(Debug, Clone)]
23pub struct ApiKey {
24    pub prefix: Option<String>,
25    pub key: String,
26}
27
28impl Configuration {
29    #[must_use]
30    pub fn new() -> Configuration {
31        Configuration::default()
32    }
33}
34
35impl Default for Configuration {
36    fn default() -> Self {
37        Configuration {
38            base_path: "https://thunderstore.io".to_owned(),
39            user_agent: Some("OpenAPI-Generator/v1/rust".to_owned()),
40            client: reqwest::Client::new(),
41            basic_auth: None,
42            oauth_access_token: None,
43            bearer_access_token: None,
44            api_key: None,
45        }
46    }
47}