googapis 0.6.0

This library generated from Google API using tonic-build.
docs.rs failed to build googapis-0.6.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

This library generated from Google API using tonic-build.

Example

The complete code can be found here.

Cargo.toml:

[dependencies]
googapis = { version = "0.5", features = ["google-spanner-admin-database-v1"] }
gouth = { version = "0.2" }
tonic = { version = "0.5", features = ["tls"] }
prost = "0.8"
prost-types = "0.8"
tokio = { version = "1.9", features = ["rt-multi-thread", "time", "fs", "macros"] }

main.rs:

use googapis::{
google::spanner::admin::database::v1::{
database_admin_client::DatabaseAdminClient, ListDatabasesRequest,
},
CERTIFICATES,
};
use gouth::Token;
use tonic::{
metadata::MetadataValue,
transport::{Certificate, Channel, ClientTlsConfig},
Request,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let project = std::env::var("PROJECT")?;
let instance = std::env::var("INSTANCE")?;
let token = Token::new()?;

let tls_config = ClientTlsConfig::new()
.ca_certificate(Certificate::from_pem(CERTIFICATES))
.domain_name("spanner.googleapis.com");

let channel = Channel::from_static("https://spanner.googleapis.com")
.tls_config(tls_config)?
.connect()
.await?;

let mut service = DatabaseAdminClient::with_interceptor(channel, move |mut req: Request<()>| {
let token = &*token.header_value().unwrap();
let meta = MetadataValue::from_str(token).unwrap();
req.metadata_mut().insert("authorization", meta);
Ok(req)
});

let response = service
.list_databases(Request::new(ListDatabasesRequest {
parent: format!("projects/{}/instances/{}", project, instance),
page_size: 100,
..Default::default()
}))
.await?;

println!("RESPONSE={:?}", response);

Ok(())
}