#google #google-api

google-api-proto

This library generated from googleapis/googleapis using tonic-build

644 stable releases

new 1.644.0 May 21, 2024
1.615.0 Apr 30, 2024
1.571.0 Mar 30, 2024
1.452.0 Dec 29, 2023
1.0.0-alpha.2 Dec 30, 2021

#1339 in Network programming

Download history 594/week @ 2024-01-29 534/week @ 2024-02-05 1422/week @ 2024-02-12 1325/week @ 2024-02-19 1924/week @ 2024-02-26 3551/week @ 2024-03-04 2858/week @ 2024-03-11 3105/week @ 2024-03-18 1832/week @ 2024-03-25 2180/week @ 2024-04-01 1958/week @ 2024-04-08 2391/week @ 2024-04-15 1571/week @ 2024-04-22 2029/week @ 2024-04-29 1757/week @ 2024-05-06 1669/week @ 2024-05-13

7,175 downloads per month
Used in 4 crates

MIT/Apache

64MB
1M SLoC

google-api-proto

ci pub doc version

This library generated from googleapis/googleapis using tonic-build.

Overview

This library contains all the code generated from the googleapis/googleapis.

When using each product API, you must explicitly include it in your build using a feature flag.
For example, if you want to use Cloud Pub/Sub, write features = ["google-pubsub-v1"] to Cargo.toml.

The feature name is the period of the package name of each proto file, replaced by a hyphen. If you specify a package, it will automatically load the dependent packages and include them in the build. It means that features = ["google-spanner-admin-database-v1"] is the same as the code below:

pub mod google {
    pub mod api {
        // generated code
    }
    pub mod iam {
        pub mod v1 {
            // generated code
        }
    }
    pub mod longrunning {
        // generated code
    }
    pub mod r#type {
        // generated code
    }
    pub mod rpc {
        // generated code
    }
    pub mod spanner {
        pub mod admin {
            pub mod database {
                pub mod v1 {
                    // generated code
                }
            }
        }
    }
}

In addition, multiple features can be specified.
The list of available features can be found here.

Version matrices

google-api-proto tonic tonic-build
1.0.0 <= 0.6.x 0.6.x
1.59.0 <= 0.7.x 0.7.x
1.243.0 <= 0.8.x 0.8.x
1.280.0 <= 0.9.x 0.9.x
1.415.0 <= 0.10.x 0.10.x
1.516.0 <= 0.11.x 0.11.x

Example

The complete code can be found here.

Cargo.toml:

[dependencies]
# For runtime
tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread"] }
# For google authentication
google-authz = { version = "1.0.0-alpha.5", features = ["tonic"] }
# For gRPC
tonic = { version = "0.11.0", features = ["tls", "tls-webpki-roots"] }
prost = "0.12.3"
prost-types = "0.12.3"
google-api-proto = { version = "1", features = ["google-spanner-admin-database-v1"] }

main.rs:

use std::env;

use google_api_proto::google::spanner::admin::database::v1::{
    database_admin_client::DatabaseAdminClient, ListDatabasesRequest,
};
use google_authz::GoogleAuthz;
use tonic::{transport::Channel, Request};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let project = "google project id";
    let instance = "spanner instance name";

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

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

    Ok(())
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Dependencies

~4–6MB
~100K SLoC