fastly_api/apis/
configuration.rs1use reqwest;
10use std::env;
11
12pub const DEFAULT_RATELIMIT: u64 = 1000;
14
15#[derive(Debug, Clone)]
16pub struct Configuration {
17 pub base_path: String,
18 pub user_agent: Option<String>,
19 pub client: reqwest::Client,
20 pub basic_auth: Option<BasicAuth>,
21 pub oauth_access_token: Option<String>,
22 pub bearer_access_token: Option<String>,
23 pub api_key: Option<ApiKey>,
24 pub rate_limit_remaining: u64,
25 pub rate_limit_reset: u64,
26 }
28
29pub type BasicAuth = (String, Option<String>);
30
31#[derive(Debug, Clone)]
32pub struct ApiKey {
33 pub prefix: Option<String>,
34 pub key: String,
35}
36
37impl Configuration {
38 pub fn new() -> Configuration {
39 Configuration::default()
40 }
41}
42
43impl Default for Configuration {
44 fn default() -> Self {
45 let api_key = match env::var("FASTLY_API_TOKEN") {
46 Ok(key) => key,
47 Err(_) => "".to_string(),
48 };
49
50 Configuration {
51 base_path: "https://api.fastly.com".to_owned(),
52 user_agent: Some("fastly-rust/9.0.0/rust".to_owned()),
53 client: reqwest::Client::new(),
54 basic_auth: None,
55 oauth_access_token: None,
56 bearer_access_token: None,
57 api_key: Some(ApiKey {
58 prefix: None,
59 key: api_key,
60 }),
61 rate_limit_remaining: DEFAULT_RATELIMIT,
62 rate_limit_reset: 0,
63 }
64 }
65}