forked from mechiru/google-authz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtonic.rs
26 lines (21 loc) · 865 Bytes
/
tonic.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::env;
use google_api_proto::google::pubsub::v1::{publisher_client::PublisherClient, ListTopicsRequest};
use google_authz::GoogleAuthz;
use tonic::{transport::Channel, Request};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt::init();
let project = env::args().nth(1).expect("cargo run --bin tonic -- <GCP_PROJECT_ID>");
let channel = Channel::from_static("https://pubsub.googleapis.com").connect().await?;
let channel = GoogleAuthz::new(channel).await;
let mut client = PublisherClient::new(channel);
let response = client
.list_topics(Request::new(ListTopicsRequest {
project: format!("projects/{}", project),
page_size: 10,
..Default::default()
}))
.await?;
println!("response = {:#?}", response);
Ok(())
}