Split out common api client code into separate crate

This commit is contained in:
philippeitis
2022-09-24 20:36:01 -07:00
parent 5e9fbf1f7f
commit e6be1edb45
5 changed files with 890 additions and 13 deletions

View File

@@ -31,13 +31,15 @@ anyhow = "^ 1.0"
hyper-rustls = "0.23.0"
## Must match the one hyper uses, otherwise there are duplicate similarly named `Mime` structs
mime = "^ 0.2.0"
serde = "^ 1.0"
serde = { version = "^ 1.0", features = ["derive"] }
serde_json = "^ 1.0"
serde_derive = "^ 1.0"
## TODO: Make yup-oauth2 optional
## yup-oauth2 = { version = "^ 7.0", optional = true }
yup-oauth2 = "^ 7.0"
itertools = "^ 0.10"
% if 'is_executable' not in cargo:
google-api-client = { path = "../../google-api-client" }
% endif
% for dep in cargo.get('dependencies', list()):
${dep}
% endfor
@@ -50,7 +52,6 @@ ${dep}
crate_name_we_depend_on = library_to_crate_name(api_name, suffix=make.depends_on_suffix)
%>\
% if make.depends_on_suffix is not None:
[dependencies.${crate_name_we_depend_on}]

View File

@@ -30,6 +30,8 @@ use http::Uri;
use hyper::client::connect;
use tokio::io::{AsyncRead, AsyncWrite};
use tower_service;
use serde::{Serialize, Deserialize};
use crate::{client, client::GetToken};
// ##############

View File

@@ -40,21 +40,14 @@ ${lib.docs(c)}
<%util:gen_info source="${self.uri}" />\
</%block>
#[macro_use]
extern crate serde_derive;
// Re-export the hyper and hyper_rustls crate, they are required to build the hub
pub extern crate hyper;
pub extern crate hyper_rustls;
extern crate serde;
extern crate serde_json;
pub use hyper;
pub use hyper_rustls;
// Re-export the yup_oauth2 crate, that is required to call some methods of the hub and the client
pub extern crate yup_oauth2 as oauth2;
extern crate mime;
extern crate url;
pub extern crate google_api_client as client;
pub mod api;
pub mod client;
// Re-export the hub type and some basic client structs
pub use api::${hub_type};