Crates.io | gcloud-sdk |
lib.rs | gcloud-sdk |
version | |
source | src |
created_at | 2022-07-03 17:04:34.95181 |
updated_at | 2024-12-02 18:46:13.335418 |
description | Async Google gRPC/REST APIs and the client implementation hiding complexity of GCP authentication based on Tonic middleware and Reqwest. |
homepage | |
repository | https://github.com/abdolence/gcloud-sdk-rs |
max_upload_size | |
id | 618443 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Async Google Cloud Platform (GCP) gRPC/REST APIs client implementation based on Tonic middleware and Reqwest.
This is NOT OFFICIAL Google Cloud SDK (and it doesn't exist for Rust at the time this page updated).
This library contains all the code generated from the Google API for gRPC and REST APIs.
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.
In addition, multiple features can be specified.
The list of available features can be found here.
// The library handles getting token from environment automatically
let firestore_client: GoogleApi<FirestoreClient<GoogleAuthMiddleware>> =
GoogleApi::from_function(
FirestoreClient::new,
"https://firestore.googleapis.com",
// cloud resource prefix: used only for some of the APIs (such as Firestore)
Some(cloud_resource_prefix.clone()),
)
.await?;
let response = firestore_client
.get()
.list_documents(tonic::Request::new(ListDocumentsRequest {
parent: format!("{}/documents", cloud_resource_prefix),
..Default::default()
}))
.await?;
More complete examples are located here.
Cargo.toml:
[dependencies]
gcloud-sdk = { version = "0.25", features = ["google-firestore-v1"] }
let google_rest_client = gcloud_sdk::GoogleRestApi::new().await?;
let response = gcloud_sdk::google_rest_apis::storage_v1::buckets_api::storage_buckets_list(
&google_rest_client.create_google_storage_v1_config().await?,
gcloud_sdk::google_rest_apis::storage_v1::buckets_api::StoragePeriodBucketsPeriodListParams {
project: google_project_id,
..Default::default()
}
).await?;
Default Scope is https://www.googleapis.com/auth/cloud-platform
.
To specify custom scopes there is from_function_with_scopes()
function
instead of from_function()
;
Looks for credentials in the following places, preferring the first location found:
gcloud auth application-default login
.The library provides the support for workload identity federation support to use "keyless" integrations with different providers:
AWS provider is not supported yet (feel free to open a PR to support, https://github.com/abdolence/gcloud-sdk-rs/issues/29).
Don't confuse gcloud auth login
with gcloud auth application-default login
for local development,
since the first authorize only gcloud
tool to access the Cloud Platform.
The latter obtains user access credentials via a web flow and puts them in the well-known location for Application Default Credentials (ADC).
This command is useful when you are developing code that would normally use a service account but need to run the code in a local development environment where it's easier to provide user credentials.
So to work for local development you need to use gcloud auth application-default login
.
Sometimes using proto generated APIs are tedious and cumbersome, so you may need to introduce facade APIs on top of them:
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
The library was started as a fork of mechiru/googapis and mechiru/gouth libraries, but now includes much more: