mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-18 09:14:19 +01:00
feat(hub): Allow overriding rootUrl and baseUrl
Allow the hub to override `rootUrl` and `baseUrl` for the service. This is useful for pointing at localhost for testing or a proxy.
This commit is contained in:
@@ -180,7 +180,7 @@
|
||||
|
||||
// Unused attributes happen thanks to defined, but unused structures
|
||||
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
||||
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
||||
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
||||
// unused imports in fully featured APIs. Same with unused_mut ... .
|
||||
#![allow(unused_imports, unused_mut, dead_code)]
|
||||
|
||||
@@ -311,6 +311,8 @@ pub struct Taskqueue<C, A> {
|
||||
client: RefCell<C>,
|
||||
auth: RefCell<A>,
|
||||
_user_agent: String,
|
||||
_base_url: String,
|
||||
_root_url: String,
|
||||
}
|
||||
|
||||
impl<'a, C, A> Hub for Taskqueue<C, A> {}
|
||||
@@ -323,6 +325,8 @@ impl<'a, C, A> Taskqueue<C, A>
|
||||
client: RefCell::new(client),
|
||||
auth: RefCell::new(authenticator),
|
||||
_user_agent: "google-api-rust-client/1.0.4".to_string(),
|
||||
_base_url: "https://www.googleapis.com/taskqueue/v1beta2/projects/".to_string(),
|
||||
_root_url: "https://www.googleapis.com/".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,6 +346,26 @@ impl<'a, C, A> Taskqueue<C, A>
|
||||
self._user_agent = agent_name;
|
||||
prev
|
||||
}
|
||||
|
||||
/// Set the base url to use in all requests to the server.
|
||||
/// It defaults to `https://www.googleapis.com/taskqueue/v1beta2/projects/`.
|
||||
///
|
||||
/// Returns the previously set base url.
|
||||
pub fn base_url(&mut self, new_base_url: String) -> String {
|
||||
let prev = self._base_url.clone();
|
||||
self._base_url = new_base_url;
|
||||
prev
|
||||
}
|
||||
|
||||
/// Set the root url to use in all requests to the server.
|
||||
/// It defaults to `https://www.googleapis.com/`.
|
||||
///
|
||||
/// Returns the previously set root url.
|
||||
pub fn root_url(&mut self, new_root_url: String) -> String {
|
||||
let prev = self._root_url.clone();
|
||||
self._root_url = new_root_url;
|
||||
prev
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -852,7 +876,7 @@ impl<'a, C, A> TaskqueueGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A:
|
||||
|
||||
params.push(("alt", "json".to_string()));
|
||||
|
||||
let mut url = "https://www.googleapis.com/taskqueue/v1beta2/projects/{project}/taskqueues/{taskqueue}".to_string();
|
||||
let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}";
|
||||
if self._scopes.len() == 0 {
|
||||
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
||||
}
|
||||
@@ -1120,7 +1144,7 @@ impl<'a, C, A> TaskLeaseCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau
|
||||
|
||||
params.push(("alt", "json".to_string()));
|
||||
|
||||
let mut url = "https://www.googleapis.com/taskqueue/v1beta2/projects/{project}/taskqueues/{taskqueue}/tasks/lease".to_string();
|
||||
let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/lease";
|
||||
if self._scopes.len() == 0 {
|
||||
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
||||
}
|
||||
@@ -1408,7 +1432,7 @@ impl<'a, C, A> TaskInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa
|
||||
|
||||
params.push(("alt", "json".to_string()));
|
||||
|
||||
let mut url = "https://www.googleapis.com/taskqueue/v1beta2/projects/{project}/taskqueues/{taskqueue}/tasks".to_string();
|
||||
let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks";
|
||||
if self._scopes.len() == 0 {
|
||||
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
||||
}
|
||||
@@ -1680,7 +1704,7 @@ impl<'a, C, A> TaskDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa
|
||||
}
|
||||
|
||||
|
||||
let mut url = "https://www.googleapis.com/taskqueue/v1beta2/projects/{project}/taskqueues/{taskqueue}/tasks/{task}".to_string();
|
||||
let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/{task}";
|
||||
if self._scopes.len() == 0 {
|
||||
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
||||
}
|
||||
@@ -1938,7 +1962,7 @@ impl<'a, C, A> TaskPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau
|
||||
|
||||
params.push(("alt", "json".to_string()));
|
||||
|
||||
let mut url = "https://www.googleapis.com/taskqueue/v1beta2/projects/{project}/taskqueues/{taskqueue}/tasks/{task}".to_string();
|
||||
let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/{task}";
|
||||
if self._scopes.len() == 0 {
|
||||
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
||||
}
|
||||
@@ -2227,7 +2251,7 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut
|
||||
|
||||
params.push(("alt", "json".to_string()));
|
||||
|
||||
let mut url = "https://www.googleapis.com/taskqueue/v1beta2/projects/{project}/taskqueues/{taskqueue}/tasks".to_string();
|
||||
let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks";
|
||||
if self._scopes.len() == 0 {
|
||||
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
||||
}
|
||||
@@ -2476,7 +2500,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth
|
||||
|
||||
params.push(("alt", "json".to_string()));
|
||||
|
||||
let mut url = "https://www.googleapis.com/taskqueue/v1beta2/projects/{project}/taskqueues/{taskqueue}/tasks/{task}".to_string();
|
||||
let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/{task}";
|
||||
if self._scopes.len() == 0 {
|
||||
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
||||
}
|
||||
@@ -2744,7 +2768,7 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa
|
||||
|
||||
params.push(("alt", "json".to_string()));
|
||||
|
||||
let mut url = "https://www.googleapis.com/taskqueue/v1beta2/projects/{project}/taskqueues/{taskqueue}/tasks/{task}".to_string();
|
||||
let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/{task}";
|
||||
if self._scopes.len() == 0 {
|
||||
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
||||
}
|
||||
@@ -2961,4 +2985,3 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user